summaryrefslogtreecommitdiff
path: root/libformat/libformat/format.cxx
blob: d1c18bc10b16a649cb8fd340939dc601bfb1c31a (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
// file: libformat/format.cxx -*- C++ -*-

#include <libformat/format.hxx>

#include <cctype>     // to{upper,lower}()
#include <algorithm>  // transform()

using namespace std;

namespace format
{
  string
  message (const string& g, const string& n, volume v)
  {
    string r (g);

    transform (r.begin (), r.end (), r.begin (),
               [v] (char c) -> char
               {
                 switch (v)
                 {
                 case volume::quiet:  return tolower (c);
                 case volume::normal: return c;
                 case volume::loud:   return toupper (c);
                 }
               });

    return r += ", " + n + '!';
  }
}