blob: fe6ad1535af29c2c5acc4a1aa2e610db19114372 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 + '!';
}
}
|