aboutsummaryrefslogtreecommitdiff
path: root/odb/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-10-15 07:01:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-10-15 07:01:17 +0200
commita482f1c4dd4efab83d3b19309900f1cbf54383a5 (patch)
tree3c1ab27e420cbf760a54a1c4be61bbd0448a4873 /odb/context.cxx
parent400d258aab3722be3a4b8548870afad1574f3ad8 (diff)
Automatically map C++11 enum classes (strong enums)
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index 4db15a0..352cb51 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -1926,16 +1926,25 @@ database_type_impl (semantics::type& t,
bool id,
bool* null)
{
- type_map_type::const_iterator i (data_->type_map_.find (t, hint));
+ using semantics::enum_;
+
+ // By default map an enum as its underlying type.
+ //
+ if (enum_* e = dynamic_cast<enum_*> (&t))
+ return database_type_impl (
+ e->underlying_type (), e->underlying_type_hint (), id, null);
+ // Built-in type mapping.
+ //
+ type_map_type::const_iterator i (data_->type_map_.find (t, hint));
if (i != data_->type_map_.end ())
{
if (null != 0)
*null = i->second.null;
return id ? i->second.id_type : i->second.type;
}
- else
- return string ();
+
+ return string ();
}
static string