summaryrefslogtreecommitdiff
path: root/odb/context.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-10-27 17:36:59 +0200
commit7f6c64f2211d37db76a97fbc79a4b5492302ef2f (patch)
treef2e386644fcaab5c51e3f5ad0ac737ea5b4d5bd2 /odb/context.hxx
parent5259b98c75f3754a0f713bcee4bddd0ed7ce35ef (diff)
Implement support for composite value types
New test: common/composite.
Diffstat (limited to 'odb/context.hxx')
-rw-r--r--odb/context.hxx41
1 files changed, 36 insertions, 5 deletions
diff --git a/odb/context.hxx b/odb/context.hxx
index ac83736..b8a33c5 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -32,15 +32,33 @@ public:
typedef std::string string;
typedef ::options options_type;
- // Database names and types.
+ // Predicates.
//
public:
- // Cleaned-up member name that can be used in public interfaces
- // such as queries, column names, etc.
+
+ // Composite value type is a class type that was explicitly marked
+ // as value type and there was no SQL type mapping provided for it
+ // by the user (specifying the SQL type makes the value type simple).
//
- string
- public_name (semantics::data_member&) const;
+ static bool
+ comp_value (semantics::class_& c)
+ {
+ return c.count ("value") && !c.count ("type");
+ }
+ // Return the class object if this type is a composite value type
+ // and NULL otherwise.
+ //
+ static semantics::class_*
+ comp_value (semantics::type& t)
+ {
+ semantics::class_* c (dynamic_cast<semantics::class_*> (&t));
+ return c != 0 && t.count ("value") && !t.count ("type") ? c : 0;
+ }
+
+ // Database names and types.
+ //
+public:
string
table_name (semantics::type&) const;
@@ -50,12 +68,25 @@ public:
virtual string
column_type (semantics::data_member&) const;
+ // C++ names.
+ //
public:
+ // Cleaned-up member name that can be used in public interfaces.
+ //
+ string
+ public_name (semantics::data_member&) const;
+
// Escape C++ keywords, reserved names, and illegal characters.
//
string
escape (string const&) const;
+ // Counts and other information.
+ //
+public:
+ static size_t
+ column_count (semantics::class_&);
+
protected:
struct data;
typedef cutl::shared_ptr<data> data_ptr;