Eclipse SUMO - Simulation of Urban MObility
StringUtils Class Reference

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...
 
template<typename T , typename... Targs>
static const std::string format (const std::string &format, T value, Targs... Fargs)
 adds a new formatted message 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 padFront (const std::string &str, int length, char padding)
 
static std::string prune (const std::string &str)
 Removes trailing and leading whitechars. More...
 
static std::string pruneZeros (const std::string &str, int max)
 Removes trailing zeros (at most 'max') More...
 
static std::string replace (std::string str, const std::string &what, const std::string &by)
 
static void resetTranscoder ()
 must be called when shutting down the xml subsystem More...
 
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 (const std::string &str, const std::chrono::time_point< std::chrono::system_clock > *const timeRef=nullptr)
 
static std::string to_lower_case (const 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 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 transcodeFromLocal (const std::string &localString)
 convert a string from the local codepage to UTF-8 More...
 
static std::string transcodeToLocal (const std::string &utf8String)
 convert a string from UTF-8 to the local codepage 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...
 

Static Private Member Functions

static void _format (const char *format, std::ostringstream &os)
 
template<typename T , typename... Targs>
static void _format (const char *format, std::ostringstream &os, T value, Targs... Fargs)
 adds a new formatted message More...
 

Static Private Attributes

static XERCES_CPP_NAMESPACE::XMLLCPTranscoder * myLCPTranscoder = nullptr
 

Detailed Description

Some static methods for string processing.

Definition at line 41 of file StringUtils.h.

Member Function Documentation

◆ _format() [1/2]

static void StringUtils::_format ( const char *  format,
std::ostringstream &  os 
)
inlinestaticprivate

Definition at line 178 of file StringUtils.h.

References format().

Referenced by _format(), and format().

Here is the caller graph for this function:

◆ _format() [2/2]

template<typename T , typename... Targs>
static void StringUtils::_format ( const char *  format,
std::ostringstream &  os,
value,
Targs...  Fargs 
)
inlinestaticprivate

adds a new formatted message

Definition at line 185 of file StringUtils.h.

References _format(), and format().

◆ charToHex()

std::string StringUtils::charToHex ( unsigned char  c)
static

Definition at line 289 of file StringUtils.cpp.

Referenced by urlEncode().

Here is the caller graph for this function:

◆ convertUmlaute()

std::string StringUtils::convertUmlaute ( std::string  str)
static

Converts german "Umlaute" to their latin-version.

Definition at line 103 of file StringUtils.cpp.

References replace().

Referenced by PCLoaderDlrNavteq::loadPolyFile(), NIImporter_Vissim::VissimSingleTypeParser::readName(), and NBEdge::reinit().

Here is the caller graph for this function:

◆ endsWith()

bool StringUtils::endsWith ( const std::string &  str,
const std::string  suffix 
)
static

Checks whether a given string ends with the suffix.

Definition at line 215 of file StringUtils.cpp.

Referenced by NIImporter_VISUM::getNamedFloat(), MSBaseVehicle::getPrefixedParameter(), LandmarkLookupTable< E, V >::LandmarkLookupTable(), NIImporter_Vissim::load(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), GNEApplicationWindow::onCmdSaveAsPlainXML(), and MSBaseVehicle::replaceRouteEdges().

Here is the caller graph for this function:

◆ escapeXML()

std::string StringUtils::escapeXML ( const std::string &  orig,
const bool  maskDoubleHyphen = false 
)
static

Replaces the standard escapes by their XML entities.

The strings &, <, >, ", and ' are replaced by &, <, >, ", and '

Parameters
[in]origThe original string
[in]maskDoubleHyphenWhether – in input shall be converted to &#45;&#45; (semantically equivalent but allowed in XML comments)
Returns
the string with the escaped sequences

Definition at line 231 of file StringUtils.cpp.

References replace().

Referenced by NBPTStop::addLine(), PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), NIImporter_OpenStreetMap::insertEdge(), MSPerson::MSPersonStage_Walking::routeOutput(), MSStageDriving::routeOutput(), MSStageTranship::routeOutput(), MSStageWaiting::routeOutput(), RODFDetectorCon::save(), RODFDetectorCon::saveAsPOIs(), NBPTLine::write(), NBPTStop::write(), MSFCDExport::write(), GNEBusStop::writeAdditional(), GNEChargingStation::writeAdditional(), GNEContainerStop::writeAdditional(), GNEInductionLoopDetector::writeAdditional(), GNEInstantInductionLoopDetector::writeAdditional(), GNELaneAreaDetector::writeAdditional(), GNEMultiEntryExitDetector::writeAdditional(), GNEParkingArea::writeAdditional(), GNEParkingSpace::writeAdditional(), GNERerouter::writeAdditional(), GNEVaporizer::writeAdditional(), GNEVariableSpeedSign::writeAdditional(), OptionsCont::writeConfiguration(), NWWriter_SUMO::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_SUMO::writeJunction(), NWWriter_XML::writeNodes(), NWWriter_OpenDrive::writeNormalEdge(), Parameterised::writeParams(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_SUMO::writeTrafficLight(), RODFDetectorCon::writeValidationDetectors(), SUMOPolygon::writeXML(), PointOfInterest::writeXML(), MEInductLoop::writeXMLOutput(), and MSInductLoop::writeXMLOutput().

Here is the caller graph for this function:

◆ format()

template<typename T , typename... Targs>
static const std::string StringUtils::format ( const std::string &  format,
value,
Targs...  Fargs 
)
inlinestatic

adds a new formatted message

Definition at line 170 of file StringUtils.h.

References _format(), format(), and gPrecision.

Referenced by _format(), format(), and MsgHandler::informf().

Here is the caller graph for this function:

◆ hexToChar()

unsigned char StringUtils::hexToChar ( const std::string &  str)
static

Definition at line 301 of file StringUtils.cpp.

Referenced by urlDecode().

Here is the caller graph for this function:

◆ hexToInt()

int StringUtils::hexToInt ( const std::string &  sData)
static

converts a string with a hex value into the integer value described by it by calling the char-type converter

Exceptions
anEmptyData - exception if the given string is empty
aNumberFormatException - exception when the string does not contain an integer

Definition at line 358 of file StringUtils.cpp.

Referenced by NIImporter_Vissim::NIVissimXMLHandler_Fahrzeugklassendefinition::myEndElement(), and RGBColor::parseColor().

Here is the caller graph for this function:

◆ latin1_to_utf8()

std::string StringUtils::latin1_to_utf8 ( std::string  str)
static

Transfers from Latin 1 (ISO-8859-1) to UTF-8.

Definition at line 86 of file StringUtils.cpp.

Referenced by PCLoaderArcView::load(), NIImporter_VISUM::parse_Edges(), and NIImporter_VISUM::parse_stopPoints().

Here is the caller graph for this function:

◆ padFront()

std::string StringUtils::padFront ( const std::string &  str,
int  length,
char  padding 
)
static

Definition at line 225 of file StringUtils.cpp.

References MAX2().

Referenced by GUITLLogicPhasesTrackerWindow::drawValues().

Here is the caller graph for this function:

◆ prune()

◆ pruneZeros()

std::string StringUtils::pruneZeros ( const std::string &  str,
int  max 
)
static

Removes trailing zeros (at most 'max')

Definition at line 66 of file StringUtils.cpp.

References MAX2().

Referenced by SUMOVehicleParameter::getDepartPos(), SUMOVehicleParameter::getDepartPosLat(), and SUMOVehicleParameter::getDepartSpeed().

Here is the caller graph for this function:

◆ replace()

std::string StringUtils::replace ( std::string  str,
const std::string &  what,
const std::string &  by 
)
static

Replaces all occurences of the second string by the third string within the first string

Definition at line 120 of file StringUtils.cpp.

Referenced by convertUmlaute(), escapeXML(), PHEMlightdllV5::Correction::GetMileage(), PHEMlightdllV5::Correction::IniDETfactor(), PHEMlightdllV5::Correction::IniTNOxfactor(), NIImporter_ArcView::load(), GUIGLObjectPopupMenu::onCmdShowCursorGeoPositionOnline(), GNEFrameAttributeModules::AttributesEditorRow::stripWhitespaceAfterComma(), and substituteEnvironment().

Here is the caller graph for this function:

◆ resetTranscoder()

void StringUtils::resetTranscoder ( )
static

must be called when shutting down the xml subsystem

Definition at line 503 of file StringUtils.cpp.

References myLCPTranscoder.

Referenced by XMLSubSys::close().

Here is the caller graph for this function:

◆ startsWith()

◆ substituteEnvironment()

std::string StringUtils::substituteEnvironment ( const std::string &  str,
const std::chrono::time_point< std::chrono::system_clock > *const  timeRef = nullptr 
)
static

Replaces an environment variable with its value (similar to bash); syntax for a variable is ${NAME}

Definition at line 135 of file StringUtils.cpp.

References replace(), and toString().

Referenced by OutputDevice::getDevice(), GUISettingsHandler::myStartElement(), GUIDialog_ViewSettings::onCmdEditTable(), and OptionsCont::set().

Here is the caller graph for this function:

◆ to_lower_case()

◆ toBool()

bool StringUtils::toBool ( const std::string &  sData)
static

converts a string into the bool value described by it by calling the char-type converter

Returns
true if the data* is one of the following (case insensitive): '1', 'x', 'true', 'yes', 'on', 't'
false if the data* is one of the following (case insensitive): '0', '-', 'false', 'no', 'off', 'f'
Exceptions
EmptyData- exception if the given string is empty or 0 pointer
BoolFormatExceptionin any other case

Definition at line 411 of file StringUtils.cpp.

References to_lower_case().

Referenced by NBRailwayTopologyAnalyzer::addBidiEdgesForBufferStops(), MSDevice::equippedByDefaultAssignmentOptions(), SUMOSAXAttributes::getBool(), MSDevice::getBoolParam(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), GUIVehicle::getColorValue(), GNELane::getColorValue(), GUIEdge::getColorValue(), GUILane::getColorValue(), GUIBaseVehicle::getScaleValue(), NIImporter_VISUM::getWeightedBool(), NEMALogic::init(), MSSOTLTrafficLightLogic::isDecayThresholdActivated(), MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic(), MSDelayBasedTrafficLightLogic::MSDelayBasedTrafficLightLogic(), MSSimpleTrafficLightLogic::MSSimpleTrafficLightLogic(), GUISettingsHandler::myStartElement(), NIImporter_OpenStreetMap::EdgesHandler::myStartElement(), NEMALogic::NEMALogic(), GUIDialog_ViewSettings::onCmdEditTable(), NIImporter_VISUM::parse_Edges(), NIImporter_VISUM::parse_TrafficLights(), SUMOVehicleParameter::parseParkingType(), GUISettingsHandler::parseSizeSettings(), SUMOVehicleParameter::parseStopTriggers(), GUISettingsHandler::parseTextSettings(), MSDevice_SSM::requestsTrajectories(), Option_Bool::set(), Option_BoolExtended::set(), MSDevice_ToC::setParameter(), MSActuatedTrafficLightLogic::setParameter(), MSRailSignal::setParameter(), MSSimpleTrafficLightLogic::setParameter(), MSDevice_SSM::useGeoCoords(), MSDevice_SSM::writeLanesPositions(), and MSDevice_SSM::writePositions().

Here is the caller graph for this function:

◆ toDouble()

double StringUtils::toDouble ( const std::string &  sData)
static

converts a string into the double value described by it by calling the char-type converter

Exceptions
anEmptyData - exception if the given string is empty
aNumberFormatException - exception when the string does not contain a double

Definition at line 382 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(), MSDevice::equippedByDefaultAssignmentOptions(), MSActuatedTrafficLightLogic::evalAtomicExpression(), LIBSUMO_NAMESPACE::Simulation::findIntermodalRoute(), MSSwarmTrafficLightLogic::getBetaNo(), MSSwarmTrafficLightLogic::getBetaSp(), SUMOVTypeParameter::getCFParam(), MSSwarmTrafficLightLogic::getChangePlanProbability(), GUIVehicle::getColorValue(), GNEEdgeData::getColorValue(), GNEEdgeRelData::getColorValue(), GNETAZRelData::getColorValue(), GNELane::getColorValue(), GUIEdge::getColorValue(), GUILane::getColorValue(), MFXAddEditTypedTable::getControlForItem(), MSSOTLTrafficLightLogic::getDecayConstant(), MSDevice_SSM::getDetectionRange(), NGNet::getDistribution(), Parameterised::getDouble(), Parameterised::getDoubles(), MSDevice_SSM::getExtraTime(), SUMOSAXAttributesImpl_Cached::getFloat(), SUMOSAXAttributesImpl_Xerces::getFloat(), SUMOSAXAttributes::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(), GUIBaseVehicle::getScaleValue(), MSSOTLTrafficLightLogic::getSpeedThreshold(), MSSwarmTrafficLightLogic::getThetaInit(), MSSwarmTrafficLightLogic::getThetaMax(), MSSwarmTrafficLightLogic::getThetaMin(), getTurningDefaults(), MSTriggeredRerouter::getWeight(), NIImporter_VISUM::getWeightedFloat(), MSRailCrossing::init(), MSSwarmTrafficLightLogic::init(), MSActuatedTrafficLightLogic::init(), PushButtonLogic::init(), SigmoidLogic::init(), SUMOVTypeParameter::initRailVisualizationParameters(), NIImporter_OpenStreetMap::interpretDistance(), NIImporter_OpenStreetMap::EdgesHandler::interpretSpeed(), LandmarkLookupTable< E, V >::LandmarkLookupTable(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPolyFile(), main(), MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic(), MSDelayBasedTrafficLightLogic::MSDelayBasedTrafficLightLogic(), MSSimpleTrafficLightLogic::MSSimpleTrafficLightLogic(), MSSOTLPolicy::MSSOTLPolicy(), NIImporter_ITSUMO::Handler::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Streckendefinition::myEndElement(), NIImporter_Vissim::NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition::myEndElement(), GUISettingsHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NEMALogic::NEMALogic(), MSDevice_GLOSA::notifyEnter(), GUIDialog_ViewSettings::onCmdEditTable(), 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(), NIImporter_VISUM::parse_stopPoints(), SUMOVehicleParameter::parseArrivalPos(), SUMOVehicleParameter::parseArrivalPosLat(), SUMOVehicleParameter::parseArrivalSpeed(), GeomConvHelper::parseBoundaryReporting(), SUMOVehicleParserHelper::parseCFMParams(), RGBColor::parseColor(), SUMOVehicleParameter::parseDepartPos(), SUMOVehicleParameter::parseDepartPosLat(), SUMOVehicleParameter::parseDepartSpeed(), SUMOVehicleParserHelper::parseFlowAttributes(), SUMOVehicleParserHelper::parseJMParams(), SUMOVTypeParameter::parseLatAlignment(), SUMOVehicleParserHelper::parseLCParams(), GenericEngineModel::parseParameter(), GeomConvHelper::parseShapeReporting(), GUISettingsHandler::parseSizeSettings(), GUISettingsHandler::parseTextSettings(), ODMatrix::parseTimeLine(), 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_Friction::setParameter(), MSDevice_GLOSA::setParameter(), MSDevice_Routing::setParameter(), MSDevice_SSM::setParameter(), MSDevice_Taxi::setParameter(), MSTransportableDevice_Routing::setParameter(), MSRailCrossing::setParameter(), MSDevice_ToC::setParameter(), MSLCM_LC2013::setParameter(), MSLCM_SL2015::setParameter(), MSActuatedTrafficLightLogic::setParameter(), NEMALogic::setParameter(), MSCFModel_CC::setParameter(), LIBSUMO_NAMESPACE::Vehicle::setStopParameter(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(), string2time(), toDoubleSecure(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::WAUTSwitchProcedure_Stretch(), and RODFDetector::writeEmitterDefinition().

◆ toDoubleSecure()

double StringUtils::toDoubleSecure ( const std::string &  sData,
const double  def 
)
static

converts a string into the integer value described by it

Returns
the default value if the data is empty

Definition at line 402 of file StringUtils.cpp.

References toDouble().

Referenced by MSRouteHandler::openRouteDistribution().

Here is the caller graph for this function:

◆ toInt()

int StringUtils::toInt ( const std::string &  sData)
static

converts a string into the integer value described by it by calling the char-type converter, which

Exceptions
anEmptyData - exception if the given string is empty
NumberFormatException- exception when the string does not contain an integer

Definition at line 315 of file StringUtils.cpp.

References toLong(), and toString().

Referenced by NIXMLEdgesHandler::addSplit(), FareModul::addStop(), NBOwnTLDef::buildNemaPhases(), NEMALogic::constructTimingAndPhaseDefs(), MSActuatedTrafficLightLogic::evalAtomicExpression(), MFXAddEditTypedTable::getControlForItem(), OutputDevice::getDevice(), SUMOXMLDefinitions::getIndexFromLane(), SUMOSAXAttributes::getInt(), NBEdge::getLaneIndexFromLaneID(), NINavTeqHelper::getLaneNumber(), MSSwarmTrafficLightLogic::getMaxCongestionDuration(), MSSOTLRequestPolicy::getMinDecisionalPhaseDuration(), MSSOTLTrafficLightLogic::getMode(), MSSwarmTrafficLightLogic::getReinforcementMode(), NINavTeqHelper::getSpeed(), MSSOTLTrafficLightLogic::getThreshold(), MSSwarmTrafficLightLogic::init(), MSActuatedTrafficLightLogic::init(), NBHelpers::interpretLaneID(), PCLoaderVisum::load(), NIImporter_OpenDrive::loadNetwork(), 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(), GUIDialog_Options::InputIntVector::onCmdSetOption(), 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::parseDepartLane(), GenericEngineModel::parseParameter(), NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos(), SUMOVehicleParameter::parseRouteIndex(), ODMatrix::parseSingleTime(), 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(), LIBSUMO_NAMESPACE::Vehicle::setStopParameter(), MSSOTLE2Sensors::setVehicleWeigths(), GUIMainWindow::setWindowSizeAndPos(), toIntSecure(), and NWWriter_SUMO::writeInternalNodes().

◆ toIntSecure()

int StringUtils::toIntSecure ( const std::string &  sData,
int  def 
)
static

converts a string into the integer value described by it

Returns
the default value if the data is empty

Definition at line 325 of file StringUtils.cpp.

References toInt().

Referenced by NIXMLConnectionsHandler::parseDeprecatedLaneDefinition().

Here is the caller graph for this function:

◆ toLong()

long long int StringUtils::toLong ( const std::string &  sData)
static

converts a string into the long value described by it by calling the char-type converter, which

Exceptions
anEmptyData - exception if the given string is empty
NumberFormatException- exception when the string does not contain a long integer

Definition at line 334 of file StringUtils.cpp.

Referenced by SUMOSAXAttributes::getLong(), PCLoaderVisum::load(), MSDevice_Vehroutes::loadState(), MSStateHandler::myStartElement(), NIImporter_OpenStreetMap::NodesHandler::myStartElement(), NIImporter_VISUM::parse_AreaSubPartElement(), NIImporter_VISUM::parse_Districts(), NIImporter_VISUM::parse_Kante(), NIImporter_VISUM::parse_PartOfArea(), NIImporter_VISUM::parse_Point(), NBEdgeCont::remapIDs(), NBNodeCont::remapIDs(), and toInt().

Here is the caller graph for this function:

◆ transcode() [1/2]

static std::string StringUtils::transcode ( const XMLCh *const  data)
inlinestatic

◆ transcode() [2/2]

std::string StringUtils::transcode ( const XMLCh *const  data,
int  length 
)
static

converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8 considering the given length

Exceptions
EmptyDataif the given pointer is 0

Definition at line 427 of file StringUtils.cpp.

◆ transcodeFromLocal()

std::string StringUtils::transcodeFromLocal ( const std::string &  localString)
static

convert a string from the local codepage to UTF-8

Definition at line 451 of file StringUtils.cpp.

References myLCPTranscoder, and transcode().

Referenced by OptionsIO::setArgs().

Here is the caller graph for this function:

◆ transcodeToLocal()

std::string StringUtils::transcodeToLocal ( const std::string &  utf8String)
static

convert a string from UTF-8 to the local codepage

Definition at line 467 of file StringUtils.cpp.

References myLCPTranscoder.

Referenced by OptionsIO::getRoot(), FileHelpers::isDirectory(), FileHelpers::isReadable(), OptionsIO::loadConfiguration(), GUIApplicationWindow::onCmdSaveConfig(), OutputDevice_File::OutputDevice_File(), SUMOSAXReader::parse(), SUMOSAXReader::parseFirst(), and OptionsCont::processMetaOptions().

Here is the caller graph for this function:

◆ trim()

std::string StringUtils::trim ( const std::string  s,
const std::string &  t = " \t\n" 
)
static

remove leading and trailing whitespace

Definition at line 498 of file StringUtils.cpp.

References trim_left(), and trim_right().

Referenced by GNENet::createEdge(), and GUIDialog_ViewSettings::onCmdEditTable().

Here is the caller graph for this function:

◆ trim_left()

std::string StringUtils::trim_left ( const std::string  s,
const std::string &  t = " \t\n" 
)
static

remove leading whitespace from string

Definition at line 484 of file StringUtils.cpp.

Referenced by trim().

Here is the caller graph for this function:

◆ trim_right()

std::string StringUtils::trim_right ( const std::string  s,
const std::string &  t = " \t\n" 
)
static

remove trailing whitespace from string

Definition at line 491 of file StringUtils.cpp.

Referenced by trim().

Here is the caller graph for this function:

◆ urlDecode()

std::string StringUtils::urlDecode ( const std::string &  encoded)
static

Definition at line 272 of file StringUtils.cpp.

References hexToChar().

Referenced by MSDevice_SSM::getOutputFilename(), and OptionsCont::relocateFiles().

Here is the caller graph for this function:

◆ urlEncode()

std::string StringUtils::urlEncode ( const std::string &  url,
const std::string  encodeWhich = "" 
)
static

Definition at line 247 of file StringUtils.cpp.

References charToHex().

Referenced by OptionsCont::writeConfiguration().

Here is the caller graph for this function:

Field Documentation

◆ emptyString

std::string StringUtils::emptyString
static

An empty string.

Definition at line 87 of file StringUtils.h.

Referenced by MSPerson::getNextEdge(), and GUIGlObject::getParentName().

◆ myLCPTranscoder

XERCES_CPP_NAMESPACE::XMLLCPTranscoder * StringUtils::myLCPTranscoder = nullptr
staticprivate

Definition at line 197 of file StringUtils.h.

Referenced by resetTranscoder(), transcodeFromLocal(), and transcodeToLocal().


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