diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-06-08 14:37:54 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-06-08 14:37:54 +0200 |
commit | ff6df050c55b5ae56c6daaef9c44860992f927d1 (patch) | |
tree | c58449346c3f092dcbdcdda1c8b3583001a40dee /src/common/Metric/Metric.cpp | |
parent | 0f9a0accf17ba3a9f20d6a7575b51ed2cb09a73c (diff) |
Core/Misc: Remove boost/algorithm dependency
Diffstat (limited to 'src/common/Metric/Metric.cpp')
-rw-r--r-- | src/common/Metric/Metric.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index a3956209b08..227e8e55bb8 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -21,7 +21,6 @@ #include "IoContext.h" #include "Log.h" #include "Util.h" -#include <boost/algorithm/string/replace.hpp> #include <boost/asio/ip/tcp.hpp> void Metric::Initialize(std::string const& realmName, Trinity::Asio::IoContext& ioContext, std::function<void()> overallStatusLogger) @@ -38,8 +37,7 @@ bool Metric::Connect() { auto& stream = static_cast<boost::asio::ip::tcp::iostream&>(GetDataStream()); stream.connect(_hostname, _port); - auto error = stream.error(); - if (error) + if (boost::system::error_code const& error = stream.error()) { TC_LOG_ERROR("metric", "Error connecting to '{}:{}', disabling Metric. Error message : {}", _hostname, _port, error.message()); @@ -266,18 +264,23 @@ void Metric::ScheduleOverallStatusLog() std::string Metric::FormatInfluxDBValue(bool value) { - return value ? "t" : "f"; + return std::string(1, value ? 't' : 'f'); } template<class T> std::string Metric::FormatInfluxDBValue(T value) { - return std::to_string(value) + 'i'; + std::string result = std::to_string(value); + result += 'i'; + return result; } std::string Metric::FormatInfluxDBValue(std::string const& value) { - return '"' + boost::replace_all_copy(value, "\"", "\\\"") + '"'; + std::string result = StringReplaceAll(value, "\"", "\\\""); + result.insert(result.begin(), '"'); + result.append(1, '"'); + return result; } std::string Metric::FormatInfluxDBValue(char const* value) @@ -298,7 +301,7 @@ std::string Metric::FormatInfluxDBValue(float value) std::string Metric::FormatInfluxDBTagValue(std::string const& value) { // ToDo: should handle '=' and ',' characters too - return boost::replace_all_copy(value, " ", "\\ "); + return StringReplaceAll(value, " ", "\\ "); } std::string Metric::FormatInfluxDBValue(std::chrono::nanoseconds value) |