aboutsummaryrefslogtreecommitdiff
path: root/odb/common.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-07-30 13:30:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-07-30 13:30:16 +0200
commit6aab653d6975b92c11eef1b56f025c11e6d8e612 (patch)
treef2e2681836da00c8d77d829ff3fb9f2ace71a607 /odb/common.hxx
parent8e220faa86451ad4df72001282bb3ae4c8dcd1fb (diff)
Add support for the rest of database operations
Diffstat (limited to 'odb/common.hxx')
-rw-r--r--odb/common.hxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/odb/common.hxx b/odb/common.hxx
index 5588f00..ef188d8 100644
--- a/odb/common.hxx
+++ b/odb/common.hxx
@@ -6,6 +6,7 @@
#ifndef ODB_COMMON_HXX
#define ODB_COMMON_HXX
+#include <cstddef> // std::size_t
#include <odb/context.hxx>
// Find id member.
@@ -15,7 +16,7 @@ struct id_member: traversal::class_,
context
{
id_member (context& c)
- : context (c), m_ (0)
+ : context (c)
{
*this >> names_ >> *this;
}
@@ -33,11 +34,53 @@ struct id_member: traversal::class_,
m_ = &m;
}
- using class_::traverse;
+ virtual void
+ traverse (semantics::class_& c)
+ {
+ m_ = 0;
+ names (c);
+ }
private:
traversal::names names_;
semantics::data_member* m_;
};
+// Find id member.
+//
+struct member_count: traversal::class_,
+ traversal::data_member,
+ context
+{
+ member_count (context& c)
+ : context (c)
+ {
+ *this >> names_ >> *this;
+ }
+
+ std::size_t
+ count () const
+ {
+ return count_;
+ }
+
+ virtual void
+ traverse (semantics::data_member& m)
+ {
+ if (!m.count ("transient"))
+ count_++;
+ }
+
+ virtual void
+ traverse (semantics::class_& c)
+ {
+ count_ = 0;
+ names (c);
+ }
+
+private:
+ traversal::names names_;
+ std::size_t count_;
+};
+
#endif // ODB_COMMON_HXX