Strings gives static methods to work with std::wstring easier:

  • std::wstring between(...) - returns the wstring between two given literals,
  • void explode(...) - splits given str into vector<wstring> by given delimiter (in similar way to explode(...) from PHP),
  • void remove(...) - removes fragments (determined by two begin & end literals) from given wstring,
  • unsigned long getHash(const std::wstring &content) - generates hash code of content (it may collide with hash created for different wstring),
  • std::vector<std::wstring> parseArguments(int argc, const char * argv[]) - converts arguments (usually passed as console input parameters) into vector of wstring.

Note that all delimiters are of type std::wstring, co you can e.g. find a sub-string that is between two words of another std::wstring (and not only between the characters).

For conversions to/from std::wstring (e.g. from float or std::wstring type) use Converter.


void explode(...)

Will NEVER call ERROR_HANDLE(...).
Passed the Unit Test (2015-11-16)

void explode(const std::wstring &delimiter, const std::wstring &str, std::vector<&result>)

Split given str by given delimiter, into vector of non-empty wstring elements.


std::vector<std::wstring> result;
explode(L"-", L"this-is-text", &result); //result: {L"this", L"is", L"text"}

Remember that explode(...) split wstring into vector of non-empty wstring elements:

explode(L"-", L"this-is-", &result); //result: {L"this", L"is"} - no L"" as last element
explode(L"-", L"-this-is", &result); //result: {L"this", L"is"} - no L"" as first element
explode(L"-", L"this----------is", &result); //result = {L"this", L"is"} - no L"" elements between multiple delimiters
explode(L"-", L"abc", &result); //result: {L"abc"} - wstring was not splited (delimiter did not split it as it was not found)