diff options
Diffstat (limited to 'src/auxiliary')
-rw-r--r-- | src/auxiliary/functions.cc | 14 | ||||
-rw-r--r-- | src/auxiliary/functions.h | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc index 2b42bae..b417a4a 100644 --- a/src/auxiliary/functions.cc +++ b/src/auxiliary/functions.cc @@ -76,4 +76,18 @@ const std::string spaces(const std::string &text,size_t n) return s; } +void to_lowercase(std::string &text) +{ + for (std::string::iterator i = text.begin(); i != text.end(); ++i) + (*i) = tolower(*i); +} + +const std::string lowercase(const std::string &text) +{ + std::string t; + for (std::string::const_iterator i = text.begin(); i != text.end(); ++i) + t += tolower(*i); + return t; +} + } diff --git a/src/auxiliary/functions.h b/src/auxiliary/functions.h index cd9ed13..2202b87 100644 --- a/src/auxiliary/functions.h +++ b/src/auxiliary/functions.h @@ -36,6 +36,12 @@ size_t text_length(const std::string &text); /// prepend spaces to a string up to the desired lenght, excluding color codes const std::string spaces(const std::string &text, size_t n); + +/// convert a string to lowercase +void to_lowercase(std::string &text); + +/// return text, converted to lowercase +const std::string lowercase(const std::string &text); } #endif // __INCLUDED_AUX_FUNCTIONS_H__ |