summaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-06 12:15:06 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 11:47:12 +0200
commita9515f06d9570cb22565c1c80132aabed416d3f5 (patch)
treea5a7b7f28cb1dd5966a3b0d3cbbc2db0b532aa26 /odb
parentb683a4349522c7e067a70ba8b397bd38d956df61 (diff)
Implement oracle_version comparison operators and initializing constructor
Diffstat (limited to 'odb')
-rw-r--r--odb/option-types.cxx7
-rw-r--r--odb/option-types.hxx49
-rw-r--r--odb/relational/oracle/common.cxx4
3 files changed, 50 insertions, 10 deletions
diff --git a/odb/option-types.cxx b/odb/option-types.cxx
index 870fb1d..d1cccb4 100644
--- a/odb/option-types.cxx
+++ b/odb/option-types.cxx
@@ -120,10 +120,7 @@ operator>> (istream& is, oracle_version& v)
is >> minor;
if (!is.fail ())
- {
- v.major_ = major;
- v.minor_ = minor;
- }
+ v = oracle_version (major, minor);
}
else
is.setstate (istream::failbit);
@@ -135,5 +132,5 @@ operator>> (istream& is, oracle_version& v)
ostream&
operator<< (ostream& os, oracle_version v)
{
- return os << v.major_ << '.' << v.minor_;
+ return os << v.ver_major () << '.' << v.ver_minor ();
}
diff --git a/odb/option-types.hxx b/odb/option-types.hxx
index 642c149..9d1d98c 100644
--- a/odb/option-types.hxx
+++ b/odb/option-types.hxx
@@ -69,6 +69,12 @@ operator<< (std::ostream&, schema_format);
//
struct oracle_version
{
+ oracle_version () {}
+ oracle_version (unsigned short major, unsigned short minor)
+ : major_ (major), minor_ (minor)
+ {
+ }
+
unsigned short
ver_major () const
{
@@ -81,14 +87,53 @@ struct oracle_version
return minor_;
}
- friend std::istream& operator>> (std::istream&, oracle_version&);
- friend std::ostream& operator<< (std::ostream&, oracle_version);
+ bool
+ equal (const oracle_version& x) const
+ {
+ return major_ == x.major_ && minor_ == x.minor_;
+ }
+
+ bool
+ less (const oracle_version& x) const
+ {
+ return major_ < x.major_ || (major_ == x.major_ && minor_ < x.minor_);
+ }
+
+ bool
+ greater (const oracle_version& x) const
+ {
+ return major_ > x.major_ || (major_ == x.major_ && minor_ > x.minor_);
+ }
private:
unsigned short major_;
unsigned short minor_;
};
+bool
+inline operator< (const oracle_version& x, const oracle_version& y)
+{
+ return x.less (y);
+}
+
+bool
+inline operator> (const oracle_version& x, const oracle_version& y)
+{
+ return x.greater (y);
+}
+
+bool
+inline operator<= (const oracle_version& x, const oracle_version& y)
+{
+ return !x.greater (y);
+}
+
+bool
+inline operator>= (const oracle_version& x, const oracle_version& y)
+{
+ return !x.less (y);
+}
+
std::istream&
operator>> (std::istream&, oracle_version&);
diff --git a/odb/relational/oracle/common.cxx b/odb/relational/oracle/common.cxx
index f77f391..bf1925d 100644
--- a/odb/relational/oracle/common.cxx
+++ b/odb/relational/oracle/common.cxx
@@ -122,9 +122,7 @@ namespace relational
// extraction into a 64 bit integer.
//
else if (
- (options.oracle_client_version ().ver_major () > 11 ||
- (options.oracle_client_version ().ver_major () == 11 &&
- options.oracle_client_version ().ver_minor () >= 2)) &&
+ (options.oracle_client_version () >= oracle_version (11, 2)) &&
(r <= 19 || (r == 20 && unsigned_integer (mi.t))))
traverse_int64 (mi);
else