From 061cb76fc48f493b187928f841083981e9733a28 Mon Sep 17 00:00:00 2001 From: Alex Maystrenko Date: Sat, 5 Feb 2022 20:47:29 +0100 Subject: [PATCH] make functions in header file inline added header guard now string utils can be used in any part of the project --- include/util/string.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/util/string.hpp b/include/util/string.hpp index d644b4c..c8c0209 100644 --- a/include/util/string.hpp +++ b/include/util/string.hpp @@ -1,15 +1,17 @@ +#pragma once + #include const std::string WHITESPACE = " \n\r\t\f\v"; -std::string ltrim(const std::string s) { +inline std::string ltrim(const std::string s) { size_t begin = s.find_first_not_of(WHITESPACE); return (begin == std::string::npos) ? "" : s.substr(begin); } -std::string rtrim(const std::string s) { +inline std::string rtrim(const std::string s) { size_t end = s.find_last_not_of(WHITESPACE); return (end == std::string::npos) ? "" : s.substr(0, end + 1); } -std::string trim(const std::string& s) { return rtrim(ltrim(s)); } +inline std::string trim(const std::string& s) { return rtrim(ltrim(s)); }