Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4String Class Reference

#include <G4String.hh>

Inheritance diagram for G4String:

Public Types

enum  caseCompare { exact , ignoreCase }
enum  stripType { leading , trailing , both }

Public Member Functions

 G4String ()=default
 G4String (const std::string &)
 G4String (const G4String &)
 G4String (std::string &&)
 G4String (G4String &&)
G4Stringoperator= (const G4String &)
G4Stringoperator= (G4String &&)
 operator const char * () const
 Implicitly convert to const char*.
G4int compareTo (std::string_view, caseCompare mode=exact) const
 Override of subscript operator for int to suppress C2666 errors with MSVC.
std::istream & readLine (std::istream &, G4bool skipWhite=true)
 Deprecated function.
G4Stringremove (size_type)
 Deprecated function.
G4bool contains (const std::string &) const
 Deprecated function.
G4bool contains (char) const
 Deprecated function.
G4String strip (stripType strip_Type=trailing, char ch=' ')
 Deprecated function.
void toLower ()
 Deprecated function.
void toUpper ()
 Deprecated function.

Detailed Description

Definition at line 61 of file G4String.hh.

Member Enumeration Documentation

◆ caseCompare

Deprecated
Will be removed in future release
Enumerator
exact 
ignoreCase 

Definition at line 66 of file G4String.hh.

67 {
68 exact,
70 };
@ ignoreCase
Definition G4String.hh:69

◆ stripType

Deprecated
Will be removed in future release
Enumerator
leading 
trailing 
both 

Definition at line 74 of file G4String.hh.

75 {
76 leading,
78 both
79 };

Constructor & Destructor Documentation

◆ G4String() [1/5]

G4String::G4String ( )
inlinedefault

◆ G4String() [2/5]

G4String::G4String ( const std::string & )
inline

◆ G4String() [3/5]

G4String::G4String ( const G4String & )
inline

◆ G4String() [4/5]

G4String::G4String ( std::string && )
inline

◆ G4String() [5/5]

G4String::G4String ( G4String && )
inline

Member Function Documentation

◆ compareTo()

G4int G4String::compareTo ( std::string_view ,
caseCompare mode = exact ) const
inline

Override of subscript operator for int to suppress C2666 errors with MSVC.

Deprecated
Will be removed at the same time as operator const char* that requires it

This override is required because of G4String's provision of an implicit conversion operator to const char*. Together with the subscript operator and C++'s built-in operator[](const char*, int) operator, use of G4String::operator[] will trigger [MSVC error C2666](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c2666?view=msvc-170) This is a known issue with mixing implicit conversion to const char* and subscript operators. Provision of the override with int` argument is thus a workaround until the conversion operator is removed. */ inline reference operator[](int);

/This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
inline const_reference operator[](int) const;

/** Deprecated function

Deprecated
Use std::string::compare or G4StrUtil::icompare instead

◆ contains() [1/2]

G4bool G4String::contains ( char ) const
inline

Deprecated function.

Deprecated
Use G4StrUtil::contains instead

◆ contains() [2/2]

G4bool G4String::contains ( const std::string & ) const
inline

Deprecated function.

Deprecated
Use G4StrUtil::contains instead

◆ operator const char *()

G4String::operator const char * ( ) const
inline

Implicitly convert to const char*.

Deprecated
Will be removed in future releases for std::string compliance If passing G4String to functions requiring const char*, use std::string::c_str to explicitly convert. G4String also implicitly converts to std::string_view to match the std::string interface.

◆ operator=() [1/2]

G4String & G4String::operator= ( const G4String & )
inline

◆ operator=() [2/2]

G4String & G4String::operator= ( G4String && )
inline

◆ readLine()

std::istream & G4String::readLine ( std::istream & ,
G4bool skipWhite = true )
inline

Deprecated function.

Deprecated
Use std::getline plus G4StrUtil::lstrip instead

◆ remove()

G4String & G4String::remove ( size_type )
inline

Deprecated function.

Deprecated
Use std::string::erase instead

◆ strip()

G4String G4String::strip ( stripType strip_Type = trailing,
char ch = ' ' )
inlinenodiscard

Deprecated function.

Deprecated
Use G4StrUtil functions instead

◆ toLower()

void G4String::toLower ( )
inline

Deprecated function.

Deprecated
Use G4StrUtil functions instead

◆ toUpper()

void G4String::toUpper ( )
inline

Deprecated function.

Deprecated
Use G4StrUtil functions instead

The documentation for this class was generated from the following file: