diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-06 08:58:43 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-10-21 11:47:12 +0200 |
commit | 3d1aa62e7f6dfeba4b81ea4716598fe680f1fffb (patch) | |
tree | 269833f53585612e72ba1facc0b4b997ddd936dc /odb/option-types.cxx | |
parent | 03fbd42bd45c30875f1a5c3c52062550e4a8a7f9 (diff) |
Add --oracle-client-version option and its associated C++ type oracle_version
Diffstat (limited to 'odb/option-types.cxx')
-rw-r--r-- | odb/option-types.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/odb/option-types.cxx b/odb/option-types.cxx index da29793..cc4b28b 100644 --- a/odb/option-types.cxx +++ b/odb/option-types.cxx @@ -7,6 +7,7 @@ #include <istream> #include <ostream> #include <algorithm> // std::lower_bound +#include <sstream> // std::ostringstream #include <odb/option-types.hxx> @@ -94,3 +95,46 @@ operator<< (ostream& os, schema_format sf) { return os << sf.string (); } + +// oracle_version +// +istream& +operator>> (istream& is, oracle_version& v) +{ + unsigned short major, minor; + + // Extract the major version. + // + is >> major; + + if (!is.fail ()) + { + // Extract the decimal point. + // + char p; + is >> p; + + if (!is.fail () && p == '.') + { + // Extract the minor version. + // + is >> minor; + + if (!is.fail ()) + { + v.major_ = major; + v.minor_ = minor; + } + } + else + is.setstate (istream::failbit); + } + + return is; +} + +ostream& +operator<< (ostream& os, oracle_version v) +{ + return os << v.major_ << '.' << v.minor_; +} |