Commit d6188c7f73bf7d71ec967548249a6f5d136598cf
Exists in
master
and in
10 other branches
Merge branch 'FER_11651' into amdadev
Showing
2 changed files
with
31 additions
and
2 deletions
Show diff stats
src/TimeTableCatalog/AsciiReader.cc
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | #include "AsciiReader.hh" |
11 | 11 | #include <boost/algorithm/string.hpp> |
12 | 12 | #include <boost/algorithm/string/predicate.hpp> |
13 | +#include <boost/tokenizer.hpp> | |
13 | 14 | #include <boost/lexical_cast.hpp> |
14 | 15 | #include <fstream> |
15 | 16 | #include "TimeTableCatalogUtil.hh" |
... | ... | @@ -102,9 +103,9 @@ std::unique_ptr<TimeInterval> AsciiReader::readInterval( |
102 | 103 | // -- create time interval |
103 | 104 | std::unique_ptr <TimeInterval> ti (new TimeInterval(startTime, stopTime, pcrtIndex)); |
104 | 105 | |
105 | - std::vector<std::string> params; | |
106 | - split(line, AsciiData::SEPARATOR.c_str()[0], params); | |
107 | 106 | |
107 | + std::vector<std::string> params = splitLine(line); | |
108 | + | |
108 | 109 | // If parameters value found, set them for the interval |
109 | 110 | if (!params.empty()) { |
110 | 111 | // Starts setting parameter values with the third field of the |
... | ... | @@ -129,6 +130,32 @@ std::unique_ptr<TimeInterval> AsciiReader::readInterval( |
129 | 130 | return ti; |
130 | 131 | } |
131 | 132 | |
133 | + | |
134 | +std::vector<std::string> AsciiReader::splitLine(const std::string& line) { | |
135 | + std::vector<std::string> result; | |
136 | + std::string token; | |
137 | + bool inQuotes = false; | |
138 | + | |
139 | + for (char c : line) { | |
140 | + if (c == '"') { | |
141 | + inQuotes = !inQuotes; | |
142 | + } else if (c == ' ' && !inQuotes) { | |
143 | + if (!token.empty()) { | |
144 | + result.push_back(token); | |
145 | + token.clear(); | |
146 | + } | |
147 | + } else { | |
148 | + token += c; | |
149 | + } | |
150 | + } | |
151 | + | |
152 | + // Add the last token | |
153 | + if (!token.empty()) | |
154 | + result.push_back(token); | |
155 | + return result; | |
156 | +} | |
157 | + | |
158 | + | |
132 | 159 | void AsciiReader::readMetadata(const std::string& pline, |
133 | 160 | TimeTable& ptimeTable) { |
134 | 161 | // try to find string like "Prop:xxxx" and set _prop attribute to "xxxx" | ... | ... |
src/TimeTableCatalog/AsciiReader.hh