diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-26 12:13:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-28 14:15:45 +0200 |
commit | 64d0ceffaaf5f57a3d24a5210bf0ad2a8474a618 (patch) | |
tree | 98115a01b0bd2e9ddfdc6ff3a0f7470915de483a /odb/context.hxx | |
parent | 061a16256eef2c2df53e2e145d16f17270c2de82 (diff) |
Add wrapper support for composite values
NULL semantics for composite values is not yet supported.
Diffstat (limited to 'odb/context.hxx')
-rw-r--r-- | odb/context.hxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/odb/context.hxx b/odb/context.hxx index 69c5d48..3a09805 100644 --- a/odb/context.hxx +++ b/odb/context.hxx @@ -78,6 +78,17 @@ public: // public: + // Check whether the type is a wrapper. Return the wrapped type if + // it is a wrapper and NULL otherwise. + // + static semantics::type* + wrapper (semantics::type& t) + { + return t.count ("wrapper") && t.get<bool> ("wrapper") + ? t.get<semantics::type*> ("wrapper-type") + : 0; + } + // Composite value type is a class type that was explicitly marked // as value type and there was no database type mapping provided for // it by the user (specifying the database type makes the value type @@ -102,6 +113,19 @@ public: return c != 0 && comp_value (*c) ? c : 0; } + // As above but also "sees through" wrappers. + // + static semantics::class_* + comp_value_wrapper (semantics::type& t) + { + if (semantics::class_* c = comp_value (t)) + return c; + else if (semantics::type* wt = wrapper (t)) + return comp_value (*wt); + else + return 0; + } + static bool container (semantics::type& t) { |