Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
|
Query and manipulation functions for G4String. More...
Functions | |
void | to_lower (G4String &str) |
Convert string to lowercase. | |
G4String | to_lower_copy (G4String str) |
Return lowercased copy of string. | |
void | to_upper (G4String &str) |
Convert string to uppercase. | |
G4String | to_upper_copy (G4String str) |
Return uppercase copy of string. | |
void | lstrip (G4String &str, char ch=' ') |
Remove leading characters from string. | |
void | rstrip (G4String &str, char ch=' ') |
Remove trailing characters from string. | |
void | strip (G4String &str, char ch=' ') |
Remove leading and trailing characters from string. | |
G4String | lstrip_copy (G4String str, char ch=' ') |
Return copy of string with leading characters removed. | |
G4String | rstrip_copy (G4String str, char ch=' ') |
Return copy of string with trailing characters removed. | |
G4String | strip_copy (G4String str, char ch=' ') |
Return copy of string with leading and trailing characters removed. | |
G4bool | contains (const G4String &str, std::string_view ss) |
Check if a string contains a given substring. | |
G4bool | contains (const G4String &str, char ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
G4bool | contains (const G4String &str, const char *ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
G4bool | contains (const G4String &str, const G4String &ss) |
G4int | icompare (std::string_view lhs, std::string_view rhs) |
Case insensitive comparison of two strings. | |
bool | starts_with (const G4String &str, std::string_view ss) |
Return true if a string starts with a given prefix. | |
bool | starts_with (const G4String &str, G4String::value_type ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | starts_with (const G4String &str, const char *ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | starts_with (const G4String &str, const G4String &ss) |
bool | ends_with (const G4String &str, std::string_view ss) |
Return true if a string ends with a given suffix. | |
bool | ends_with (const G4String &str, G4String::value_type ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | ends_with (const G4String &str, const char *ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | ends_with (const G4String &str, const G4String &ss) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | safe_erase (G4String &str, G4String::size_type index=0, G4String::size_type count=G4String::npos) |
Remove specified in-range characters from string. | |
std::istream & | readline (std::istream &is, G4String &str, G4bool skipWhite=true) |
Read characters into a G4String from an input stream until end-of-line. | |
Query and manipulation functions for G4String.
Additional free functions that are not part of the std::string
interface as of the minimum C++ standard supported by Geant4 (currently C++17).
G4String
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::string_view
and const char*
substring arguments. G4String currently provides implicit conversion to const char*
, which makes the calls ambiguous due to std::string
's implicit conversion to std::string_view
Check if a string contains a given substring.
[in] | str | string to be checked |
[in] | ss | substring to check for |
true | if str contains ss |
false | otherwise |
Referenced by G4AdjointStackingAction::ClassifyNewTrack(), G4TrajectoryDrawByEncounteredVolume::Draw(), G4TrajectoryEncounteredVolumeFilter::Evaluate(), G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate(), G4GDMLWrite::GenerateName(), G3VolTableEntry::GetMasterClone(), G4VVisCommand::InterpolateViews(), G4AdjointTrackingAction::PreUserTrackingAction(), G4LatticeReader::ProcessToken(), G4UIQt::ReceiveG4cout(), G4VisCommandDrawTree::SetNewValue(), and G4VisCommandViewerSave::SetNewValue().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return true if a string ends with a given suffix.
[in] | str | string to be checked |
[in] | ss | suffix to check for |
true | if str ends with ss |
false | otherwise |
|
inline |
Case insensitive comparison of two strings.
Converts both input arguments to lower case and returns the result of std::string::compare
with these values.
[in] | lhs | the first string in the comparison |
[in] | rhs | the second string in the comparison |
G4int
if lowercased lhs
appears before(after) lowercased rhs
in lexicographical order, zero if both compare equivalent after lowercasing. Referenced by G4VisCommandSceneHandlerCreate::SetNewValue(), and G4VisCommandsViewerSet::SetNewValue().
void G4StrUtil::lstrip | ( | G4String & | str, |
char | ch = ' ' |
||
) |
Remove leading characters from string.
[in,out] | str | string to strip |
[in] | ch | character to remove |
str
has any leading sequence of ch
removed Referenced by G4UItcsh::CompleteCommand(), and G4UItcsh::ListMatchedCommand().
Return copy of string with leading characters removed.
[in] | str | string to copy and strip |
[in] | ch | character to remove |
str
with any leading sequence of ch
removed Referenced by G4VBasicShell::ApplyShellCommand(), G4UItcsh::CompleteCommand(), and G4UItcsh::ListMatchedCommand().
|
inline |
Read characters into a G4String from an input stream until end-of-line.
std::getline
instead of this function, plus G4StrUtil::lstrip
if leading whitespace removal is required. [in] | is | input stream to read from |
[in,out] | str | string to read into |
[in] | skipWhite | if true, discard leading whitespace from is |
is
Referenced by G3CLRead(), and G4UIcsh::GetCommandLineString().
void G4StrUtil::rstrip | ( | G4String & | str, |
char | ch = ' ' |
||
) |
Remove trailing characters from string.
[in,out] | str | string to strip |
[in] | ch | character to remove |
str
has any trailing sequence of ch
removed Referenced by G4UIcsh::GetCommandLineString(), and G4RadioactiveDecay::LoadDecayTable().
Return copy of string with trailing characters removed.
[in] | str | string to copy and strip |
[in] | ch | character to remove |
str
with any trailing sequence of ch
removed
|
inline |
Remove specified in-range characters from string.
Equivalent to std::string::erase(index, count)
with erasure only occuring if index <= size()
. When index > size()
the string is left unmodified.
std::string::erase
if the start index is already checked, or otherwise known, to be in range. Otherwise, implement the index-size comparison instead of using this function.[in,out] | str | string to erase characters from |
[in] | index | position to start removal from |
[in] | count | number of characters to remove |
str
is unchanged if index > str.size()
, otherwise str
has min(count, str.size() - index)
characters removed starting at index
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::string_view
and const char*
substring arguments. G4String currently provides implicit conversion to const char*
, which makes the calls ambiguous due to std::string
's implicit conversion to std::string_view
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return true if a string starts with a given prefix.
[in] | str | string to be checked |
[in] | ss | prefix to check for |
true | if str starts with ss |
false | otherwise |
void G4StrUtil::strip | ( | G4String & | str, |
char | ch = ' ' |
||
) |
Remove leading and trailing characters from string.
[in,out] | str | string to strip |
[in] | ch | character to remove |
str
has any leading and trailing sequence of ch
removed Referenced by G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate(), G4VViewer::G4VViewer(), G4VViewer::SetName(), G4VisCommandViewerClone::SetNewValue(), G4VisCommandViewerCreate::SetNewValue(), and G4VBasicShell::TerminalHelp().
Return copy of string with leading and trailing characters removed.
[in] | str | string to copy and strip |
[in] | ch | character to remove |
str
with any leading and trailing sequence of ch
removed Referenced by G4VBasicShell::ChangeDirectory(), G4VBasicShell::ChangeDirectoryCommand(), G4VBasicShell::Complete(), G4ConversionUtils::Convert(), G4VBasicShell::FindCommand(), G4VBasicShell::FindDirectory(), G4gsmate(), G4UIArrayString::G4UIArrayString(), G4UItcsh::G4UItcsh(), G4VUIshell::GetCommandTree(), G4VUIshell::ListCommand(), G4VBasicShell::ListDirectory(), G4VBasicShell::ModifyToFullPathCommand(), G4UImanager::RemoveAlias(), G4AttCheck::Standard(), and G4VisManager::ViewerShortName().
|
inline |
Convert string to lowercase.
[in,out] | str | the string to lowercase |
Referenced by G4LatticeReader::ProcessToken(), G4LatticeReader::ReadMapInfo(), and G4INCLXXInterfaceMessenger::SetNewValue().
Return lowercased copy of string.
[in] | str | the string to lowercase |
str
Referenced by G4Colour::AddToMap(), G4UIExecutive::G4UIExecutive(), G4Colour::GetColour(), G4BaseFileManager::GetFileType(), G4VisManager::GetVerbosityValue(), and G4VisFilterManager< T >::SetMode().
|
inline |
Convert string to uppercase.
[in,out] | str | the string to uppercase |
Return uppercase copy of string.
[in] | str | the string to upper case |
str
Referenced by G4UIcommand::ConvertToBool(), and G4UImessenger::StoB().