From 344ddd511742f1f0fee5536bfd1600ba1988c570 Mon Sep 17 00:00:00 2001 From: Martin Piatka Date: Tue, 25 Oct 2022 16:18:45 +0200 Subject: [PATCH] string_view_utils: Add sv_contains() --- src/debug.cpp | 8 -------- src/main.cpp | 2 +- src/utils/string_view_utils.hpp | 3 +++ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index c8394f647..5ea7c63a6 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -207,14 +207,6 @@ void debug_dump(const void *lp, int len) } } -namespace{ - -bool sv_contains(std::string_view haystack, std::string_view needle){ - return haystack.find(needle) != std::string_view::npos; -} - -} //anon namespace - bool parse_log_cfg(const char *conf_str, int *log_lvl, bool *logger_skip_repeats, diff --git a/src/main.cpp b/src/main.cpp index 77998f2ea..681e5be1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,7 +96,7 @@ #include "utils/misc.h" #include "utils/nat.h" #include "utils/net.h" -#include "utils/sv_parse_num.hpp" +#include "utils/string_view_utils.hpp" #include "utils/thread.h" #include "utils/wait_obj.h" #include "utils/udp_holepunch.h" diff --git a/src/utils/string_view_utils.hpp b/src/utils/string_view_utils.hpp index 212b55792..0374c9637 100644 --- a/src/utils/string_view_utils.hpp +++ b/src/utils/string_view_utils.hpp @@ -64,6 +64,9 @@ */ std::string_view tokenize(std::string_view& str, char delim, char quot = '\0'); +inline bool sv_contains(std::string_view haystack, std::string_view needle){ + return haystack.find(needle) != std::string_view::npos; +} /* std::from_chars is c++17, but on major compilers the feature was missing or * partial (no floating point support). This header provides safe fallbacks