Replace boost::replace_all and boost::ireplace_all

Replaced with custom functions using std::string_view to remove Boost
dependency and reduce template instantiation, keeping original
behavior.

Tested: added UT and verified all tests passed

Change-Id: I82cc238c800c7780dc50b6a40445657931bf5250
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index 852db33..522c6f3 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -14,7 +14,6 @@
 #include "utils.hpp"
 
 #include <boost/algorithm/string/case_conv.hpp>
-#include <boost/algorithm/string/replace.hpp>
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/post.hpp>
 #include <boost/asio/steady_timer.hpp>
diff --git a/src/entity_manager/overlay.cpp b/src/entity_manager/overlay.cpp
index 534c68f..ce41bca 100644
--- a/src/entity_manager/overlay.cpp
+++ b/src/entity_manager/overlay.cpp
@@ -3,10 +3,10 @@
 
 #include "overlay.hpp"
 
+#include "../utils.hpp"
 #include "devices.hpp"
 #include "utils.hpp"
 
-#include <boost/algorithm/string/replace.hpp>
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/steady_timer.hpp>
 #include <boost/container/flat_map.hpp>
@@ -39,7 +39,7 @@
         // remove brackets and comma from array
         std::string array = in.dump();
         array = array.substr(1, array.size() - 2);
-        boost::replace_all(array, ",", " ");
+        std::ranges::replace(array, ',', ' ');
         return array;
     }
     return in.dump();
@@ -247,10 +247,8 @@
         {
             channels = keyPair.value().get<std::vector<std::string>>();
         }
-        boost::replace_all(parameters, templateChar + keyPair.key(),
-                           subsituteString);
-        boost::replace_all(busPath, templateChar + keyPair.key(),
-                           subsituteString);
+        replaceAll(parameters, templateChar + keyPair.key(), subsituteString);
+        replaceAll(busPath, templateChar + keyPair.key(), subsituteString);
     }
 
     if (!bus || !address)
diff --git a/src/entity_manager/perform_probe.cpp b/src/entity_manager/perform_probe.cpp
index f398860..e5b57eb 100644
--- a/src/entity_manager/perform_probe.cpp
+++ b/src/entity_manager/perform_probe.cpp
@@ -5,7 +5,6 @@
 
 #include "perform_scan.hpp"
 
-#include <boost/algorithm/string/replace.hpp>
 #include <phosphor-logging/lg2.hpp>
 
 #include <regex>
@@ -114,7 +113,8 @@
                         return false;
                     }
                     std::string commandStr = *(match.begin() + 1);
-                    boost::replace_all(commandStr, "'", "");
+                    replaceAll(commandStr, "'", "");
+
                     cur = (std::find(scan->passedProbes.begin(),
                                      scan->passedProbes.end(), commandStr) !=
                            scan->passedProbes.end());
@@ -136,8 +136,9 @@
             }
             std::string commandStr = *(match.begin() + 1);
             // convert single ticks and single slashes into legal json
-            boost::replace_all(commandStr, "'", "\"");
-            boost::replace_all(commandStr, R"(\)", R"(\\)");
+            std::ranges::replace(commandStr, '\'', '"');
+
+            replaceAll(commandStr, R"(\)", R"(\\)");
             auto json = nlohmann::json::parse(commandStr, nullptr, false, true);
             if (json.is_discarded())
             {
diff --git a/src/entity_manager/utils.cpp b/src/entity_manager/utils.cpp
index 6f51ec8..4e46395 100644
--- a/src/entity_manager/utils.cpp
+++ b/src/entity_manager/utils.cpp
@@ -6,7 +6,6 @@
 #include "phosphor-logging/lg2.hpp"
 
 #include <boost/algorithm/string/case_conv.hpp>
-#include <boost/algorithm/string/replace.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus/match.hpp>
 
@@ -170,11 +169,11 @@
         return ret;
     }
 
-    boost::replace_all(*strPtr, std::string(templateChar) + "index",
-                       std::to_string(index));
+    replaceAll(*strPtr, std::string(templateChar) + "index",
+               std::to_string(index));
     if (replaceStr)
     {
-        boost::replace_all(*strPtr, *replaceStr, std::to_string(index));
+        replaceAll(*strPtr, *replaceStr, std::to_string(index));
     }
 
     for (const auto& [propName, propValue] : interface)
@@ -205,7 +204,7 @@
                       strPtr->at(nextItemIdx)) == mathChars.end())
         {
             std::string val = std::visit(VariantToStringVisitor(), propValue);
-            boost::ireplace_all(*strPtr, templateName, val);
+            iReplaceAll(*strPtr, templateName, val);
             continue;
         }