strvector::const_iterator subfind(string const & text, strvector const & list, size_t const pos) { for(auto it = list.begin(); it != list.end(); it++) { if(subcmp(text, *it, pos)) { return it; } } return list.end(); }
string join(strvector const& list, string const& glue) { auto result = string(); auto it = list.begin(); while(it != list.end()) { result += *it; it++; if(it != list.end()) { result += glue; } } return result; }
void interpret(strvector& data, CTableView* pView) { bool ok = true; for (strvector::const_iterator i = data.begin(), end = data.end(); i != end && ok; ++i) { string s = *i; token_handler handler = find_handler(s); if (handler) ok = (*handler)(i, end, pView); } }
size_t strfind_of(string const & text, strvector const& list, size_t const offset, strvector::const_iterator outIt) { size_t result = string::npos; outIt = list.end(); for(auto it = list.begin(); it < list.end(); it++) { if(it->empty()) continue; auto pos = text.find(*it, offset); if(pos == string::npos) continue; if(result == string::npos || pos < result) { result = pos; outIt = it; } } return result; }
// // If there are spaces in a coordinate entry in the // layout file, then those coordinates will be two // entries in the 'data' vector because a space is // a string separator. // // This function collapses such entries into one to // allow entries like: '13, 5' in the layout file. // void collapse(strvector& data) { strvector tmp; for (strvector::const_iterator i = data.begin(), e = data.end(); i != e; ++i) { string s = *i; int pos = s.find_first_of(','); if (pos == string::npos || pos == (s.size() - 1) && i != e) { ++i; string s2 = *i; s += s2; } tmp.push_back(s); } data = tmp; }