Commit 1bcc7b53f781478c867ec15a175ff2016796bc6c

Authored by Erdogan Furkan
1 parent 920804c3

#11651 - Done.

src/TimeTableCatalog/AsciiReader.cc
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 #include "AsciiReader.hh" 10 #include "AsciiReader.hh"
11 #include <boost/algorithm/string.hpp> 11 #include <boost/algorithm/string.hpp>
12 #include <boost/algorithm/string/predicate.hpp> 12 #include <boost/algorithm/string/predicate.hpp>
  13 +#include <boost/tokenizer.hpp>
13 #include <boost/lexical_cast.hpp> 14 #include <boost/lexical_cast.hpp>
14 #include <fstream> 15 #include <fstream>
15 #include "TimeTableCatalogUtil.hh" 16 #include "TimeTableCatalogUtil.hh"
@@ -102,9 +103,9 @@ std::unique_ptr&lt;TimeInterval&gt; AsciiReader::readInterval( @@ -102,9 +103,9 @@ std::unique_ptr&lt;TimeInterval&gt; AsciiReader::readInterval(
102 // -- create time interval 103 // -- create time interval
103 std::unique_ptr <TimeInterval> ti (new TimeInterval(startTime, stopTime, pcrtIndex)); 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 // If parameters value found, set them for the interval 109 // If parameters value found, set them for the interval
109 if (!params.empty()) { 110 if (!params.empty()) {
110 // Starts setting parameter values with the third field of the 111 // Starts setting parameter values with the third field of the
@@ -129,6 +130,32 @@ std::unique_ptr&lt;TimeInterval&gt; AsciiReader::readInterval( @@ -129,6 +130,32 @@ std::unique_ptr&lt;TimeInterval&gt; AsciiReader::readInterval(
129 return ti; 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 void AsciiReader::readMetadata(const std::string& pline, 159 void AsciiReader::readMetadata(const std::string& pline,
133 TimeTable& ptimeTable) { 160 TimeTable& ptimeTable) {
134 // try to find string like "Prop:xxxx" and set _prop attribute to "xxxx" 161 // try to find string like "Prop:xxxx" and set _prop attribute to "xxxx"
src/TimeTableCatalog/AsciiReader.hh
@@ -52,6 +52,8 @@ public: @@ -52,6 +52,8 @@ public:
52 52
53 ParameterDescription::ParameterType getTypeFromString(std::string type); 53 ParameterDescription::ParameterType getTypeFromString(std::string type);
54 54
  55 + std::vector<std::string> splitLine(const std::string& line) ;
  56 +
55 private: 57 private:
56 58
57 /** 59 /**