aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-24 10:18:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-24 10:18:09 +0200
commit0799760700c288939bc39ad43f3e167d42406df5 (patch)
tree97760c1568657196a3bdc57b97030d15025da4ea /common
parent17d444a90d5ab7e4333bf4d17a9a0a3d35104ba4 (diff)
Add support for unordered storage of ordered containers
New pragma: unordered.
Diffstat (limited to 'common')
-rw-r--r--common/container/driver.cxx12
-rw-r--r--common/container/test.hxx16
2 files changed, 27 insertions, 1 deletions
diff --git a/common/container/driver.cxx b/common/container/driver.cxx
index 8355ab1..9940c9a 100644
--- a/common/container/driver.cxx
+++ b/common/container/driver.cxx
@@ -57,6 +57,9 @@ main (int argc, char* argv[])
med.cv.push_back (comp (123, "aaa"));
med.cv.push_back (comp (234, "bbbb"));
+ med.uv.push_back (123);
+ med.uv.push_back (234);
+
// list
//
med.sl.push_back ("aaa");
@@ -108,6 +111,10 @@ main (int argc, char* argv[])
full.cv.push_back (comp (2345, "bbbbb"));
full.cv.push_back (comp (3456, "cccccc"));
+ full.uv.push_back (1234);
+ full.uv.push_back (2345);
+ full.uv.push_back (3456);
+
// list
//
full.sl.push_back ("aaaa");
@@ -179,6 +186,7 @@ main (int argc, char* argv[])
empty.nv.push_back (12);
empty.sv.push_back ("aa");
empty.cv.push_back (comp (12, "aa"));
+ empty.uv.push_back (12);
empty.sl.push_back ("aa");
empty.ns.insert (12);
empty.ss.insert ("aa");
@@ -198,6 +206,7 @@ main (int argc, char* argv[])
med.nv.clear ();
med.sv.clear ();
med.cv.clear ();
+ med.uv.clear ();
med.sl.clear ();
@@ -229,6 +238,9 @@ main (int argc, char* argv[])
full.cv.back ().str += "c";
full.cv.push_back (comp (4567, "ddddddd"));
+ full.uv.back ()++;
+ full.uv.push_back (4567);
+
// list
//
full.sl.back () += "c";
diff --git a/common/container/test.hxx b/common/container/test.hxx
index a12be5c..1f565cd 100644
--- a/common/container/test.hxx
+++ b/common/container/test.hxx
@@ -10,7 +10,6 @@
#include <set>
#include <list>
#include <vector>
-
#include <string>
#include <odb/core.hxx>
@@ -96,6 +95,9 @@ struct object
#pragma db value_column("")
comp_vector cv;
+ #pragma db unordered
+ num_vector uv;
+
// list
//
#pragma db transient
@@ -120,6 +122,17 @@ struct object
inline bool
operator== (const object& x, const object& y)
{
+ if (x.uv.size () != y.uv.size ())
+ return false;
+
+ int xs (0), ys (0);
+
+ for (num_vector::size_type i (0); i < x.uv.size (); ++i)
+ {
+ xs += x.uv[i];
+ ys += y.uv[i];
+ }
+
return
x.id_ == y.id_ &&
x.num == y.num &&
@@ -130,6 +143,7 @@ operator== (const object& x, const object& y)
x.nv == y.nv &&
x.sv == y.sv &&
x.cv == y.cv &&
+ xs == ys &&
x.sl == y.sl &&