Commit d6188c7f73bf7d71ec967548249a6f5d136598cf

Authored by Benjamin Renard
2 parents 061ac3dd 1bcc7b53

Merge branch 'FER_11651' into amdadev

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&lt;TimeInterval&gt; 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&lt;TimeInterval&gt; 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
... ... @@ -52,6 +52,8 @@ public:
52 52  
53 53 ParameterDescription::ParameterType getTypeFromString(std::string type);
54 54  
  55 + std::vector<std::string> splitLine(const std::string& line) ;
  56 +
55 57 private:
56 58  
57 59 /**
... ...