Introduction
To those used to manage strings in VB, the existance of functions like Split, Join, Replace and the like makes programming a bliss. C++ programmers don't have those "built in" facilities. For them, the present set of functions attemps to accomplish the same goal.
Matter gets worse for C++ programmers because besides the lack of those functions, they usually have to struggle with many kinds of strings (C like strings, STD strings, BSTRS, CStrings, etc). The idea is to bring a unified set of tools to cope with them all. Thus, the present tools resorts to the use of templates, allowing this way to receive as input anything that can be used to construct a std::string. There are also a couple of template specializations to deal with single charactters. A secondary goal is to show the use of template functions and namespaces.
Using the code
The following code snippet should be self explanatory:
//StringUtils::Split usage
const char* szToSplit = "Hello|World|from|String|Utils";
std::vector<std::string> v = StringUtils::Split(szToSplit, "|");
for (size_t i = 0; i < v.size(); i++)
std::cout << v[i] << std::endl;
//StringUtils::Join usage
std::string s = StringUtils::Join(v,"#");
std::cout << s << std::endl;
//should produce: Hello#World#from#String#Utils
Enough words for now, all you've gotta do is to #include "stringutils.h" in your source code. Happy templating!