aboutsummaryrefslogtreecommitdiff
path: root/xsd/cxx/option-types.cxx
blob: 4dc2aefc705f4b6a5038a9789cfe8f938e443218 (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
45
46
47
48
49
// file      : xsd/cxx/option-types.cxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#include <istream>
#include <ostream>

#include <cxx/option-types.hxx>

using namespace std;

namespace CXX
{
  //
  // cxx_version
  //

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

  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
        is.setstate (istream::failbit);
    }

    return is;
  }
}