diff options
Diffstat (limited to 'libformat/libformat/format.cxx')
-rw-r--r-- | libformat/libformat/format.cxx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/libformat/libformat/format.cxx b/libformat/libformat/format.cxx index 421f50d..53530a8 100644 --- a/libformat/libformat/format.cxx +++ b/libformat/libformat/format.cxx @@ -2,10 +2,30 @@ #include <libformat/format.hxx> +#include <cctype> // to{upper,lower}() +#include <algorithm> // transform() + using namespace std; -string -format (const string& g, const string& n) +namespace format { - return g + ", " + n + '!'; + string + message (const string& g, const string& n, volume v) + { + string r (g); + + auto tr = [&r] (char (*t) (char)) + { + transform (r.begin (), r.end (), r.begin (), t); + }; + + switch (v) + { + case volume::quiet: tr ([](char c) -> char {return tolower (c);}); break; + case volume::normal: break; + case volume::loud: tr ([](char c) -> char {return toupper (c);}); break; + } + + return r += ", " + n + '!'; + } } |