treewide: prefer std::starts_with to boost
Replace boost versions of starts_with and ends_with with the std
versions provided with c++20.
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I97218c607ff04aedad490b3af428071b0fa75615
diff --git a/src/associations.cpp b/src/associations.cpp
index 79672af..6dbc710 100644
--- a/src/associations.cpp
+++ b/src/associations.cpp
@@ -1,9 +1,9 @@
#include "associations.hpp"
-#include <boost/algorithm/string/predicate.hpp>
#include <sdbusplus/exception.hpp>
#include <iostream>
+#include <string>
void removeAssociation(const std::string& sourcePath, const std::string& owner,
sdbusplus::asio::object_server& server,
@@ -462,8 +462,7 @@
endpoints.begin(), endpoints.end(), otherPath);
if (endpoint != endpoints.end())
{
- return boost::starts_with(ap.first,
- endpointPath + '/');
+ return ap.first.starts_with(endpointPath + '/');
}
return false;
});
diff --git a/src/main.cpp b/src/main.cpp
index 1e3883f..109b1b3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,7 +5,6 @@
#include <tinyxml2.h>
-#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/signal_set.hpp>
#include <boost/container/flat_map.hpp>
@@ -30,7 +29,7 @@
boost::container::flat_map<std::string, std::string>& owners,
const std::string& newObject)
{
- if (boost::starts_with(newObject, ":"))
+ if (newObject.starts_with(":"))
{
return;
}
@@ -430,7 +429,7 @@
auto child = std::find_if(
interfaceMap.begin(), interfaceMap.end(),
[&owner, &childPath](const auto& entry) {
- return boost::starts_with(entry.first, childPath) &&
+ return entry.first.starts_with(childPath) &&
(entry.second.find(owner) != entry.second.end());
});
@@ -456,7 +455,7 @@
// Interfaces need to be sorted for intersect to function
std::sort(interfaces.begin(), interfaces.end());
- if (boost::ends_with(reqPath, "/"))
+ if (reqPath.ends_with("/"))
{
reqPath.pop_back();
}
@@ -476,7 +475,7 @@
continue;
}
- if (boost::starts_with(reqPath, thisPath))
+ if (reqPath.starts_with(thisPath))
{
if (interfaces.empty())
{
@@ -549,7 +548,7 @@
// reqPath is now guaranteed to have a trailing "/" while reqPathStripped
// will be guaranteed not to have a trailing "/"
- if (!boost::ends_with(reqPath, "/"))
+ if (!reqPath.ends_with("/"))
{
reqPath += "/";
}
@@ -574,7 +573,7 @@
continue;
}
- if (boost::starts_with(thisPath, reqPath))
+ if (thisPath.starts_with(reqPath))
{
// count the number of slashes past the stripped search term
int32_t thisDepth = std::count(
@@ -611,7 +610,7 @@
// reqPath is now guaranteed to have a trailing "/" while reqPathStripped
// will be guaranteed not to have a trailing "/"
- if (!boost::ends_with(reqPath, "/"))
+ if (!reqPath.ends_with("/"))
{
reqPath += "/";
}
@@ -636,7 +635,7 @@
continue;
}
- if (boost::starts_with(thisPath, reqPath))
+ if (thisPath.starts_with(reqPath))
{
// count the number of slashes past the stripped search term
int thisDepth = std::count(
diff --git a/src/processing.cpp b/src/processing.cpp
index 561cbde..5a733d4 100644
--- a/src/processing.cpp
+++ b/src/processing.cpp
@@ -1,15 +1,14 @@
#include "processing.hpp"
-#include <boost/algorithm/string/predicate.hpp>
-
#include <iostream>
+#include <string>
bool getWellKnown(
const boost::container::flat_map<std::string, std::string>& owners,
const std::string& request, std::string& wellKnown)
{
// If it's already a well known name, just return
- if (!boost::starts_with(request, ":"))
+ if (!request.starts_with(":"))
{
wellKnown = request;
return true;
@@ -27,11 +26,10 @@
bool needToIntrospect(const std::string& processName,
const AllowDenyList& allowList)
{
- auto inAllowList =
- std::find_if(allowList.begin(), allowList.end(),
- [&processName](const auto& prefix) {
- return boost::starts_with(processName, prefix);
- }) != allowList.end();
+ auto inAllowList = std::find_if(allowList.begin(), allowList.end(),
+ [&processName](const auto& prefix) {
+ return processName.starts_with(prefix);
+ }) != allowList.end();
return inAllowList;
}
@@ -42,7 +40,7 @@
InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
sdbusplus::asio::object_server& server)
{
- if (boost::starts_with(oldOwner, ":"))
+ if (oldOwner.starts_with(":"))
{
auto it = nameOwners.find(oldOwner);
if (it != nameOwners.end())