14 #ifndef vtkSpyPlotHistoryReaderPrivate_h 15 #define vtkSpyPlotHistoryReaderPrivate_h 17 #include <vtksys/SystemTools.hxx> 39 bool convert(
const std::string& num, T& t)
41 std::istringstream i(num);
47 inline void trim(std::string&
string,
const std::string& whitespace =
" \t\"")
49 const size_t begin =
string.find_first_not_of(whitespace);
50 if (begin == std::string::npos)
55 const size_t end =
string.find_last_not_of(whitespace);
56 const size_t range = end - begin + 1;
57 string =
string.substr(begin, range);
63 const size_t begin = str.rfind(
'.');
64 if (begin == std::string::npos)
70 bool valid =
convert(str.substr(begin + 1), row);
71 return (valid) ? row : -1;
77 const size_t begin = str.rfind(
'.');
78 if (begin == std::string::npos)
83 std::string t(str.substr(0, begin));
89 inline void split(
const std::string& s,
const char& delim, std::vector<std::string>& elems)
91 std::stringstream ss(s);
93 while (std::getline(ss, item, delim))
96 elems.push_back(item);
102 std::map<std::string, int>& fields, std::map<int, std::string>& lookup)
104 std::stringstream ss(s);
108 while (std::getline(ss, item, delim))
114 if (vtksys::SystemTools::LowerCase(item) ==
"time")
118 if (fields.find(item) != fields.end())
121 fields[item] = index;
122 lookup[index] = item;
124 if (count == fields.size())
134 std::map<int, std::string>& lookup, std::map<std::string, std::string>& info)
136 std::stringstream ss(s);
140 while (std::getline(ss, item, delim))
143 if (lookup.find(index) != lookup.end())
147 info[lookup[index]] = item;
150 if (count == lookup.size())
160 std::map<int, int>& columnIndexToRowId, std::map<int, std::string>& fieldCols)
164 std::vector<std::string> cols;
165 cols.reserve(header.size());
166 split(header, delim, cols);
167 std::vector<std::string>::const_iterator it;
170 std::vector<std::string> newHeader;
171 newHeader.reserve(cols.size());
174 bool foundStart =
false;
178 for (it = cols.begin(); it != cols.end(); ++it)
180 if ((*it).find(
".") != std::string::npos)
185 columnIndexToRowId.insert(std::pair<int, int>(index, rowNumber));
205 int numberOfCols = 1;
215 columnIndexToRowId.insert(std::pair<int, int>(index, rowNumber));
216 index += numberOfCols;
219 while (it != cols.end())
std::string nameFromHeaderCol(const std::string &str)
void getTimeStepInfo(const std::string &s, const char &delim, std::map< int, std::string > &lookup, std::map< std::string, std::string > &info)
void getMetaHeaderInfo(const std::string &s, const char &delim, std::map< std::string, int > &fields, std::map< int, std::string > &lookup)
void split(const std::string &s, const char &delim, std::vector< std::string > &elems)
int rowFromHeaderCol(const std::string &str)
std::vector< std::string > createTableLayoutFromHeader(std::string &header, const char &delim, std::map< int, int > &columnIndexToRowId, std::map< int, std::string > &fieldCols)
void trim(std::string &string, const std::string &whitespace=" \")
bool convert(const std::string &num, T &t)