Mantid
|
#include <StringTokenizer.h>
Public Types | |
using | ConstIterator = std::vector< std::string >::const_iterator |
using | Iterator = std::vector< std::string >::iterator |
enum | Options { TOK_IGNORE_EMPTY = 1 , TOK_TRIM = 2 , TOK_IGNORE_FINAL_EMPTY_TOKEN = 4 } |
Specify tokenizer options. These can be combined using + or |. More... | |
using | TokenVec = std::vector< std::string > |
Public Member Functions | |
const TokenVec & | asVector () |
Returns a vector of tokenized strings. More... | |
std::string & | at (std::size_t index) |
Get a reference to the index'th token. More... | |
const std::string & | at (std::size_t index) const |
Get a const reference to the index'th token. More... | |
Iterator | begin () |
Iterator referring to first element in the container. More... | |
ConstIterator | begin () const |
Const iterator referring to first element in the container. More... | |
ConstIterator | cbegin () const |
Const iterator referring to first element in the container. More... | |
ConstIterator | cend () const |
Const iterator referring to the past-the-end element in the container. More... | |
std::size_t | count () const |
Get the total number of tokens. More... | |
Iterator | end () |
Iterator referring to the past-the-end element in the container. More... | |
ConstIterator | end () const |
Const iterator referring to the past-the-end element in the container. More... | |
std::string & | operator[] (std::size_t index) |
Get a const reference to the index'th token. More... | |
const std::string & | operator[] (std::size_t index) const |
Get a const reference to the index'th token. More... | |
std::size_t | size () const noexcept |
Get the total number of tokens. More... | |
StringTokenizer ()=default | |
Constructs an object from an empty string. More... | |
StringTokenizer (const std::string &str, const std::string &separators, unsigned options=0) | |
Constructor requiring a string to tokenize and a string of separators. More... | |
~StringTokenizer ()=default | |
Destroys the tokenizer. More... | |
Private Attributes | |
std::vector< std::string > | m_tokens |
Definition at line 27 of file StringTokenizer.h.
using Mantid::Kernel::StringTokenizer::ConstIterator = std::vector<std::string>::const_iterator |
Definition at line 37 of file StringTokenizer.h.
using Mantid::Kernel::StringTokenizer::Iterator = std::vector<std::string>::iterator |
Definition at line 36 of file StringTokenizer.h.
using Mantid::Kernel::StringTokenizer::TokenVec = std::vector<std::string> |
Definition at line 35 of file StringTokenizer.h.
Specify tokenizer options. These can be combined using + or |.
Enumerator | |
---|---|
TOK_IGNORE_EMPTY | ignore empty tokens |
TOK_TRIM | remove leading and trailing whitespace from tokens |
TOK_IGNORE_FINAL_EMPTY_TOKEN | ignore an empty token at the end of the string. |
Definition at line 30 of file StringTokenizer.h.
|
default |
Constructs an object from an empty string.
Mantid::Kernel::StringTokenizer::StringTokenizer | ( | const std::string & | str, |
const std::string & | separators, | ||
unsigned | options = 0 |
||
) |
Constructor requiring a string to tokenize and a string of separators.
str | Input string to be separated into tokens. |
separators | List of characters used to separate the input string. |
options | tokenizer settings. The number can be found using the StringTokenizer::Options enum |
Throws | std::runtime_error if options > 7. |
Definition at line 106 of file StringTokenizer.cpp.
References m_tokens, std::to_string(), TOK_IGNORE_EMPTY, TOK_IGNORE_FINAL_EMPTY_TOKEN, and TOK_TRIM.
|
default |
Destroys the tokenizer.
|
inline |
Returns a vector of tokenized strings.
Definition at line 91 of file StringTokenizer.h.
Referenced by Mantid::API::IFunction::categories(), Mantid::API::Algorithm::categories(), Mantid::DataHandling::getGroupNames(), Mantid::Geometry::operator>>(), Mantid::Kernel::UserStringParser::separateComma(), Mantid::Algorithms::SampleLogsBehaviour::setSampleMap(), Mantid::Kernel::Strings::StrParts(), Mantid::Kernel::UserStringParser::Tokenize(), and Mantid::API::Algorithm::workspaceMethodOn().
|
inline |
Get a reference to the index'th token.
index | Index of the requested token. |
Throws | std::out_of_range if the index is out of range. |
Definition at line 105 of file StringTokenizer.h.
References index.
|
inline |
Get a const reference to the index'th token.
index | Index of the requested token. |
Throws | std::out_of_range if the index is out of range. |
Definition at line 98 of file StringTokenizer.h.
References index.
|
inline |
Iterator referring to first element in the container.
Definition at line 49 of file StringTokenizer.h.
Referenced by Mantid::WorkflowAlgorithms::DgsDiagnose::exec(), Mantid::API::AlgorithmFactoryImpl::fillHiddenCategories(), Mantid::API::FileFinderImpl::findRuns(), Mantid::API::FunctionFactoryImpl::getFunctionNamesGUI(), Mantid::DataHandling::GroupDetectors2::RangeHelper::getList(), Mantid::API::Expression::parse(), Mantid::DataHandling::UpdateInstrumentFromFile::parseAsciiHeader(), Mantid::CurveFitting::Functions::CrystalFieldControl::parseStringListAttribute(), Mantid::DataHandling::GroupDetectors2::readInt(), Mantid::API::ExperimentInfo::readParameterMap(), Mantid::DataHandling::PDLoadCharacterizations::readVersion1(), Mantid::Algorithms::ReadGroupsFromFile::readXMLGroupingFile(), Mantid::Algorithms::SampleLogsBehaviour::setSampleMap(), and Mantid::DataHandling::CheckMantidVersion::splitVersionString().
|
inline |
Const iterator referring to first element in the container.
Definition at line 59 of file StringTokenizer.h.
|
inline |
Const iterator referring to first element in the container.
Definition at line 69 of file StringTokenizer.h.
Referenced by Mantid::API::BoxControllerSettingsAlgorithm::initBoxControllerProps(), Mantid::DataHandling::LoadSwans::loadMetaData(), Mantid::Geometry::IsotropicAtomBraggScattererParser::operator()(), Mantid::DataHandling::SampleEnvironmentSpecParser::parseTranslationVector(), Mantid::DataHandling::LoadSpec::readLine(), Mantid::DataHandling::LoadRKH::readUnit(), Mantid::Geometry::strToUnitCell(), and Mantid::Kernel::VMDBase< TYPE >::VMDBase().
|
inline |
Const iterator referring to the past-the-end element in the container.
Definition at line 74 of file StringTokenizer.h.
Referenced by Mantid::API::BoxControllerSettingsAlgorithm::initBoxControllerProps(), Mantid::DataHandling::LoadSwans::loadMetaData(), Mantid::Geometry::IsotropicAtomBraggScattererParser::operator()(), Mantid::DataHandling::SampleEnvironmentSpecParser::parseTranslationVector(), Mantid::DataHandling::LoadSpec::readLine(), Mantid::DataHandling::LoadRKH::readUnit(), Mantid::Geometry::strToUnitCell(), and Mantid::Kernel::VMDBase< TYPE >::VMDBase().
|
inline |
Get the total number of tokens.
Definition at line 110 of file StringTokenizer.h.
Referenced by Mantid::DataHandling::LoadSNSspec::confidence(), Mantid::API::FileFinderImpl::findRuns(), Mantid::DataHandling::GroupDetectors2::RangeHelper::getList(), Mantid::API::getWordsInString(), Mantid::DataHandling::LoadNexusProcessed::getWordsInString(), Mantid::API::BoxControllerSettingsAlgorithm::initBoxControllerProps(), Mantid::CurveFitting::Algorithms::makeNames(), Mantid::Kernel::operator>>(), Mantid::DataHandling::UpdateInstrumentFromFile::parseAsciiHeader(), Mantid::DataHandling::SampleEnvironmentSpecParser::parseTranslationVector(), Mantid::CurveFitting::Algorithms::parseValueRange(), Mantid::DataHandling::LoadRKH::read2DHeader(), Mantid::DataHandling::GroupDetectors2::readInt(), Mantid::API::ExperimentInfo::readParameterMap(), Mantid::DataHandling::LoadRKH::readUnit(), and Mantid::Kernel::Strings::splitToKeyValues().
|
inline |
Iterator referring to the past-the-end element in the container.
Definition at line 54 of file StringTokenizer.h.
Referenced by Mantid::WorkflowAlgorithms::DgsDiagnose::exec(), Mantid::API::AlgorithmFactoryImpl::fillHiddenCategories(), Mantid::API::FileFinderImpl::findRuns(), Mantid::API::FunctionFactoryImpl::getFunctionNamesGUI(), Mantid::DataHandling::GroupDetectors2::RangeHelper::getList(), Mantid::DataHandling::UpdateInstrumentFromFile::parseAsciiHeader(), Mantid::CurveFitting::Functions::CrystalFieldControl::parseStringListAttribute(), Mantid::DataHandling::GroupDetectors2::readInt(), Mantid::API::ExperimentInfo::readParameterMap(), Mantid::DataHandling::PDLoadCharacterizations::readVersion1(), Mantid::Algorithms::ReadGroupsFromFile::readXMLGroupingFile(), Mantid::Algorithms::SampleLogsBehaviour::setSampleMap(), and Mantid::DataHandling::CheckMantidVersion::splitVersionString().
|
inline |
Const iterator referring to the past-the-end element in the container.
Definition at line 64 of file StringTokenizer.h.
|
inline |
Get a const reference to the index'th token.
Indexing an out-of-range element won't throw, but is otherwise undefined behavior.
index | Index of the requested token. |
Definition at line 88 of file StringTokenizer.h.
References index.
|
inline |
Get a const reference to the index'th token.
Indexing an out-of-range element won't throw, but is otherwise undefined behavior.
index | Index of the requested token. |
Definition at line 81 of file StringTokenizer.h.
References index.
|
inlinenoexcept |
Get the total number of tokens.
Definition at line 115 of file StringTokenizer.h.
Referenced by Mantid::API::FileFinderImpl::findRuns(), Mantid::DataHandling::LoadSwans::loadMetaData(), Mantid::Geometry::IsotropicAtomBraggScattererParser::operator()(), Mantid::DataHandling::LoadSpec::readLine(), and Mantid::Geometry::strToUnitCell().
|
private |
Definition at line 118 of file StringTokenizer.h.
Referenced by StringTokenizer().