diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-08 17:27:40 +0200 |
commit | 4fd6bca4e75870958ea61b94e0a1e60e78cd91bc (patch) | |
tree | 2119cae72f45e1ceff1982d8364b4b678ac4ee69 /odb/context.cxx | |
parent | 7cd11b5f604c7d786261568aa31cd2ae3638f61e (diff) |
Add support for defining composite value type as class template instantiations
Diffstat (limited to 'odb/context.cxx')
-rw-r--r-- | odb/context.cxx | 88 |
1 files changed, 59 insertions, 29 deletions
diff --git a/odb/context.cxx b/odb/context.cxx index 532a6b7..267b233 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -3,11 +3,14 @@ // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // license : GNU GPL v3; see accompanying LICENSE file +#include <odb/gcc.hxx> + #include <cctype> // std::toupper #include <cassert> #include <odb/context.hxx> #include <odb/common.hxx> +#include <odb/pragma.hxx> #include <odb/relational/mysql/context.hxx> #include <odb/relational/oracle/context.hxx> @@ -16,6 +19,23 @@ using namespace std; +// +// view_object +// + +string view_object:: +name () const +{ + if (!alias.empty ()) + return alias; + + return kind == object ? context::class_name (*obj) : orig_name; +} + +// +// context +// + namespace { char const* keywords[] = @@ -388,6 +408,30 @@ class_kind (semantics::class_& c) } string context:: +class_name (semantics::class_& c) +{ + return c.is_a<semantics::class_instantiation> () + ? c.get<semantics::names*> ("tree-hint")->name () + : c.name (); +} + +string context:: +class_fq_name (semantics::class_& c) +{ + return c.is_a<semantics::class_instantiation> () + ? c.fq_name (c.get<semantics::names*> ("tree-hint")) + : c.fq_name (); +} + +semantics::path context:: +class_file (semantics::class_& c) +{ + return c.is_a<semantics::class_instantiation> () + ? semantics::path (LOCATION_FILE (c.get<location_t> ("location"))) + : c.file (); +} + +string context:: upcase (string const& s) { string r; @@ -491,34 +535,20 @@ composite_ (semantics::class_& c) { bool r (true); - // List of pragmas that disqualify a value type from being treated as - // composite. - // - //@@ Did we add new simple value pragmas and forgot to account for - // them here? - // - r = r && c.count ("value"); - r = r && !c.count ("table"); - r = r && !c.count ("type"); - r = r && !c.count ("id-type"); - r = r && !c.count ("value-type"); - r = r && !c.count ("index-type"); - r = r && !c.count ("key-type"); - r = r && !c.count ("value-column"); - r = r && !c.count ("index-column"); - r = r && !c.count ("key-column"); - r = r && !c.count ("id-column"); - r = r && !c.count ("default"); - r = r && !c.count ("null"); - r = r && !c.count ("not-null"); - r = r && !c.count ("value-null"); - r = r && !c.count ("value-not-null"); - r = r && !c.count ("options"); - r = r && !c.count ("value-options"); - r = r && !c.count ("index-options"); - r = r && !c.count ("key-options"); - r = r && !c.count ("id-options"); - r = r && !c.count ("unordered"); + if (c.count ("value")) + { + for (pragma_name_set::const_iterator i (simple_value_pragmas_.begin ()), + e (simple_value_pragmas_.end ()); i != e; ++i) + { + if (c.count (*i)) + { + r = false; + break; + } + } + } + else + r = false; c.set ("composite-value", r); return r; @@ -532,7 +562,7 @@ table_name (semantics::class_& c) const if (c.count ("table")) name += c.get<string> ("table"); else - name += c.name (); + name += class_name (c); return name; } |