diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-11 14:40:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-11 14:40:02 +0200 |
commit | 5652354aa256426c5ab32c4a1c5687e5509af868 (patch) | |
tree | ac59964abb8696c12ec4ea71c56e9219dd4245e6 /odb/context.cxx | |
parent | 2a7a60a29cc72f07263ec7534732141f8869b5ed (diff) |
Add support for custom table definition options
Diffstat (limited to 'odb/context.cxx')
-rw-r--r-- | odb/context.cxx | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/odb/context.cxx b/odb/context.cxx index e220d0e..dd4019a 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -2130,6 +2130,90 @@ table_name (semantics::data_member& m, table_prefix const& p) const return r; } +string context:: +table_options (semantics::class_& c) +{ + string r; + + // Accumulate options from class. + // + // @@ Should we also get them from bases? + // + // @@ Note for some databases (like SQLite), options are seperated with + // comma, not space. Likely the same issue in the column_options(). + // + if (c.count ("options")) + { + strings const& o (c.get<strings> ("options")); + + for (strings::const_iterator i (o.begin ()); i != o.end (); ++i) + { + if (i->empty ()) + r.clear (); + else + { + if (!r.empty ()) + r += ' '; + + r += *i; + } + } + } + + return r; +} + +string context:: +table_options (semantics::data_member& m, semantics::type& c) +{ + string r; + + // Accumulate options from container and member. + // + // @@ Currently there is no way to assign options to the container type. If + // we use the value specifier, then it ends up being treated as a value + // type. To support this we will probably need to invent the container + // specifier. + // + if (c.count ("options")) + { + strings const& o (c.get<strings> ("options")); + + for (strings::const_iterator i (o.begin ()); i != o.end (); ++i) + { + if (i->empty ()) + r.clear (); + else + { + if (!r.empty ()) + r += ' '; + + r += *i; + } + } + } + + if (m.count ("options")) + { + strings const& o (m.get<strings> ("options")); + + for (strings::const_iterator i (o.begin ()); i != o.end (); ++i) + { + if (i->empty ()) + r.clear (); + else + { + if (!r.empty ()) + r += ' '; + + r += *i; + } + } + } + + return r; +} + // context::column_prefix // context::column_prefix:: |