diff options
Diffstat (limited to 'src/auxiliary')
-rw-r--r-- | src/auxiliary/functions.cc | 20 | ||||
-rw-r--r-- | src/auxiliary/functions.h | 25 |
2 files changed, 30 insertions, 15 deletions
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc index 8cefbc5..5dbc012 100644 --- a/src/auxiliary/functions.cc +++ b/src/auxiliary/functions.cc @@ -13,7 +13,7 @@ const std::string plural(const char * word, size_t n) { std::string p(word); - if (n != 1) + if (n != 1) p += 's'; return p; } @@ -96,40 +96,40 @@ const std::string text_strip_lowercase(const std::string &text) return r; } -const std::string pad_left(const std::string &text,size_t n) +const std::string pad_left(const std::string &text, size_t n) { size_t l = text_length(text); if (n <= l) return text; std::string s; - s.assign(n-l, ' '); + s.assign(n - l, ' '); s.append(text); return s; } -const std::string pad_right(const std::string &text,size_t n) +const std::string pad_right(const std::string &text, size_t n) { size_t l = text_length(text); if (n <= l) return text; std::string s(text); - s.append(n-l, ' '); + s.append(n - l, ' '); return s; } void to_lowercase(std::string &text) { - for (std::string::iterator i = text.begin(); i != text.end(); ++i) - (*i) = tolower(*i); + 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); + for (std::string::const_iterator i = text.begin(); i != text.end(); ++i) + t += tolower(*i); return t; } @@ -139,7 +139,7 @@ void trim(std::string &text) text.erase(0, 1); } while (text.size() && text[text.size()-1] == ' ') { - text.erase(text.size()-1, 1); + text.erase(text.size() - 1, 1); } } diff --git a/src/auxiliary/functions.h b/src/auxiliary/functions.h index d5b590d..aeaa201 100644 --- a/src/auxiliary/functions.h +++ b/src/auxiliary/functions.h @@ -18,18 +18,33 @@ namespace aux const std::string plural(const char * word, size_t n); /// append an "s" to a word, depending on the amount -inline const std::string plural(const std::string & word, size_t n) { return plural(word.c_str(), n); } +inline const std::string plural(const std::string & word, size_t n) +{ + return plural(word.c_str(), n); +} /// prepend the "a" or "an" article to a word const std::string article(const char * word); -inline const std::string article(const std::string & word) { return article(word.c_str()); } +inline const std::string article(const std::string & word) +{ + return article(word.c_str()); +} -inline bool is_base_color_code(char const *c) { return ((*c == '^') && (*(c+1) >= '0') && (*(c+1) <= '7')); } +inline bool is_base_color_code(char const *c) +{ + return ((*c == '^') && (*(c + 1) >= '0') && (*(c + 1) <= '7')); +} -inline bool is_core_color_code(char const *c) { return ((*c == '^') && (*(c+1) >= 'A') && (*(c+1) <= 'Z')); } +inline bool is_core_color_code(char const *c) +{ + return ((*c == '^') && (*(c + 1) >= 'A') && (*(c + 1) <= 'Z')); +} -inline bool is_color_code(char const *c) { return (is_base_color_code(c) || is_core_color_code(c)); } +inline bool is_color_code(char const *c) +{ + return (is_base_color_code(c) || is_core_color_code(c)); +} /// length of a string, excluding color codes size_t text_length(const std::string &text); |