62 static std::string
getFilePath(
const std::string& path);
70 static std::string
addExtension(
const std::string& path,
const std::string& extension);
94 static bool isSocket(
const std::string& name);
106 static bool isAbsolute(
const std::string& path);
119 static std::string
checkForRelativity(
const std::string& filename,
const std::string& basePath);
135 static std::ostream&
writeInt(std::ostream& strm,
int value);
145 static std::ostream&
writeFloat(std::ostream& strm,
double value);
153 static std::ostream&
writeByte(std::ostream& strm,
unsigned char value);
165 static std::ostream&
writeString(std::ostream& strm,
const std::string& value);
184 template <
typename E>
185 static std::ostream&
writeEdgeVector(std::ostream& os,
const std::vector<E>& edges);
193 template <
typename E>
194 static void readEdgeVector(std::istream& in, std::vector<const E*>& edges,
const std::string& rid);
199 template <
typename E>
202 std::vector<int> follow;
204 E prev = edges.front();
205 for (
typename std::vector<E>::const_iterator i = edges.begin() + 1; i != edges.end(); ++i) {
207 for (; idx < prev->getNumSuccessors(); ++idx) {
211 if (prev->getSuccessors()[idx] == (*i)) {
212 follow.push_back(idx);
213 if (idx > maxFollow) {
219 if (idx > 15 || idx == prev->getNumSuccessors()) {
225 if (follow.empty()) {
226 for (
typename std::vector<E>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
230 const int bits = maxFollow > 3 ? 4 : 2;
231 const int numFields = 8 *
sizeof(int) / bits;
236 for (std::vector<int>::const_iterator i = follow.begin(); i != follow.end(); ++i) {
239 if (field == numFields) {
255 template <
typename E>
258 in.read((
char*) &size,
sizeof(
int));
261 in.read((
char*) &bitsOrEntry,
sizeof(
int));
262 if (bitsOrEntry < 0) {
263 const int bits = -bitsOrEntry;
264 const int numFields = 8 *
sizeof(int) / bits;
265 const int mask = (1 << bits) - 1;
267 in.read((
char*) &edgeID,
sizeof(
int));
268 const E* prev = E::getAllEdges()[edgeID];
270 edges.push_back(prev);
273 int field = numFields;
274 for (; size > 0; size--) {
275 if (field == numFields) {
276 in.read((
char*) &data,
sizeof(
int));
279 int followIndex = (data >> ((numFields - field - 1) * bits)) & mask;
280 if (followIndex >= prev->getNumSuccessors()) {
281 throw ProcessError(
"Invalid follower index in route '" + rid +
"'!");
283 prev = prev->getSuccessors()[followIndex];
284 edges.push_back(prev);
289 const E* edge = E::getAllEdges()[bitsOrEntry];
291 throw ProcessError(
"An edge within the route '" + rid +
"' is not known!");
293 edges.push_back(edge);
296 in.read((
char*) &bitsOrEntry,
sizeof(
int));
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
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
static bool isReadable(std::string path)
Checks whether the given file is readable.
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
static void readEdgeVector(std::istream &in, std::vector< const E *> &edges, const std::string &rid)
Reads an edge vector binary.
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
static std::ostream & writeTime(std::ostream &strm, SUMOTime value)
Writes a time description binary.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
Functions for an easier usage of files and paths.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
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...
static std::string addExtension(const std::string &path, const std::string &extension)
Add an extension to the given file path.
static std::ostream & writeEdgeVector(std::ostream &os, const std::vector< E > &edges)
Writes an edge vector binary.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
static std::ostream & writeString(std::ostream &strm, const std::string &value)
Writes a string binary.