@@ -604,18 +604,28 @@ namespace sqlite3pp
604604
605605 static void replace_all (std::wstring & data, const std::wstring &toSearch, const std::wstring &replaceStr)
606606 {
607- // Get the first occurrence
607+ if (toSearch.empty ())
608+ return ;
608609 size_t pos = data.find (toSearch);
609- // Repeat till end is reached
610610 while (pos != std::string::npos)
611611 {
612- // Replace this occurrence of Sub String
613612 data.replace (pos, toSearch.size (), replaceStr);
614- // Get the next occurrence from the current position
615613 pos = data.find (toSearch, pos + replaceStr.size ());
616614 }
617615 }
618616
617+ static void replace_all (std::string& str, const std::string& toSearch, const std::string& replaceStr)
618+ {
619+ if (toSearch.empty ())
620+ return ;
621+ size_t start_pos = 0 ;
622+ while ((start_pos = str.find (toSearch, start_pos)) != std::string::npos)
623+ {
624+ str.replace (start_pos, toSearch.length (), replaceStr);
625+ start_pos += replaceStr.length (); // Move past the replaced text
626+ }
627+ }
628+
619629 static void CheckEnv (std::wstring &src, const std::string &VarName, const std::string VarNamePrefix, const std::string VarNamePostfix)
620630 {
621631 char env_p[_MAX_PATH] = { 0 };
@@ -1154,19 +1164,10 @@ namespace sqlite3pp
11541164 static const char TopHeaderCommnetsPrt2[] = " For more details see https://github.com/David-Maisonave/sqlite3pp_EZ\n */" ;
11551165 const std::vector<std::pair<std::string, std::string> > SQLiteClassBuilder::columns_dummy;
11561166
1157- void replaceAll (std::string& str, const std::string& from, const std::string& to) {
1158- if (from.empty ())
1159- return ;
1160- size_t start_pos = 0 ;
1161- while ((start_pos = str.find (from, start_pos)) != std::string::npos) {
1162- str.replace (start_pos, from.length (), to);
1163- start_pos += to.length (); // Move past the replaced text
1164- }
1165- }
11661167 std::string GetValidFuncName (std::string name)
11671168 {
11681169 // ToDo: Use regex to make sure all values are AlphaNum
1169- replaceAll (name, " " , " __" );
1170+ replace_all (name, " " , " __" );
11701171 return name;
11711172 }
11721173
0 commit comments