123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #pragma once
- #include <algorithm>
- #include <cctype>
- #include <iterator>
- #include <string>
- #include <vector>
- namespace WwiseGTE
- {
- inline std::wstring ConvertNarrowToWide(std::string const& input)
- {
- std::wstring output;
- std::transform(input.begin(), input.end(), std::back_inserter(output),
- [](char c) { return static_cast<wchar_t>(c); });
- return output;
- }
- inline std::string ConvertWideToNarrow(std::wstring const& input)
- {
- std::string output;
- std::transform(input.begin(), input.end(), std::back_inserter(output),
- [](wchar_t c) { return static_cast<char>(c); });
- return output;
- }
- inline std::string ToLower(std::string const& input)
- {
- std::string output;
- std::transform(input.begin(), input.end(), std::back_inserter(output),
- [](int c) { return static_cast<char>(::tolower(c)); });
- return output;
- }
- inline std::string ToUpper(std::string const& input)
- {
- std::string output;
- std::transform(input.begin(), input.end(), std::back_inserter(output),
- [](int c) { return static_cast<char>(::toupper(c)); });
- return output;
- }
-
-
-
-
-
-
-
- inline void GetTokens(std::string const& input, std::string const& whiteSpace,
- std::vector<std::string>& tokens)
- {
- std::string tokenString(input);
- tokens.clear();
- while (tokenString.length() > 0)
- {
-
- auto begin = tokenString.find_first_not_of(whiteSpace);
- if (begin == std::string::npos)
- {
-
- break;
- }
-
- if (begin > 0)
- {
- tokenString = tokenString.substr(begin);
- }
-
- auto end = tokenString.find_first_of(whiteSpace);
- if (end != std::string::npos)
- {
- std::string token = tokenString.substr(0, end);
- tokens.push_back(token);
- tokenString = tokenString.substr(end);
- }
- else
- {
-
- tokens.push_back(tokenString);
- break;
- }
- }
- }
-
-
- inline void GetTextTokens(std::string const& input,
- std::vector<std::string>& tokens)
- {
- static std::string const whiteSpace = []
- {
- std::string temp;
- for (int i = 0; i <= 32; ++i)
- {
- temp += char(i);
- }
- for (int i = 127; i < 255; ++i)
- {
- temp += char(i);
- }
- return temp;
- }
- ();
- GetTokens(input, whiteSpace, tokens);
- }
-
-
-
- inline void GetAdvancedTextTokens(std::string const& input,
- std::vector<std::string>& tokens)
- {
- static std::string const whiteSpace = []
- {
- std::string temp;
- for (int i = 0; i <= 32; ++i)
- {
- temp += char(i);
- }
- temp += char(127);
- return temp;
- }
- ();
- GetTokens(input, whiteSpace, tokens);
- }
- }
|