summaryrefslogtreecommitdiff
path: root/cli/option-types.cxx
blob: a196ae43214c47a04b0d26b231fb5bb2a1daf7d8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
// file      : cli/option-types.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2018 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#include <istream>

#include <cli/option-types.hxx>

using namespace std;

static const char* cxx_version_[] =
{
  "c++98",
  "c++11"
  "c++14"
};

string cxx_version::
string () const
{
  return cxx_version_[v_];
}

istream&
operator>> (istream& is, cxx_version& v)
{
  string s;
  is >> s;

  if (!is.fail ())
  {
    if (s == "c++98")
      v = cxx_version::cxx98;
    else if (s == "c++11")
      v = cxx_version::cxx11;
    else if (s == "c++14")
      v = cxx_version::cxx14;
    else
      is.setstate (istream::failbit);
  }

  return is;
}