![]() |
SUMO - Simulation of Urban MObility
|
Functions for an easier usage of files and paths. More...
#include <FileHelpers.h>
Static Public Member Functions | |
file access functions | |
static bool | isReadable (std::string path) |
Checks whether the given file is readable. More... | |
file path evaluating functions | |
static std::string | getFilePath (const std::string &path) |
Removes the file information from the given path. More... | |
static std::string | getConfigurationRelative (const std::string &configPath, const std::string &path) |
Returns the second path as a relative path to the first file. More... | |
static bool | isSocket (const std::string &name) |
Returns the information whether the given name represents a socket. More... | |
static bool | isAbsolute (const std::string &path) |
Returns the information whether the given path is absolute. More... | |
static std::string | checkForRelativity (const std::string &filename, const std::string &basePath) |
Returns the path from a configuration so that it is accessable from the current working directory. More... | |
static std::string | prependToLastPathComponent (const std::string &prefix, const std::string &path) |
prepend the given prefix to the last path component of the given file path More... | |
binary writing functions | |
static std::ostream & | writeInt (std::ostream &strm, int value) |
Writes an integer binary. More... | |
static std::ostream & | writeFloat (std::ostream &strm, double value) |
Writes a float binary. More... | |
static std::ostream & | writeByte (std::ostream &strm, unsigned char value) |
Writes a byte binary. More... | |
static std::ostream & | writeString (std::ostream &strm, const std::string &value) |
Writes a string binary. More... | |
static std::ostream & | writeTime (std::ostream &strm, SUMOTime value) |
Writes a time description binary. More... | |
template<typename E > | |
static std::ostream & | writeEdgeVector (std::ostream &os, const std::vector< E > &edges) |
Writes an edge vector binary. More... | |
template<typename E > | |
static void | readEdgeVector (std::istream &in, std::vector< const E *> &edges, const std::string &rid) |
Reads an edge vector binary. More... | |
Functions for an easier usage of files and paths.
Definition at line 48 of file FileHelpers.h.
|
static |
Returns the path from a configuration so that it is accessable from the current working directory.
If the path is absolute, it is returned. Otherwise, the file's position is computed regarding the configuration path (see getConfigurationRelative).
[in] | filename | The path to the file to be examined |
[in] | basePath | The path the configuration file (including the config's file name) |
Definition at line 119 of file FileHelpers.cpp.
References getConfigurationRelative(), isAbsolute(), and isSocket().
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::beginE3Detector(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic(), and MSDelayBasedTrafficLightLogic::MSDelayBasedTrafficLightLogic().
|
static |
Returns the second path as a relative path to the first file.
Given the position of the configuration file, and the information where a second file is relative to the configuration file's position, we want to known where this second file can be found. This method gets the path to the configuration file (including the configuration file name) and the path to get the relative position of and returns this relative position.
[in] | configPath | The path the configuration file (including the config's file name) |
[in] | path | The path to the references file (relativ to configuration path) |
Definition at line 81 of file FileHelpers.cpp.
References getFilePath().
Referenced by ShapeHandler::addPOI(), ShapeHandler::addPoly(), SUMOVehicleParserHelper::beginVTypeParsing(), checkForRelativity(), NWFrame::checkOptions(), NLTriggerBuilder::getFileName(), GNEAdditionalHandler::getFileName(), main(), GUISettingsHandler::myStartElement(), OptionsCont::relocateFiles(), and GenericSAXHandler::startElement().
|
static |
Removes the file information from the given path.
[in] | path | The path to the file to return the folder it is located in |
Definition at line 71 of file FileHelpers.cpp.
Referenced by TraCIServer::cleanup(), getConfigurationRelative(), RODFDetectorCon::writeEmitters(), and RODFDetectorCon::writeSpeedTrigger().
|
static |
Returns the information whether the given path is absolute.
A path is meant to be absolute, if
[in] | path | The path to examine |
Definition at line 96 of file FileHelpers.cpp.
References isSocket().
Referenced by ShapeHandler::addPOI(), ShapeHandler::addPoly(), SUMOVehicleParserHelper::beginVTypeParsing(), checkForRelativity(), NLTriggerBuilder::getFileName(), GNEAdditionalHandler::getFileName(), GUISettingsHandler::myStartElement(), OptionsCont::relocateFiles(), and GenericSAXHandler::startElement().
|
static |
Checks whether the given file is readable.
[in] | path | The path to the file that shall be examined |
Definition at line 53 of file FileHelpers.cpp.
Referenced by NIImporter_SUMO::_loadNetwork(), NLBuilder::buildRouteLoaderControl(), OptionsCont::isUsableFileList(), PCNetProjectionLoader::load(), NIImporter_OpenStreetMap::load(), OptionsIO::loadConfiguration(), ODDistrictCont::loadDistricts(), PCLoaderVisum::loadIfSet(), PCLoaderOSM::loadIfSet(), PCLoaderXML::loadIfSet(), ODMatrix::loadMatrix(), loadNet(), ROLoader::loadNet(), NIImporter_RobocupRescue::loadNetwork(), NIImporter_ArcView::loadNetwork(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), PCLoaderDlrNavteq::loadPOIFiles(), PCLoaderDlrNavteq::loadPolyFiles(), ODMatrix::loadRoutes(), NIImporter_Vissim::loadXML(), NILoader::loadXMLType(), GUIApplicationWindow::onCmdNetedit(), readDetectorFlows(), readDetectors(), and SUMOSAXReader::LocalSchemaResolver::resolveEntity().
|
static |
Returns the information whether the given name represents a socket.
A file name is meant to describe a socket address if a colon is found at a position larger than one.
[in] | name | The name of a file |
Definition at line 89 of file FileHelpers.cpp.
Referenced by checkForRelativity(), OutputDevice::getDevice(), and isAbsolute().
|
static |
prepend the given prefix to the last path component of the given file path
Definition at line 138 of file FileHelpers.cpp.
Referenced by OutputDevice::getDevice().
|
static |
Reads an edge vector binary.
[in] | is | The stream to read from |
[out] | edges | The edge vector to write into |
Definition at line 273 of file FileHelpers.h.
Referenced by RORouteHandler::parseEdges(), and MSEdge::parseEdgesList().
|
static |
Writes a byte binary.
[in,out] | strm | The stream to write into |
[in] | value | The byte to write |
Definition at line 165 of file FileHelpers.cpp.
Referenced by BinaryFormatter::closeTag(), BinaryFormatter::openTag(), SUMOSAXAttributesImpl_Binary::SUMOSAXAttributesImpl_Binary(), BinaryFormatter::writeAttr(), BinaryFormatter::writeAttrHeader(), BinaryFormatter::writeHeader(), BinaryFormatter::writePosition(), BinaryFormatter::writeStaticHeader(), and BinaryFormatter::writeStringList().
|
static |
Writes an edge vector binary.
[in,out] | os | The stream to write into |
[in] | edges | The edges to write |
Definition at line 217 of file FileHelpers.h.
References writeInt().
Referenced by BinaryFormatter::writeAttr().
|
static |
Writes a float binary.
This method behaves differently depending on the definition of double at compile time.
[in,out] | strm | The stream to write into |
[in] | value | The float to write |
Definition at line 158 of file FileHelpers.cpp.
Referenced by computeAllPairs(), BinaryFormatter::writeAttr(), and BinaryFormatter::writePosition().
|
static |
Writes an integer binary.
[in,out] | strm | The stream to write into |
[in] | value | The integer to write |
Definition at line 151 of file FileHelpers.cpp.
Referenced by SUMOSAXAttributesImpl_Binary::SUMOSAXAttributesImpl_Binary(), BinaryFormatter::writeAttr(), writeEdgeVector(), BinaryFormatter::writeHeader(), BinaryFormatter::writePosition(), writeString(), and BinaryFormatter::writeStringList().
|
static |
Writes a string binary.
Writes the length of the string, first, using writeInt. Writes then the string's characters.
[in,out] | strm | The stream to write into |
[in] | value | The string to write |
Definition at line 172 of file FileHelpers.cpp.
References writeInt().
Referenced by BinaryFormatter::writeAttr(), BinaryFormatter::writeHeader(), BinaryFormatter::writePreformattedTag(), BinaryFormatter::writeStaticHeader(), and BinaryFormatter::writeStringList().
|
static |
Writes a time description binary.
This method behaves differently depending on the definition of SUMOTime at compile time, which in turn depends on the enabling of subsecond timesteps.
[in,out] | strm | The stream to write into |
[in] | value | The time to write |
Definition at line 182 of file FileHelpers.cpp.