1 #ifndef ROSE_StringUtility_SplitJoin_H
2 #define ROSE_StringUtility_SplitJoin_H
4 #include <Rose/Constants.h>
13 namespace StringUtility {
33 ROSE_UTIL_API std::vector<std::string>
split(
const std::string &separator,
const std::string &str,
size_t maxparts =
UNLIMITED,
34 bool trim_white_space =
false);
35 ROSE_UTIL_API std::vector<std::string>
split(
char separator,
const std::string &str,
size_t maxparts =
UNLIMITED,
36 bool trim_white_space =
false);
43 ROSE_UTIL_API std::list<std::string>
tokenize(
const std::string&,
char delim);
52 template<
class Iterator>
53 std::string
join_range(
const std::string &separator, Iterator begin, Iterator end) {
54 std::ostringstream retval;
55 for (Iterator i=begin; i!=end; ++i)
56 retval <<(i==begin ? std::string() : separator) <<*i;
60 template<
class Container>
61 std::string
join(
const std::string &separator,
const Container &container) {
62 return join_range(separator, container.begin(), container.end());
65 template<
class Container>
66 std::string
join(
char separator,
const Container &container) {
67 return join_range(std::string(1, separator), container.begin(), container.end());
70 ROSE_UTIL_API std::string
join(
const std::string &separator,
char *strings[],
size_t nstrings);
71 ROSE_UTIL_API std::string
join(
const std::string &separator,
const char *strings[],
size_t nstrings);
72 ROSE_UTIL_API std::string
join(
char separator,
char *strings[],
size_t nstrings);
73 ROSE_UTIL_API std::string
join(
char separator,
const char *strings[],
size_t nstrings);
96 ROSE_UTIL_API std::string
joinEnglish(
const std::vector<std::string> &phrases,
97 const std::string &separator =
",",
98 const std::string &finalIntro =
"and");
111 ROSE_UTIL_API std::string
listToString(
const std::list<int>&,
bool separateStrings =
false);
119 ROSE_UTIL_API std::string
listToString(
const std::list<std::string>&,
bool separateStrings =
false);
120 ROSE_UTIL_API std::string
listToString(
const std::vector<std::string>&,
bool separateStrings =
false);
131 ROSE_UTIL_API std::list<std::string>
stringToList(
const std::string&);
137 ROSE_UTIL_API
void splitStringIntoStrings(
const std::string& inputString,
char separator, std::vector<std::string>& stringList);