![]() |
Eclipse SUMO - Simulation of Urban MObility
|
Some static methods for string processing. More...
#include <StringUtils.h>
Static Public Member Functions | |
static std::string | charToHex (unsigned char c) |
static std::string | convertUmlaute (std::string str) |
Converts german "Umlaute" to their latin-version. More... | |
static bool | endsWith (const std::string &str, const std::string suffix) |
Checks whether a given string ends with the suffix. More... | |
static std::string | escapeXML (const std::string &orig, const bool maskDoubleHyphen=false) |
Replaces the standard escapes by their XML entities. More... | |
static unsigned char | hexToChar (const std::string &str) |
static int | hexToInt (const std::string &sData) |
converts a string with a hex value into the integer value described by it by calling the char-type converter More... | |
static std::string | latin1_to_utf8 (std::string str) |
Transfers from Latin 1 (ISO-8859-1) to UTF-8. More... | |
static std::string | prune (const std::string &str) |
Removes trailing and leading whitechars. More... | |
static std::string | replace (std::string str, const char *what, const char *by) |
static bool | startsWith (const std::string &str, const std::string prefix) |
Checks whether a given string starts with the prefix. More... | |
static std::string | substituteEnvironment (std::string str) |
static std::string | to_lower_case (std::string str) |
Transfers the content to lower case. More... | |
static bool | toBool (const std::string &sData) |
converts a string into the bool value described by it by calling the char-type converter More... | |
static double | toDouble (const std::string &sData) |
converts a string into the double value described by it by calling the char-type converter More... | |
static double | toDoubleSecure (const std::string &sData, const double def) |
converts a string into the integer value described by it More... | |
static int | toInt (const std::string &sData) |
converts a string into the integer value described by it by calling the char-type converter, which More... | |
static int | toIntSecure (const std::string &sData, int def) |
converts a string into the integer value described by it More... | |
static long long int | toLong (const std::string &sData) |
converts a string into the long value described by it by calling the char-type converter, which More... | |
static std::string | toTimeString (int time) |
Builds a time string (hh:mm:ss) from the given seconds. More... | |
static std::string | transcode (const XMLCh *const data) |
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8 More... | |
static std::string | transcode (const XMLCh *const data, int length) |
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8 considering the given length More... | |
static std::string | trim (const std::string s, const std::string &t=" \t\n") |
remove leading and trailing whitespace More... | |
static std::string | trim_left (const std::string s, const std::string &t=" \t\n") |
remove leading whitespace from string More... | |
static std::string | trim_right (const std::string s, const std::string &t=" \t\n") |
remove trailing whitespace from string More... | |
static std::string | urlDecode (const std::string &encoded) |
static std::string | urlEncode (const std::string &url, const std::string encodeWhich="") |
Static Public Attributes | |
static std::string | emptyString |
An empty string. More... | |
Some static methods for string processing.
Definition at line 36 of file StringUtils.h.
|
static |
Definition at line 247 of file StringUtils.cpp.
Referenced by urlEncode().
|
static |
Converts german "Umlaute" to their latin-version.
Definition at line 86 of file StringUtils.cpp.
References replace().
Referenced by PCLoaderDlrNavteq::loadPolyFile(), NIImporter_Vissim::VissimSingleTypeParser::readName(), and NBEdge::reinit().
|
static |
Checks whether a given string ends with the suffix.
Definition at line 179 of file StringUtils.cpp.
Referenced by NIImporter_VISUM::getNamedFloat(), MSBaseVehicle::getPrefixedParameter(), NIImporter_Vissim::load(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), GNEApplicationWindow::onCmdSaveAsPlainXML(), and MSBaseVehicle::replaceRouteEdges().
|
static |
Replaces the standard escapes by their XML entities.
The strings &, <, >, ", and ' are replaced by &, <, >, ", and '
[in] | orig | The original string |
[in] | maskDoubleHyphen | Whether – in input shall be converted to -- (semantically equivalent but allowed in XML comments) |
Definition at line 189 of file StringUtils.cpp.
References replace().
Referenced by NBPTStop::addLine(), PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), NIImporter_OpenStreetMap::insertEdge(), MSPerson::MSPersonStage_Walking::routeOutput(), MSStageWaiting::routeOutput(), MSStageDriving::routeOutput(), RODFDetectorCon::save(), RODFDetectorCon::saveAsPOIs(), NBPTStop::write(), NBPTLine::write(), MSFCDExport::write(), OptionsCont::writeConfiguration(), NWWriter_SUMO::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_OpenDrive::writeNormalEdge(), Parameterised::writeParams(), RODFDetectorCon::writeSpeedTrigger(), RODFDetectorCon::writeValidationDetectors(), SUMOPolygon::writeXML(), PointOfInterest::writeXML(), MEInductLoop::writeXMLOutput(), and MSInductLoop::writeXMLOutput().
|
static |
Definition at line 259 of file StringUtils.cpp.
Referenced by urlDecode().
|
static |
converts a string with a hex value into the integer value described by it by calling the char-type converter
an | EmptyData - exception if the given string is empty |
a | NumberFormatException - exception when the string does not contain an integer |
Definition at line 316 of file StringUtils.cpp.
Referenced by NIImporter_Vissim::NIVissimXMLHandler_Fahrzeugklassendefinition::myEndElement(), and RGBColor::parseColor().
|
static |
Transfers from Latin 1 (ISO-8859-1) to UTF-8.
Definition at line 69 of file StringUtils.cpp.
Referenced by PCLoaderArcView::load().
|
static |
Removes trailing and leading whitechars.
Definition at line 47 of file StringUtils.cpp.
Referenced by ODMatrix::getNextNonCommentLine(), NIImporter_OpenStreetMap::EdgesHandler::interpretSpeed(), PCLoaderArcView::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), main(), NIImporter_ITSUMO::Handler::myCharacters(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), GUIDialog_Breakpoints::onCmdEditTable(), GNETLSEditorFrame::onCmdPhaseEdit(), ODMatrix::readO(), ODMatrix::readV(), and Option_StringVector::set().
|
static |
Replaces all occurences of the second string by the third string within the first string
Definition at line 104 of file StringUtils.cpp.
Referenced by convertUmlaute(), escapeXML(), NIImporter_ArcView::load(), and GNEFrameAttributesModuls::AttributesEditorRow::stripWhitespaceAfterComma().
|
static |
Checks whether a given string starts with the prefix.
Definition at line 173 of file StringUtils.cpp.
Referenced by NBNodeCont::addCluster2Join(), NBNodeCont::customTLID(), MSDevice_Routing::getParameter(), LIBSUMO_NAMESPACE::Simulation::getParameter(), MSBaseVehicle::getPrefixedParameter(), NWWriter_DlrNavteq::getRoadClass(), MSDevice_Taxi::hasFuturePickup(), MSActuatedTrafficLightLogic::init(), MSDevice_FCD::initEdgeFilter(), NIImporter_OpenStreetMap::interpretDistance(), NBHelpers::loadEdgesFromFile(), NBHelpers::loadPrefixedIDsFomFile(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NBNodeCont::remapIDs(), NBEdgeCont::remapIDs(), MSDevice_Routing::setParameter(), and MSActuatedTrafficLightLogic::setParameter().
|
static |
Replaces an environment variable with its value (similar to bash); syntax for a variable is ${NAME}
Definition at line 121 of file StringUtils.cpp.
Referenced by OptionsLoader::startElement().
|
static |
Transfers the content to lower case.
Definition at line 58 of file StringUtils.cpp.
Referenced by NamedColumnsParser::get(), NIImporter_OpenStreetMap::EdgesHandler::interpretSpeed(), NamedColumnsParser::know(), NIImporter_Vissim::VissimSingleTypeParser::myRead(), OptionsCont::printHelp(), NIImporter_Vissim::readContents(), NIImporter_Vissim::VissimSingleTypeParser::readEndSecure(), NIImporter_DlrNavteq::readVersion(), and NamedColumnsParser::reinitMap().
|
static |
converts a string into the bool value described by it by calling the char-type converter
EmptyData | - exception if the given string is empty or 0 pointer |
BoolFormatException | in any other case |
Definition at line 369 of file StringUtils.cpp.
Referenced by NBRailwayTopologyAnalyzer::addBidiEdgesForBufferStops(), MSDevice::equippedByDefaultAssignmentOptions(), SUMOSAXAttributesImpl_Cached::getBool(), SUMOSAXAttributesImpl_Xerces::getBool(), MSDevice::getBoolParam(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), GUILane::getColorValue(), GUIVehicle::getColorValue(), GNELane::getColorValue(), NIImporter_VISUM::getWeightedBool(), MSSOTLTrafficLightLogic::isDecayThresholdActivated(), MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic(), MSDelayBasedTrafficLightLogic::MSDelayBasedTrafficLightLogic(), GUISettingsHandler::myStartElement(), GUIDialog_ViewSettings::onCmdEditTable(), NIImporter_VISUM::parse_Edges(), NIImporter_VISUM::parse_TrafficLights(), GUISettingsHandler::parseSizeSettings(), SUMOVehicleParameter::parseStopTriggers(), GUISettingsHandler::parseTextSettings(), MSDevice_SSM::requestsTrajectories(), Option_Bool::set(), Option_BoolExtended::set(), MSActuatedTrafficLightLogic::setParameter(), MSDevice_ToC::setParameter(), and MSDevice_SSM::useGeoCoords().
|
static |
converts a string into the double value described by it by calling the char-type converter
an | EmptyData - exception if the given string is empty |
a | NumberFormatException - exception when the string does not contain a double |
Definition at line 340 of file StringUtils.cpp.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(), NIXMLPTHandler::addPTLine(), NBEdgeCont::applyOptions(), MSDevice_Battery::buildVehicleDevices(), MSDevice_ElecHybrid::buildVehicleDevices(), MSDevice_Example::buildVehicleDevices(), ROEdge::cacheParamRestrictions(), SUMOVTypeParameter::cacheParamRestrictions(), MSFrame::checkOptions(), LIBSUMO_NAMESPACE::Simulation::findIntermodalRoute(), MSSwarmTrafficLightLogic::getBetaNo(), MSSwarmTrafficLightLogic::getBetaSp(), SUMOSAXAttributesImpl_Cached::getBoundary(), SUMOSAXAttributesImpl_Xerces::getBoundary(), SUMOVTypeParameter::getCFParam(), MSSwarmTrafficLightLogic::getChangePlanProbability(), GUILane::getColorValue(), GUIVehicle::getColorValue(), GNELane::getColorValue(), MFXAddEditTypedTable::getControlForItem(), MSSOTLTrafficLightLogic::getDecayConstant(), MSDevice_SSM::getDetectionRange(), NGNet::getDistribution(), Parameterised::getDouble(), MSDevice_SSM::getExtraTime(), SUMOSAXAttributesImpl_Cached::getFloat(), SUMOSAXAttributesImpl_Xerces::getFloat(), MSDevice::getFloatParam(), MSSwarmTrafficLightLogic::getForgettingCox(), MSSwarmTrafficLightLogic::getGammaNo(), MSSwarmTrafficLightLogic::getGammaSp(), MSSOTLTrafficLightLogic::getInputSensorsLength(), SUMOVTypeParameter::getJMParam(), SUMOVTypeParameter::getLCParam(), MSSwarmTrafficLightLogic::getLearningCox(), MSDevice_SSM::getMeasuresAndThresholds(), NIImporter_VISUM::getNamedFloat(), MSSOTLTrafficLightLogic::getOutputSensorsLength(), MSSwarmTrafficLightLogic::getPheroMaxVal(), SUMOSAXAttributesImpl_Cached::getShape(), SUMOSAXAttributesImpl_Xerces::getShape(), MSSOTLTrafficLightLogic::getSpeedThreshold(), MSSwarmTrafficLightLogic::getThetaInit(), MSSwarmTrafficLightLogic::getThetaMax(), MSSwarmTrafficLightLogic::getThetaMin(), getTurningDefaults(), MSTriggeredRerouter::getWeight(), NIImporter_VISUM::getWeightedFloat(), MSSwarmTrafficLightLogic::init(), PushButtonLogic::init(), SigmoidLogic::init(), MSVehicleType::initRailVisualizationParameters(), GNEVehicleType::initRailVisualizationParameters(), NIImporter_OpenStreetMap::interpretDistance(), NIImporter_OpenStreetMap::EdgesHandler::interpretSpeed(), Parameterised::isParameterValid(), LandmarkLookupTable< E, V >::LandmarkLookupTable(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPolyFile(), main(), MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic(), MSDelayBasedTrafficLightLogic::MSDelayBasedTrafficLightLogic(), MSSOTLPolicy::MSSOTLPolicy(), NIImporter_ITSUMO::Handler::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Streckendefinition::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition::myEndElement(), GUISettingsHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), GUIDialog_ViewSettings::onCmdEditTable(), Parameterised::Parameterised(), Distribution_Parameterized::parse(), NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::parse(), NIVissimSingleTypeParser_Laengenverteilungsdefinition::parse(), NIVissimSingleTypeParser_Simdauer::parse(), NIVissimSingleTypeParser_Streckendefinition::parse(), NIVissimSingleTypeParser_Verbindungsdefinition::parse(), NIVissimSingleTypeParser_Zeitenverteilungsdefinition::parse(), NIImporter_VISUM::parse_Edges(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_Point(), SUMOVehicleParserHelper::parseAngleTimesMap(), SUMOVehicleParameter::parseArrivalPos(), SUMOVehicleParameter::parseArrivalPosLat(), SUMOVehicleParameter::parseArrivalSpeed(), GeomConvHelper::parseBoundaryReporting(), RGBColor::parseColor(), SUMOVehicleParameter::parseDepartPos(), SUMOVehicleParameter::parseDepartPosLat(), SUMOVehicleParameter::parseDepartSpeed(), VehicleEngineHandler::parseDoubleAttribute(), SUMOVehicleParserHelper::parseJMParams(), SUMOVehicleParserHelper::parseLCParams(), GenericEngineModel::parseParameter(), GeomConvHelper::parseShapeReporting(), GUISettingsHandler::parseSizeSettings(), GUISettingsHandler::parseTextSettings(), ODMatrix::parseTimeLine(), SUMOVehicleParserHelper::parseVTypeEmbedded(), RODFDetFlowLoader::read(), ODMatrix::readFactor(), ODMatrix::readO(), ODMatrix::readV(), NIImporter_DlrNavteq::readVersion(), NIImporter_DlrNavteq::EdgesHandler::report(), Option_Float::set(), MSFrame::setMSGlobals(), MSDevice_Battery::setParameter(), MSDevice_Bluelight::setParameter(), MSDevice_DriverState::setParameter(), MSDevice_ElecHybrid::setParameter(), MSDevice_Example::setParameter(), MSDevice_Routing::setParameter(), MSDevice_SSM::setParameter(), MSDevice_Taxi::setParameter(), MSTransportableDevice_Routing::setParameter(), MSLCM_LC2013::setParameter(), MSLCM_SL2015::setParameter(), MSActuatedTrafficLightLogic::setParameter(), Parameterised::setParameter(), MSDevice_ToC::setParameter(), MSCFModel_CC::setParameter(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(), string2time(), toDoubleSecure(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::WAUTSwitchProcedure_Stretch(), and RODFDetector::writeEmitterDefinition().
|
static |
converts a string into the integer value described by it
Definition at line 360 of file StringUtils.cpp.
References toDouble().
Referenced by MSRouteHandler::openRouteDistribution().
|
static |
converts a string into the integer value described by it by calling the char-type converter, which
an | EmptyData - exception if the given string is empty |
NumberFormatException | - exception when the string does not contain an integer |
Definition at line 273 of file StringUtils.cpp.
References toLong(), and toString().
Referenced by NIXMLEdgesHandler::addSplit(), FareModul::addStop(), MFXAddEditTypedTable::getControlForItem(), OutputDevice::getDevice(), SUMOSAXAttributesImpl_Cached::getInt(), SUMOSAXAttributesImpl_Xerces::getInt(), SUMOSAXAttributes::getIntVector(), NBEdge::getLaneIndexFromLaneID(), NINavTeqHelper::getLaneNumber(), MSSwarmTrafficLightLogic::getMaxCongestionDuration(), MSSOTLRequestPolicy::getMinDecisionalPhaseDuration(), MSSOTLTrafficLightLogic::getMode(), MSSwarmTrafficLightLogic::getReinforcementMode(), NINavTeqHelper::getSpeed(), MSSOTLTrafficLightLogic::getThreshold(), MSActuatedTrafficLightLogic::init(), MSSwarmTrafficLightLogic::init(), NBHelpers::interpretLaneID(), PCLoaderVisum::load(), NIImporter_ITSUMO::Handler::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Streckendefinition::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Fahrzeugklassendefinition::myEndElement(), MSStateHandler::myStartElement(), NIImporter_MATSim::EdgesHandler::myStartElement(), GUISettingsHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), GNEAttributeCarrier::parse(), NIVissimSingleTypeParser_Fahrzeugklassendefinition::parse(), NIVissimSingleTypeParser_Fahrzeugtypdefinition::parse(), NIVissimSingleTypeParser_Kantensperrung::parse(), NIVissimSingleTypeParser_Knotendefinition::parse(), NIVissimSingleTypeParser_Streckendefinition::parse(), NIVissimSingleTypeParser_Verbindungsdefinition::parse(), NIVissimSingleTypeParser_VWunschentscheidungsdefinition::parse(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Edges(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_LanesConnections(), NIImporter_VISUM::parse_Types(), SUMOVehicleParserHelper::parseAngleTimesMap(), SUMOVehicleParameter::parseArrivalLane(), NIImporter_Vissim::VissimSingleTypeParser::parseAssignedVehicleTypes(), RGBColor::parseColor(), SUMOVehicleParameter::parseDepartEdge(), SUMOVehicleParameter::parseDepartLane(), VehicleEngineHandler::parseIntAttribute(), GenericEngineModel::parseParameter(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos(), ODMatrix::parseSingleTime(), SUMOVehicleParserHelper::parseVTypeEmbedded(), NIImporter_DlrNavteq::readDate(), NIImporter_Vissim::VissimSingleTypeParser::readExtEdgePointDef(), ODMatrix::readO(), ODMatrix::readV(), NIImporter_DlrNavteq::EdgesHandler::report(), NIImporter_DlrNavteq::ConnectedLanesHandler::report(), Option_Integer::set(), Option_IntVector::set(), MSCFModel_CC::setParameter(), NIVissimConflictArea::setPriorityRegulation(), MSSOTLE2Sensors::setVehicleWeigths(), GUIMainWindow::setWindowSizeAndPos(), toIntSecure(), and RODFDetector::writeEmitterDefinition().
|
static |
converts a string into the integer value described by it
Definition at line 283 of file StringUtils.cpp.
References toInt().
Referenced by RODFDetectorHandler::myStartElement(), and NIXMLConnectionsHandler::parseDeprecatedLaneDefinition().
|
static |
converts a string into the long value described by it by calling the char-type converter, which
an | EmptyData - exception if the given string is empty |
NumberFormatException | - exception when the string does not contain a long integer |
Definition at line 292 of file StringUtils.cpp.
Referenced by SUMOSAXAttributesImpl_Cached::getLong(), SUMOSAXAttributesImpl_Xerces::getLong(), PCLoaderVisum::load(), MSStateHandler::myStartElement(), NIImporter_VISUM::parse_AreaSubPartElement(), NIImporter_VISUM::parse_Districts(), NIImporter_VISUM::parse_Kante(), NIImporter_VISUM::parse_PartOfArea(), NIImporter_VISUM::parse_Point(), NBNodeCont::remapIDs(), NBEdgeCont::remapIDs(), and toInt().
|
static |
Builds a time string (hh:mm:ss) from the given seconds.
Definition at line 153 of file StringUtils.cpp.
|
inlinestatic |
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
an | EmptyData - exception if the given pointer is 0 |
Definition at line 133 of file StringUtils.h.
Referenced by OptionsLoader::characters(), GenericSAXHandler::characters(), SUMOSAXAttributesImpl_Xerces::clone(), GenericSAXHandler::endElement(), OptionsLoader::error(), OptionsLoader::fatalError(), SUMOSAXAttributesImpl_Xerces::getAttributeNames(), SUMOSAXAttributesImpl_Xerces::getFloat(), OptionsIO::getRoot(), SUMOSAXAttributesImpl_Xerces::getString(), SUMOSAXAttributesImpl_Xerces::getStringSecure(), XMLSubSys::init(), NITypeLoader::load(), OptionsIO::loadConfiguration(), main(), SUMOSAXReader::LocalSchemaResolver::resolveEntity(), SUMOSAXAttributesImpl_Xerces::serialize(), OptionsLoader::startElement(), GenericSAXHandler::startElement(), and OptionsLoader::warning().
|
static |
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8 considering the given length
EmptyData | if the given pointer is 0 |
Definition at line 389 of file StringUtils.cpp.
References transcode().
|
static |
remove leading and trailing whitespace
Definition at line 427 of file StringUtils.cpp.
References trim_left(), and trim_right().
Referenced by GUIDialog_ViewSettings::onCmdEditTable().
|
static |
remove leading whitespace from string
Definition at line 413 of file StringUtils.cpp.
Referenced by trim().
|
static |
remove trailing whitespace from string
Definition at line 420 of file StringUtils.cpp.
Referenced by trim().
|
static |
Definition at line 230 of file StringUtils.cpp.
References hexToChar().
Referenced by MSDevice_SSM::getOutputFilename(), and OptionsCont::relocateFiles().
|
static |
Definition at line 205 of file StringUtils.cpp.
References charToHex().
Referenced by Option_FileName::getValueString().
|
static |
An empty string.
Definition at line 80 of file StringUtils.h.
Referenced by MSPerson::getNextEdge(), and GUIGlObject::getParentName().