diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-09 18:02:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-09 18:02:40 +0200 |
commit | 9bf40e4a91f6a792c3279d9184b67451cf58bf49 (patch) | |
tree | a242a923ec7d309dc488c60f1233fbc91fcbae70 /cli/option-types.cxx | |
parent | bd21176187a55fa7f6e80b5cfe86f5e756971b4f (diff) |
Add --std option with c++{98,11,14} values; use function-static in C++11
This way we can use option descriptions during static initialization (e.g.,
of an Apache module).
Diffstat (limited to 'cli/option-types.cxx')
-rw-r--r-- | cli/option-types.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/option-types.cxx b/cli/option-types.cxx new file mode 100644 index 0000000..b3bc6ad --- /dev/null +++ b/cli/option-types.cxx @@ -0,0 +1,44 @@ +// file : cli/option-types.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <istream> + +#include "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; +} |