diff options
Diffstat (limited to 'libmformat/libmformat/format.cxx')
-rw-r--r-- | libmformat/libmformat/format.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libmformat/libmformat/format.cxx b/libmformat/libmformat/format.cxx new file mode 100644 index 0000000..fe6ad15 --- /dev/null +++ b/libmformat/libmformat/format.cxx @@ -0,0 +1,31 @@ +// file: libmformat/format.cxx -*- C++ -*- + +module format; + +import std.core; // transform() +import std.io; // to{upper,lower}() + +using namespace std; + +namespace format +{ + 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 + '!'; + } +} |