From 274fcfe8d3fc5b54b345d79fab6dd4bbdb544892 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 24 May 2008 16:40:06 +0000 Subject: aux::lowercase, aux::to_lowercase --- src/auxiliary/functions.cc | 14 ++++++++++++++ src/auxiliary/functions.h | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'src/auxiliary') 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__ -- cgit v1.2.3