From de8859f33a7296b485bbd5924455bb09bb087c53 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 7 Jun 2011 18:39:14 +0200 Subject: Add pgsql sql_type and sql type parsing implementation --- odb/relational/pgsql/context.hxx | 127 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 odb/relational/pgsql/context.hxx (limited to 'odb/relational/pgsql/context.hxx') diff --git a/odb/relational/pgsql/context.hxx b/odb/relational/pgsql/context.hxx new file mode 100644 index 0000000..35951bc --- /dev/null +++ b/odb/relational/pgsql/context.hxx @@ -0,0 +1,127 @@ +// file : odb/relational/pgsql/context.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v3; see accompanying LICENSE file + +#ifndef ODB_RELATIONAL_PGSQL_CONTEXT_HXX +#define ODB_RELATIONAL_PGSQL_CONTEXT_HXX + +#include + +namespace relational +{ + namespace pgsql + { + struct sql_type + { + // Keep the order in each block of types. + // + enum core_type + { + // Integral types. + // + BOOLEAN, + SMALLINT, + INTEGER, + BIGINT, + + // Float types. + // + FLOAT, + REAL, + DOUBLE, + DECIMAL, + + // Data-time types. + // + DATE, + TIME, + TIMETZ, + TIMESTAMP, + TIMESTAMPTZ, + + // String and binary types. + // + CHAR, + VARCHAR, + TEXT, + BYTEA, + BIT, + VARBIT, + + // Other types. + // + UUID, + + // Invalid type. + // + invalid + }; + + sql_type () : type (invalid), range (false) {} + + core_type type; + bool range; + + // VARBIT maximum length is 2^31 - 1 bit. + // String types can hold a maximum of 1GB of data. + // + unsigned int range_value; + }; + + class context: public virtual relational::context + { + // public: + // sql_type const& + // column_sql_type (semantics::data_member&, + // string const& key_prefix = string ()); + + // protected: + // virtual bool + // grow_impl (semantics::class_&); + + // virtual bool + // grow_impl (semantics::data_member&); + + // virtual bool + // grow_impl (semantics::data_member&, semantics::type&, string const&); + + // protected: + // virtual string + // quote_id_impl (string const&) const; + + // protected: + // virtual string + // database_type_impl (semantics::type&, + // semantics::names*, + // semantics::context&, + // column_type_flags); + + public: + virtual + ~context (); + + context (); + + // context (std::ostream&, semantics::unit&, options_type const&); + + static context& + current () + { + return *current_; + } + + private: + static context* current_; + + private: + struct data: base_context::data + { + data (std::ostream& os): base_context::data (os) {} + }; + data* data_; + }; + } +} + +#endif // ODB_RELATIONAL_PGSQL_CONTEXT_HXX -- cgit v1.1