aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/sqlite/context.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/relational/sqlite/context.hxx')
-rw-r--r--odb/relational/sqlite/context.hxx49
1 files changed, 45 insertions, 4 deletions
diff --git a/odb/relational/sqlite/context.hxx b/odb/relational/sqlite/context.hxx
index 3c17d55..6da5b9b 100644
--- a/odb/relational/sqlite/context.hxx
+++ b/odb/relational/sqlite/context.hxx
@@ -29,14 +29,20 @@ namespace relational
sql_type (): type (invalid) {}
core_type type;
+
+ // Conversion expressions for custom database types.
+ //
+ std::string to;
+ std::string from;
};
class context: public virtual relational::context
{
public:
sql_type const&
- parse_sql_type (string const&, semantics::data_member&);
-
+ parse_sql_type (string const&,
+ semantics::data_member&,
+ bool custom = true);
public:
struct invalid_sql_type
{
@@ -49,10 +55,17 @@ namespace relational
string message_;
};
+ // If custom_db_types is NULL, then this function returns
+ // invalid type instead of throwing in case an unknown type
+ // is encountered.
+ //
static sql_type
- parse_sql_type (string const&);
+ parse_sql_type (string const&, custom_db_types const* = 0);
protected:
+ virtual string const&
+ convert_expr (string const&, semantics::data_member&, bool);
+
virtual bool
grow_impl (semantics::class_&);
@@ -90,7 +103,35 @@ namespace relational
{
data (std::ostream& os): base_context::data (os) {}
- typedef std::map<string, sql_type> sql_type_cache;
+ struct sql_type_cache_entry
+ {
+ sql_type_cache_entry ()
+ : custom_cached (false), straight_cached (false) {}
+
+ sql_type const&
+ cache_custom (sql_type const& t)
+ {
+ custom = t;
+ custom_cached = true;
+ return custom;
+ }
+
+ sql_type const&
+ cache_straight (sql_type const& t)
+ {
+ straight = t;
+ straight_cached = true;
+ return straight;
+ }
+
+ sql_type custom; // With custom mapping.
+ sql_type straight; // Without custom mapping.
+
+ bool custom_cached;
+ bool straight_cached;
+ };
+
+ typedef std::map<string, sql_type_cache_entry> sql_type_cache;
sql_type_cache sql_type_cache_;
};