66 static std::string
getFilePath(
const std::string& path);
74 static std::string
addExtension(
const std::string& path,
const std::string& extension);
98 static bool isSocket(
const std::string& name);
110 static bool isAbsolute(
const std::string& path);
123 static std::string
checkForRelativity(
const std::string& filename,
const std::string& basePath);
139 static std::ostream&
writeInt(std::ostream& strm,
int value);
149 static std::ostream&
writeFloat(std::ostream& strm,
double value);
157 static std::ostream&
writeByte(std::ostream& strm,
unsigned char value);
169 static std::ostream&
writeString(std::ostream& strm,
const std::string& value);
188 template <
typename E>
189 static std::ostream&
writeEdgeVector(std::ostream& os,
const std::vector<E>& edges);
197 template <
typename E>
198 static void readEdgeVector(std::istream& in, std::vector<const E*>& edges,
const std::string& rid);
203 template <
typename E>
206 std::vector<int> follow;
208 E prev = edges.front();
209 for (
typename std::vector<E>::const_iterator i = edges.begin() + 1; i != edges.end(); ++i) {
211 for (; idx < prev->getNumSuccessors(); ++idx) {
215 if (prev->getSuccessors()[idx] == (*i)) {
216 follow.push_back(idx);
217 if (idx > maxFollow) {
223 if (idx > 15 || idx == prev->getNumSuccessors()) {
229 if (follow.empty()) {
230 for (
typename std::vector<E>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
234 const int bits = maxFollow > 3 ? 4 : 2;
235 const int numFields = 8 *
sizeof(int) / bits;
240 for (std::vector<int>::const_iterator i = follow.begin(); i != follow.end(); ++i) {
243 if (field == numFields) {
259 template <
typename E>
262 in.read((
char*) &size,
sizeof(
int));
265 in.read((
char*) &bitsOrEntry,
sizeof(
int));
266 if (bitsOrEntry < 0) {
267 const int bits = -bitsOrEntry;
268 const int numFields = 8 *
sizeof(int) / bits;
269 const int mask = (1 << bits) - 1;
271 in.read((
char*) &edgeID,
sizeof(int));
272 const E* prev = E::getAllEdges()[edgeID];
274 edges.push_back(prev);
277 int field = numFields;
278 for (; size > 0; size--) {
279 if (field == numFields) {
280 in.read((
char*) &data,
sizeof(
int));
283 int followIndex = (data >> ((numFields - field - 1) * bits)) & mask;
284 if (followIndex >= prev->getNumSuccessors()) {
285 throw ProcessError(
"Invalid follower index in route '" + rid +
"'!");
287 prev = prev->getSuccessors()[followIndex];
288 edges.push_back(prev);
293 const E* edge = E::getAllEdges()[bitsOrEntry];
295 throw ProcessError(
"An edge within the route '" + rid +
"' is not known!");
297 edges.push_back(edge);
300 in.read((
char*) &bitsOrEntry,
sizeof(
int));
Functions for an easier usage of files and paths.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
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 void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector 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 & writeString(std::ostream &strm, const std::string &value)
Writes a string binary.
static bool isReadable(std::string path)
Checks whether the given file is readable.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
static std::ostream & writeTime(std::ostream &strm, SUMOTime value)
Writes a time description binary.
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
static std::ostream & writeEdgeVector(std::ostream &os, const std::vector< E > &edges)
Writes an edge vector binary.
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
static bool isDirectory(std::string path)
Checks whether the given file is a directory.
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
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