| 22 | |
| 23 | OPENDDS_VECTOR(String) |
| 24 | split(const String& str, |
| 25 | const String& delims, |
| 26 | bool skip_leading, |
| 27 | bool skip_consecutive) |
| 28 | { |
| 29 | OPENDDS_VECTOR(String) retval; |
| 30 | |
| 31 | std::string::size_type pos = 0; |
| 32 | if (skip_leading) { |
| 33 | pos = str.find_first_not_of(delims); |
| 34 | } |
| 35 | |
| 36 | while (pos != std::string::npos && pos < str.size()) { |
| 37 | const std::string::size_type limit = str.find_first_of(delims, pos); |
| 38 | if (limit == std::string::npos) { |
| 39 | retval.push_back(str.substr(pos)); |
| 40 | break; |
| 41 | } else { |
| 42 | retval.push_back(str.substr(pos, limit - pos)); |
| 43 | if (limit == str.size() - 1) { |
| 44 | // Delimeter at the end. |
| 45 | retval.push_back(String()); |
| 46 | } |
| 47 | pos = limit + 1; |
| 48 | if (skip_consecutive && pos != std::string::npos && pos < str.size()) { |
| 49 | pos = str.find_first_not_of(delims, pos); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return retval; |
| 55 | } |
| 56 | |
| 57 | String ConfigPair::canonicalize(const String& key) |
| 58 | { |