Remove usages of boost::starts/ends_with

Per the coding standard, now that C++ supports std::string::starts_with
and std::string::ends_with, we should be using them over the boost
alternatives.  This commit goes through and updates all usages.

Arguably some of these are incorrect, and instances of common error 13,
but because this is mostly a mechanical it intentionally doesn't try to
handle it.

Tested: Unit tests pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic4c6e5d0da90f7442693199dc691a47d2240fa4f
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index aa7f0eb..0bce29f 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -22,6 +22,8 @@
 
 #include <sys/inotify.h>
 
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
 #include <boost/asio/io_context.hpp>
 #include <boost/container/flat_map.hpp>
 #include <dbus_utility.hpp>
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index a4ecbf0..c2c873d 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -318,15 +318,14 @@
 
         std::string objectPath;
         std::string service;
-        if (boost::starts_with(
-                certURI,
+        if (certURI.starts_with(
                 "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"))
         {
             objectPath = certs::httpsObjectPath;
             service = certs::httpsServiceName;
         }
-        else if (boost::starts_with(
-                     certURI, "/redfish/v1/AccountService/LDAP/Certificates"))
+        else if (certURI.starts_with(
+                     "/redfish/v1/AccountService/LDAP/Certificates"))
         {
             objectPath = certs::ldapObjectPath;
             service = certs::ldapServiceName;
@@ -358,8 +357,7 @@
         }
 
         // validate KeyUsage supporting only 1 type based on URL
-        if (boost::starts_with(
-                certURI,
+        if (certURI.starts_with(
                 "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"))
         {
             if (optKeyUsage->empty())
@@ -382,8 +380,8 @@
                 return;
             }
         }
-        else if (boost::starts_with(
-                     certURI, "/redfish/v1/AccountService/LDAP/Certificates"))
+        else if (certURI.starts_with(
+                     "/redfish/v1/AccountService/LDAP/Certificates"))
         {
             if (optKeyUsage->empty())
             {
@@ -799,8 +797,7 @@
         std::string objectPath;
         std::string name;
         std::string service;
-        if (boost::starts_with(
-                certURI,
+        if (certURI.starts_with(
                 "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/"))
         {
             objectPath =
@@ -808,16 +805,15 @@
             name = "HTTPS certificate";
             service = certs::httpsServiceName;
         }
-        else if (boost::starts_with(
-                     certURI, "/redfish/v1/AccountService/LDAP/Certificates/"))
+        else if (certURI.starts_with(
+                     "/redfish/v1/AccountService/LDAP/Certificates/"))
         {
             objectPath =
                 std::string(certs::ldapObjectPath) + "/" + std::to_string(id);
             name = "LDAP certificate";
             service = certs::ldapServiceName;
         }
-        else if (boost::starts_with(
-                     certURI,
+        else if (certURI.starts_with(
                      "/redfish/v1/Managers/bmc/Truststore/Certificates/"))
         {
             objectPath = std::string(certs::authorityObjectPath) + "/" +
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index be4ce7e..5ccc25f 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -16,6 +16,8 @@
 #pragma once
 
 #include <app.hpp>
+#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
 #include <boost/container/flat_set.hpp>
 #include <dbus_singleton.hpp>
 #include <dbus_utility.hpp>
@@ -430,7 +432,7 @@
     for (const auto& objpath : dbusData)
     {
         // Check if proper pattern for object path appears
-        if (boost::starts_with(objpath.first.str, ipv6PathStart))
+        if (objpath.first.str.starts_with(ipv6PathStart))
         {
             for (const auto& interface : objpath.second)
             {
@@ -508,7 +510,7 @@
     for (const auto& objpath : dbusData)
     {
         // Check if proper pattern for object path appears
-        if (boost::starts_with(objpath.first.str, ipv4PathStart))
+        if (objpath.first.str.starts_with(ipv4PathStart))
         {
             for (const auto& interface : objpath.second)
             {
@@ -569,7 +571,7 @@
                     }
                     // Check if given address is local, or global
                     ipv4Address.linktype =
-                        boost::starts_with(ipv4Address.address, "169.254.")
+                        ipv4Address.address.starts_with("169.254.")
                             ? LinkType::Local
                             : LinkType::Global;
                 }
@@ -1815,7 +1817,7 @@
 
 inline bool verifyNames(const std::string& parent, const std::string& iface)
 {
-    return boost::starts_with(iface, parent + "_");
+    return iface.starts_with(parent + "_");
 }
 
 inline void requestEthernetInterfacesRoutes(App& app)
@@ -2272,7 +2274,7 @@
 
             for (const std::string& ifaceItem : ifaceList)
             {
-                if (boost::starts_with(ifaceItem, rootInterfaceName + "_"))
+                if (ifaceItem.starts_with(rootInterfaceName + "_"))
                 {
                     std::string path =
                         "/redfish/v1/Managers/bmc/EthernetInterfaces/";
diff --git a/redfish-core/lib/health.hpp b/redfish-core/lib/health.hpp
index cf84c93..2f0f156 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -18,7 +18,6 @@
 #include "async_resp.hpp"
 
 #include <app.hpp>
-#include <boost/algorithm/string/predicate.hpp>
 #include <dbus_singleton.hpp>
 #include <dbus_utility.hpp>
 #include <nlohmann/json.hpp>
@@ -73,7 +72,7 @@
             if (selfPath)
             {
                 if (boost::equals(path.str, *selfPath) ||
-                    boost::starts_with(path.str, *selfPath + "/"))
+                    path.str.starts_with(*selfPath + "/"))
                 {
                     isSelf = true;
                 }
@@ -89,7 +88,7 @@
 
                 for (const std::string& child : inventory)
                 {
-                    if (boost::starts_with(path.str, child))
+                    if (path.str.starts_with(child))
                     {
                         isChild = true;
                         break;
@@ -138,15 +137,15 @@
                 }
             }
 
-            if (boost::starts_with(path.str, globalInventoryPath) &&
-                boost::ends_with(path.str, "critical"))
+            if (path.str.starts_with(globalInventoryPath) &&
+                path.str.ends_with("critical"))
             {
                 health = "Critical";
                 rollup = "Critical";
                 return;
             }
-            if (boost::starts_with(path.str, globalInventoryPath) &&
-                boost::ends_with(path.str, "warning"))
+            if (path.str.starts_with(globalInventoryPath) &&
+                path.str.ends_with("warning"))
             {
                 health = "Warning";
                 if (rollup != "Critical")
@@ -154,7 +153,7 @@
                     rollup = "Warning";
                 }
             }
-            else if (boost::ends_with(path.str, "critical"))
+            else if (path.str.ends_with("critical"))
             {
                 rollup = "Critical";
                 if (isSelf)
@@ -163,7 +162,7 @@
                     return;
                 }
             }
-            else if (boost::ends_with(path.str, "warning"))
+            else if (path.str.ends_with("warning"))
             {
                 if (rollup != "Critical")
                 {
@@ -224,8 +223,8 @@
             self->statuses = resp;
             for (auto it = self->statuses.begin(); it != self->statuses.end();)
             {
-                if (boost::ends_with(it->first.str, "critical") ||
-                    boost::ends_with(it->first.str, "warning"))
+                if (it->first.str.ends_with("critical") ||
+                    it->first.str.ends_with("warning"))
                 {
                     it++;
                     continue;
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index ffae14d..fc5754b 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -27,6 +27,7 @@
 #include <unistd.h>
 
 #include <app.hpp>
+#include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/beast/http.hpp>
@@ -312,7 +313,7 @@
     {
         // If we find a redfish log file, save the path
         std::string filename = dirEnt.path().filename();
-        if (boost::starts_with(filename, redfishLogFilename))
+        if (filename.starts_with(redfishLogFilename))
         {
             redfishLogFiles.emplace_back(redfishLogDir / filename);
         }
@@ -1774,7 +1775,7 @@
         std::string filename = it.path().filename();
         // Prefix of each log files is "log". Find the file and save the
         // path
-        if (boost::starts_with(filename, "log"))
+        if (filename.starts_with("log"))
         {
             hostLoggerFiles.emplace_back(it.path());
         }
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index c4a2ef4..3c10130 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -18,7 +18,6 @@
 #include "health.hpp"
 
 #include <app.hpp>
-#include <boost/algorithm/string.hpp>
 #include <dbus_utility.hpp>
 #include <nlohmann/json.hpp>
 #include <query.hpp>
@@ -383,7 +382,7 @@
 
         for (const char* v : values)
         {
-            if (boost::ends_with(*value, v))
+            if (value->ends_with(v))
             {
                 aResp->res.jsonValue[jsonPtr]["OperatingMemoryModes"].push_back(
                     v);
@@ -405,7 +404,7 @@
 
         for (const char* v : values)
         {
-            if (boost::ends_with(*value, v))
+            if (value->ends_with(v))
             {
                 aResp->res.jsonValue[jsonPtr]["MemoryMedia"].push_back(v);
                 break;
@@ -554,7 +553,7 @@
 
             for (const char* v : values)
             {
-                if (boost::ends_with(*value, v))
+                if (value->ends_with(v))
                 {
                     aResp->res.jsonValue[jsonPtr]["ErrorCorrection"] = v;
                     break;
@@ -578,7 +577,7 @@
 
             for (const char* v : values)
             {
-                if (boost::ends_with(*value, v))
+                if (value->ends_with(v))
                 {
                     aResp->res.jsonValue[jsonPtr]["BaseModuleType"] = v;
                     break;
@@ -642,7 +641,7 @@
                 {
                     aResp->res.jsonValue[jsonPtr]["MemoryType"] = "DRAM";
                 }
-                else if (boost::ends_with(*value, "Logical"))
+                else if (value->ends_with("Logical"))
                 {
                     aResp->res.jsonValue[jsonPtr]["MemoryType"] = "IntelOptane";
                 }
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index a8cfb68..a7f8a41 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -230,7 +230,7 @@
             {
                 getCpuDataByInterface(aResp, object.second);
             }
-            else if (boost::starts_with(object.first.str, corePath))
+            else if (object.first.str.starts_with(corePath))
             {
                 for (const auto& interface : object.second)
                 {
@@ -700,7 +700,7 @@
         for (const auto& [objectPath, serviceMap] : subtree)
         {
             // Ignore any objects which don't end with our desired cpu name
-            if (!boost::ends_with(objectPath, processorId))
+            if (!objectPath.ends_with(processorId))
             {
                 continue;
             }
@@ -1014,7 +1014,7 @@
     std::string expectedPrefix("/redfish/v1/Systems/system/Processors/");
     expectedPrefix += processorId;
     expectedPrefix += "/OperatingConfigs/";
-    if (!boost::starts_with(appliedConfigUri, expectedPrefix) ||
+    if (!appliedConfigUri.starts_with(expectedPrefix) ||
         expectedPrefix.size() == appliedConfigUri.size())
     {
         messages::propertyValueIncorrect(
@@ -1078,7 +1078,7 @@
 
             for (const std::string& object : objects)
             {
-                if (!boost::ends_with(object, cpuName))
+                if (!object.ends_with(cpuName))
                 {
                     continue;
                 }
@@ -1138,8 +1138,7 @@
             for (const auto& [objectPath, serviceMap] : subtree)
             {
                 // Ignore any configs without matching cpuX/configY
-                if (!boost::ends_with(objectPath, expectedEnding) ||
-                    serviceMap.empty())
+                if (!objectPath.ends_with(expectedEnding) || serviceMap.empty())
                 {
                     continue;
                 }
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6e72fea..04b5190 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -16,7 +16,7 @@
 #pragma once
 
 #include <app.hpp>
-#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/range/algorithm/replace_copy_if.hpp>
 #include <dbus_singleton.hpp>
@@ -463,7 +463,7 @@
     {
         for (const std::string& sensor : *allSensors)
         {
-            if (boost::starts_with(sensor, type))
+            if (sensor.starts_with(type))
             {
                 activeSensors->emplace(sensor);
             }
@@ -1232,11 +1232,11 @@
 
                     std::string health;
 
-                    if (boost::ends_with(*status, "Full"))
+                    if (status->ends_with("Full"))
                     {
                         health = "OK";
                     }
-                    else if (boost::ends_with(*status, "Degraded"))
+                    else if (status->ends_with("Degraded"))
                     {
                         health = "Warning";
                     }
@@ -1982,15 +1982,15 @@
             if (inventoryItem != nullptr)
             {
                 // Store LED state in InventoryItem
-                if (boost::ends_with(state, "On"))
+                if (state.ends_with("On"))
                 {
                     inventoryItem->ledState = LedState::ON;
                 }
-                else if (boost::ends_with(state, "Blink"))
+                else if (state.ends_with("Blink"))
                 {
                     inventoryItem->ledState = LedState::BLINK;
                 }
-                else if (boost::ends_with(state, "Off"))
+                else if (state.ends_with("Off"))
                 {
                     inventoryItem->ledState = LedState::OFF;
                 }
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index c9fb4a1..1beef2e 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -158,8 +158,8 @@
                                 return !task::completed;
                             }
 
-                            if (boost::ends_with(*state, "Invalid") ||
-                                boost::ends_with(*state, "Failed"))
+                            if (state->ends_with("Invalid") ||
+                                state->ends_with("Failed"))
                             {
                                 taskData->state = "Exception";
                                 taskData->status = "Warning";
@@ -168,7 +168,7 @@
                                 return task::completed;
                             }
 
-                            if (boost::ends_with(*state, "Staged"))
+                            if (state->ends_with("Staged"))
                             {
                                 taskData->state = "Stopping";
                                 taskData->messages.emplace_back(
@@ -183,7 +183,7 @@
                                 return !task::completed;
                             }
 
-                            if (boost::ends_with(*state, "Active"))
+                            if (state->ends_with("Active"))
                             {
                                 taskData->messages.emplace_back(
                                     messages::taskCompletedOK(index));
@@ -924,7 +924,7 @@
                                      std::string, std::vector<std::string>>>>&
                      obj : subtree)
             {
-                if (!boost::ends_with(obj.first, *swId))
+                if (!obj.first.ends_with(*swId))
                 {
                     continue;
                 }