From 557d156ec9c45ed105f7213e1748dc4aad78ebb2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Jan 2012 14:16:13 +0200 Subject: Customize generated pointer column wrapper ctor For SQL Server we need to be able to pass precision/scale. --- odb/relational/common.cxx | 20 ++++++++++++++------ odb/relational/common.hxx | 3 +++ odb/relational/mssql/common.cxx | 12 ++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/odb/relational/common.cxx b/odb/relational/common.cxx index 2d8f8d6..1ee8449 100644 --- a/odb/relational/common.cxx +++ b/odb/relational/common.cxx @@ -208,6 +208,15 @@ namespace relational } } + void query_columns:: + column_ctor (string const& type, string const& base) + { + os << type << " (const char* t, const char* c)" << endl + << " : " << base << " (t, c)" + << "{" + << "}"; + } + bool query_columns:: traverse_column (semantics::data_member& m, string const& column, bool) { @@ -276,12 +285,11 @@ namespace relational // os << "struct " << name << "_type_: " << name << "_pointer_type_, " << name << "_column_type_" - << "{" - << name << "_type_ (const char* t, const char* c)" << endl - << " : " << name << "_column_type_ (t, c)" - << "{" - << "}" - << "};"; + << "{"; + + column_ctor (name + "_type_", name + "_column_type_"); + + os << "};"; } os << "static const " << name << "_type_ " << name << ";" diff --git a/odb/relational/common.hxx b/odb/relational/common.hxx index e7400c7..a259604 100644 --- a/odb/relational/common.hxx +++ b/odb/relational/common.hxx @@ -91,6 +91,9 @@ namespace relational } virtual void + column_ctor (string const& type, string const& base); + + virtual void column_ctor_extra (semantics::data_member&) { } diff --git a/odb/relational/mssql/common.cxx b/odb/relational/mssql/common.cxx index 3112c2d..3f5cf74 100644 --- a/odb/relational/mssql/common.cxx +++ b/odb/relational/mssql/common.cxx @@ -551,6 +551,18 @@ namespace relational } virtual void + column_ctor (string const& type, string const& base) + { + os << type << " (const char* t," << endl + << "const char* c," << endl + << "unsigned short p = 0," << endl + << "unsigned short s = 0xFFFF)" << endl + << " : " << base << " (t, c, p, s)" + << "{" + << "}"; + } + + virtual void column_ctor_extra (semantics::data_member& m) { // For some types we need to pass precision and scale. -- cgit v1.1