![]() |
SUMO - Simulation of Urban MObility
|
#include <StringTokenizer.h>
Public Member Functions | |
std::string | front () |
std::string | get (int pos) const |
std::vector< std::string > | getVector () |
bool | hasNext () |
std::string | next () |
void | reinit () |
int | size () const |
StringTokenizer () | |
StringTokenizer (std::string tosplit) | |
constructor same as StringTokenizer(tosplit, StringTokenizer.WHITECHARS) tosplit is the string to split into substrings. If the string between two split positions is empty, it will not be returned. More... | |
StringTokenizer (std::string tosplit, std::string token, bool splitAtAllChars=false) | |
constructor the first string will be split at the second string's occurences. If the optional third parameter is true, the string will be split whenever a char from the second string occurs. If the string between two split positions is empty, it will nevertheless be returned. More... | |
StringTokenizer (std::string tosplit, int special) | |
constructor When StringTokenizer.NEWLINE is used as second parameter, the string will be split at all occurences of a newline character (0x0d / 0x0a) When StringTokenizer.WHITECHARS is used as second parameter, the string will be split at all characters below 0x20 (SPACE) All other ints specified as second parameter are casted int o a char at which the string will be splitted. More... | |
~StringTokenizer () | |
Static Public Attributes | |
static const int | NEWLINE = -256 |
static const int | SPACE = 32 |
static const int | TAB = 9 |
static const int | WHITECHARS = -257 |
Private Types | |
typedef std::vector< int > | SizeVector |
Private Member Functions | |
void | prepare (const std::string &tosplit, const std::string &token, bool splitAtAllChars) |
void | prepareWhitechar (const std::string &tosplit) |
Private Attributes | |
SizeVector | myLengths |
int | myPos |
SizeVector | myStarts |
std::string | myTosplit |
StringTokenizer A class similar to the StringTokenizer from Java. It splits a string at the given string or character (or one of the special cases NEWLINE or WHITECHAR) and allows to iterate over the so generated substrings.
The normal usage is like this:
StringTokenizer st(CString("This is a line"), ' '); while(st.hasNext()) cout << st.next() << endl;
This would generate the output:
This is a line
There is something to know about the behaviour: When using WHITECHAR, a list of whitechars occuring in the string to split is regarded as a single divider. All other parameter will use multiple occurences of operators as a list of single divider and the string between them will have a length of zero.
Definition at line 63 of file StringTokenizer.h.
|
private |
a list of positions/lengths
Definition at line 139 of file StringTokenizer.h.
|
inline |
default constructor
Definition at line 80 of file StringTokenizer.h.
References front(), getVector(), hasNext(), next(), prepare(), prepareWhitechar(), reinit(), size(), and ~StringTokenizer().
StringTokenizer::StringTokenizer | ( | std::string | tosplit | ) |
constructor same as StringTokenizer(tosplit, StringTokenizer.WHITECHARS) tosplit is the string to split into substrings. If the string between two split positions is empty, it will not be returned.
Definition at line 45 of file StringTokenizer.cpp.
References prepareWhitechar().
StringTokenizer::StringTokenizer | ( | std::string | tosplit, |
std::string | token, | ||
bool | splitAtAllChars = false |
||
) |
constructor the first string will be split at the second string's occurences. If the optional third parameter is true, the string will be split whenever a char from the second string occurs. If the string between two split positions is empty, it will nevertheless be returned.
Definition at line 51 of file StringTokenizer.cpp.
References prepare().
StringTokenizer::StringTokenizer | ( | std::string | tosplit, |
int | special | ||
) |
constructor When StringTokenizer.NEWLINE is used as second parameter, the string will be split at all occurences of a newline character (0x0d / 0x0a) When StringTokenizer.WHITECHARS is used as second parameter, the string will be split at all characters below 0x20 (SPACE) All other ints specified as second parameter are casted int o a char at which the string will be splitted.
Definition at line 57 of file StringTokenizer.cpp.
References NEWLINE, prepare(), prepareWhitechar(), TAB, and WHITECHARS.
StringTokenizer::~StringTokenizer | ( | ) |
std::string StringTokenizer::front | ( | ) |
returns the first substring without moving the iterator
Definition at line 103 of file StringTokenizer.cpp.
References myLengths, myStarts, and myTosplit.
Referenced by StringTokenizer().
std::string StringTokenizer::get | ( | int | pos | ) | const |
returns the item at the given position
Definition at line 113 of file StringTokenizer.cpp.
References myLengths, myStarts, and myTosplit.
Referenced by NamedColumnsParser::get(), NIImporter_DlrNavteq::EdgesHandler::getColumn(), libsumo::Vehicle::getParameter(), LandmarkLookupTable< E, V >::LandmarkLookupTable(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), NIImporter_DlrNavteq::ProhibitionHandler::report(), NIImporter_DlrNavteq::ConnectedLanesHandler::report(), and libsumo::Vehicle::setParameter().
std::vector< std::string > StringTokenizer::getVector | ( | ) |
Definition at line 178 of file StringTokenizer.cpp.
References hasNext(), next(), reinit(), and size().
Referenced by NIXMLNodesHandler::addJoinCluster(), NIXMLNodesHandler::addJoinExclusion(), MSDevice_SSM::getMeasuresAndThresholds(), NWWriter_DlrNavteq::getSinglePostalCode(), OptionsCont::getStringVector(), PCLoaderDlrNavteq::loadPolyFile(), MSDetectorFileOutput::MSDetectorFileOutput(), MSSOTLPolicy5DFamilyStimulus::MSSOTLPolicy5DFamilyStimulus(), MSTriggeredRerouter::MSTriggeredRerouter(), NIImporter_Vissim::NIVissimXMLHandler_Streckendefinition::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), Distribution_Parameterized::parse(), GNEAttributeCarrier::parse(), RGBColor::parseColor(), MSEdge::parseEdgesList(), MSRouteHandler::parseFromViaTo(), string2time(), and StringTokenizer().
bool StringTokenizer::hasNext | ( | ) |
returns the information whether further substrings exist
Definition at line 86 of file StringTokenizer.cpp.
References myPos, and myStarts.
Referenced by NLHandler::addE2Detector(), MSRouteHandler::addPersonTrip(), RORouteHandler::addPersonTrip(), ROPerson::addTrip(), NLHandler::beginEdgeParsing(), canParseVehicleClasses(), libsumo::Simulation::findIntermodalRoute(), MSDevice_SSM::getMeasuresAndThresholds(), SUMOSAXAttributesImpl_Cached::getShape(), SUMOSAXAttributesImpl_Xerces::getShape(), getVector(), NIImporter_OpenStreetMap::insertEdge(), GNEAttributeCarrier::isGenericParametersValid(), GNEFrame::GenericParametersEditor::onCmdSetGenericParameter(), MSRouteHandler::openRouteDistribution(), RORouteHandler::openRouteDistribution(), RORouteHandler::parseEdges(), NLHandler::parseLanes(), GeomConvHelper::parseShapeReporting(), SUMOSAXAttributes::parseStringSet(), SUMOSAXAttributes::parseStringVector(), parseVehicleClasses(), ODMatrix::readV(), NamedColumnsParser::reinitMap(), Option_IntVector::set(), Option_FloatVector::set(), MSTransportable::Stage_Trip::setArrived(), GNECrossing::setGenericParametersStr(), GNEConnection::setGenericParametersStr(), GNEPoly::setGenericParametersStr(), GNELane::setGenericParametersStr(), GNEJunction::setGenericParametersStr(), GNEPOI::setGenericParametersStr(), GNEEdge::setGenericParametersStr(), GNEAdditional::setGenericParametersStr(), and StringTokenizer().
std::string StringTokenizer::next | ( | ) |
returns the next substring when it exists. Otherwise the behaviour is undefined
Definition at line 90 of file StringTokenizer.cpp.
References myLengths, myPos, myStarts, and myTosplit.
Referenced by NLHandler::addE2Detector(), NLHandler::beginEdgeParsing(), canParseVehicleClasses(), SUMOSAXAttributesImpl_Cached::getBoundary(), SUMOSAXAttributesImpl_Xerces::getBoundary(), MSDevice_SSM::getMeasuresAndThresholds(), SUMOSAXAttributesImpl_Cached::getShape(), SUMOSAXAttributesImpl_Xerces::getShape(), getVector(), NIImporter_OpenStreetMap::insertEdge(), GNEAttributeCarrier::isGenericParametersValid(), PCLoaderVisum::load(), GNEFrame::GenericParametersEditor::onCmdSetGenericParameter(), MSRouteHandler::openRouteDistribution(), RORouteHandler::openRouteDistribution(), GeomConvHelper::parseBoundaryReporting(), NLHandler::parseLanes(), GeomConvHelper::parseShapeReporting(), SUMOSAXAttributes::parseStringSet(), SUMOSAXAttributes::parseStringVector(), ODMatrix::parseTimeLine(), parseVehicleClasses(), ODMatrix::readO(), ODMatrix::readTime(), ODMatrix::readV(), NamedColumnsParser::reinitMap(), NIImporter_DlrNavteq::NamesHandler::report(), NIImporter_DlrNavteq::TimeRestrictionsHandler::report(), NIImporter_DlrNavteq::ProhibitionHandler::report(), NIImporter_DlrNavteq::ConnectedLanesHandler::report(), Option_IntVector::set(), Option_FloatVector::set(), GNECrossing::setGenericParametersStr(), GNEConnection::setGenericParametersStr(), GNEPoly::setGenericParametersStr(), GNELane::setGenericParametersStr(), GNEJunction::setGenericParametersStr(), GNEPOI::setGenericParametersStr(), GNEEdge::setGenericParametersStr(), GNEAdditional::setGenericParametersStr(), and StringTokenizer().
|
private |
splits the first string at all occurences of the second. If the third parameter is true split at all chars given in the second
Definition at line 130 of file StringTokenizer.cpp.
References myLengths, and myStarts.
Referenced by StringTokenizer().
|
private |
splits the first string at all occurences of whitechars
Definition at line 156 of file StringTokenizer.cpp.
References myLengths, myStarts, and SPACE.
Referenced by StringTokenizer().
void StringTokenizer::reinit | ( | ) |
reinitialises the internal iterator
Definition at line 82 of file StringTokenizer.cpp.
References myPos.
Referenced by getVector(), and StringTokenizer().
int StringTokenizer::size | ( | ) | const |
returns the number of existing substrings
Definition at line 126 of file StringTokenizer.cpp.
References myStarts.
Referenced by NamedColumnsParser::get(), SUMOSAXAttributesImpl_Cached::getBoundary(), SUMOSAXAttributesImpl_Xerces::getBoundary(), NIImporter_DlrNavteq::EdgesHandler::getColumn(), libsumo::Vehicle::getParameter(), getVector(), NamedColumnsParser::hasFullDefinition(), NIImporter_OpenStreetMap::insertEdge(), NamedColumnsParser::know(), LandmarkLookupTable< E, V >::LandmarkLookupTable(), GeomConvHelper::parseBoundaryReporting(), ODMatrix::parseTimeLine(), ODMatrix::readO(), NIImporter_DlrNavteq::NamesHandler::report(), NIImporter_DlrNavteq::ProhibitionHandler::report(), NIImporter_DlrNavteq::ConnectedLanesHandler::report(), libsumo::Vehicle::setParameter(), and StringTokenizer().
|
private |
the list of substring lengths
Definition at line 151 of file StringTokenizer.h.
Referenced by front(), get(), next(), prepare(), and prepareWhitechar().
|
private |
the current position in the list of substrings
Definition at line 145 of file StringTokenizer.h.
|
private |
the list of substring starts
Definition at line 148 of file StringTokenizer.h.
Referenced by front(), get(), hasNext(), next(), prepare(), prepareWhitechar(), and size().
|
private |
the string to split
Definition at line 142 of file StringTokenizer.h.
|
static |
identifier for splitting the given string at all newline characters
Definition at line 66 of file StringTokenizer.h.
Referenced by StringTokenizer().
|
static |
the ascii index of the highest whitespace character
Definition at line 73 of file StringTokenizer.h.
Referenced by prepareWhitechar().
|
static |
the ascii index of the tab character
Definition at line 76 of file StringTokenizer.h.
Referenced by NIImporter_DlrNavteq::NamesHandler::report(), NIImporter_DlrNavteq::ProhibitionHandler::report(), NIImporter_DlrNavteq::ConnectedLanesHandler::report(), and StringTokenizer().
|
static |
identifier for splitting the given string at all whitespace characters
Definition at line 70 of file StringTokenizer.h.
Referenced by ROJTRTurnDefLoader::myStartElement(), ODMatrix::readO(), ODMatrix::readTime(), ODMatrix::readV(), NIImporter_DlrNavteq::EdgesHandler::report(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), NIImporter_DlrNavteq::TimeRestrictionsHandler::report(), and StringTokenizer().