diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-30 12:08:32 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-07-30 12:08:32 +0100 |
commit | 49e804ec79b56bb107fedbeb6b47493e2401635e (patch) | |
tree | 9552c53fbe2bbeede6b482c98f383bd6895afea9 | |
parent | Append chunks of plain data in urldecode (diff) | |
download | icespider-49e804ec79b56bb107fedbeb6b47493e2401635e.tar.bz2 icespider-49e804ec79b56bb107fedbeb6b47493e2401635e.tar.xz icespider-49e804ec79b56bb107fedbeb6b47493e2401635e.zip |
Inline functions for removing trailing/leading chars
-rw-r--r-- | icespider/core/util.cpp | 16 | ||||
-rw-r--r-- | icespider/core/util.h | 17 |
2 files changed, 15 insertions, 18 deletions
diff --git a/icespider/core/util.cpp b/icespider/core/util.cpp index b330f79..5e51b8b 100644 --- a/icespider/core/util.cpp +++ b/icespider/core/util.cpp @@ -7,20 +7,4 @@ namespace IceSpider { { throw Http400_BadRequest(); } - - void - remove_trailing(std::string_view & in, const char c) - { - if (const auto n = in.find_last_not_of(c); n != std::string_view::npos) { - in.remove_suffix(in.length() - n - 1); - } - } - - void - remove_leading(std::string_view & in, const char c) - { - if (const auto n = in.find_first_not_of(c); n != std::string_view::npos) { - in.remove_prefix(n); - } - } } diff --git a/icespider/core/util.h b/icespider/core/util.h index f4868c3..ecf0831 100644 --- a/icespider/core/util.h +++ b/icespider/core/util.h @@ -161,6 +161,19 @@ namespace IceSpider { } } - void remove_trailing(std::string_view & in, const char c); - void remove_leading(std::string_view & in, const char c); + inline void + remove_trailing(std::string_view & in, const char c) + { + if (const auto n = in.find_last_not_of(c); n != std::string_view::npos) { + in.remove_suffix(in.length() - n - 1); + } + } + + inline void + remove_leading(std::string_view & in, const char c) + { + if (const auto n = in.find_first_not_of(c); n != std::string_view::npos) { + in.remove_prefix(n); + } + } } |