ENH: add stringOps::splitAny, stringOps::splitSpace

- assists when building simple hand-rolled parsers.
  Also add string::split() taking a sub-string for the delimiter.
This commit is contained in:
Mark Olesen
2017-08-14 10:36:12 +02:00
parent 3b16c365ee
commit fbdd16a293
3 changed files with 212 additions and 12 deletions

View File

@ -304,15 +304,44 @@ namespace stringOps
Foam::word name(const std::string& fmt, const PrimitiveType& val);
//- Split a string into sub-strings at the delimiter character.
// An empty sub-strings are suppressed.
//- Split string into sub-strings at the delimiter character.
// Empty sub-strings are suppressed.
template<class StringType>
Foam::SubStrings<StringType> split
(
const StringType& str,
const char delimiter
const char delim
);
//- Split string into sub-strings using delimiter string.
// Empty sub-strings are suppressed.
template<class StringType>
Foam::SubStrings<StringType> split
(
const StringType& str,
const std::string& delim
);
//- Split string into sub-strings using any characters in delimiter.
// Empty sub-strings are suppressed.
template<class StringType>
Foam::SubStrings<StringType> splitAny
(
const StringType& str,
const std::string& delim
);
//- Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
// Empty sub-strings are suppressed.
template<class StringType>
Foam::SubStrings<StringType> splitSpace
(
const StringType& str
);
} // End namespace stringOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //