13    static std::string ReplaceAll(std::string& str, 
const std::string& from, 
const std::string& to) {
 
   15        while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
 
   16            str.replace(start_pos, from.length(), to);
 
   22    ReplaceFunction(std::string& str, 
const std::string& from, 
const std::string& from2, 
const std::string& to,
 
   23                    const std::string& to2) {
 
   25        size_t start_pos2 = 0;
 
   26        while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
 
   27            str.replace(start_pos, from.length(), to);
 
   28            start_pos += to.length();
 
   30            if ((start_pos2 = str.find(from2, start_pos)) != std::string::npos) {
 
   31                if (str.find(from, start_pos) < start_pos2) 
continue;
 
   33                str.replace(start_pos2, from2.length(), to2);
 
   34                start_pos = start_pos2 + to2.length();
 
   41    static std::string trim(std::string str) {
 
   42        std::string r = str.erase(str.find_last_not_of(
" \n\t\r") + 1);
 
   43        return r.erase(0, r.find_first_not_of(
" \n\t\r"));
 
   46    static std::vector<std::string> split(
const std::string& s, 
char seperator) {
 
   47        std::vector<std::string> output;
 
   49        std::string::size_type prev_pos = 0;
 
   50        std::string::size_type pos = s.find(seperator);
 
   53        while (pos != std::string::npos) {
 
   55            output.push_back(s.substr(prev_pos, pos - prev_pos));
 
   59            pos = s.find(seperator, prev_pos);
 
   63        output.push_back(s.substr(prev_pos, pos - prev_pos));
 
   69    static void make_upper(std::string& str) {
 
   70        std::transform(str.begin(), str.end(), str.begin(), toupper);
 
   73    static void make_lower(std::string& str) {
 
   74        std::transform(str.begin(), str.end(), str.begin(), tolower);
 
   77    static std::string make_lower_copy(std::string _str) {
 
   78        std::string str(std::move(_str));
 
   79        std::transform(str.begin(), str.end(), str.begin(), tolower);
 
   84    std::string appandAll(std::stringstream& sstream, T param) {
 
   86        auto result = sstream.str();
 
   87        sstream.str(std::string());
 
   93    template<
typename T0, 
typename ... Tn>
 
   94    std::string appandAll(std::stringstream& sstream, T0 param0, Tn... paramN) {
 
   96        return appandAll(sstream, paramN...);
 
   99    static std::string ConvertSpaceStr(
const std::string& str, 
bool SpaceNotChange = 
false) {
 
  100        std::string converted_str = str;
 
  102        if (SpaceNotChange) {
 
  105            while ((pos = converted_str.find(
"$nbsp:", pos)) != std::string::npos) {
 
  106                converted_str.replace(pos, 6, 
" ");
 
  112            while ((pos = converted_str.find(
' ', pos)) != std::string::npos) {
 
  113                converted_str.replace(pos, 1, 
"$nbsp:");
 
  118        return converted_str;
 
  121    static std::string GetRandomHash(
int size) {
 
  122        std::random_device rd;
 
  123        std::mt19937 gen(rd());
 
  124        std::uniform_int_distribution<> dis(0, 61); 
 
  127        result.reserve(size);
 
  129        for (
int i = 0; i < size; i++) {
 
  133                result += std::to_string(num);
 
  134            } 
else if (num < 36) {
 
  136                result += 
static_cast<char>(num + 
'A' - 10);
 
  139                result += 
static_cast<char>(num + 
'a' - 36);