-
Notifications
You must be signed in to change notification settings - Fork 8
/
README
36 lines (22 loc) · 1.17 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
split++: splits and join strings from C++
author: Erik Garrison <[email protected]>
overview:
split++ provides just the most useful string manipulation functions which C++
never had-- split and join-- in the form of two easily-manageable header files.
provided functions:
split.h:
// split a string on a single delimiter character (delim)
std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, char delim);
// split a string on any character found in the string of delimiters (delims)
std::vector<std::string>& split(const std::string &s, const std::string& delims, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, const std::string& delims);
join.h:
// join a vector of elements by a delimiter object. ostream<< must be defined
// for both class S and T and an ostream, as it is e.g. in the case of strings
// and character arrays
template<class S, class T>
std::string join(S& delim, std::vector<T>& elems);
usage:
See splittest.cpp and jointest.cpp for example usage. To use, simply include
split.h or join.h in your C++ project.