diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-26 12:43:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-01-26 12:43:16 +0200 |
commit | af12ffe836de09ec84f666effa4df347eeb07a43 (patch) | |
tree | dc0aec9f8fee545c84be098414772cf2b277c30d /odb/semantics/relational/name.cxx | |
parent | c1d2ec5bbd5969332f3278f39d2a7a8f0abc0493 (diff) |
Implement support for database schema
New pragma qualifier: namespace. New pragma specifier: schema. The table
specifier was extended to accept a schema prefix. New option: --default-
schema. The common/schema test was extended to cover the new functionality.
Diffstat (limited to 'odb/semantics/relational/name.cxx')
-rw-r--r-- | odb/semantics/relational/name.cxx | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/odb/semantics/relational/name.cxx b/odb/semantics/relational/name.cxx new file mode 100644 index 0000000..3cfd763 --- /dev/null +++ b/odb/semantics/relational/name.cxx @@ -0,0 +1,95 @@ +// file : odb/semantics/relational/name.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v3; see accompanying LICENSE file + +#include <ostream> +#include <istream> + +#include <odb/semantics/relational/name.hxx> + +using namespace std; + +namespace semantics +{ + namespace relational + { + string qname:: + string () const + { + std::string r; + + bool f (true); + for (iterator i (begin ()); i < end (); ++i) + { + if (i->empty ()) + continue; + + if (f) + f = false; + else + r += '.'; + + r += *i; + } + + return r; + } + + ostream& + operator<< (ostream& os, qname const& n) + { + bool f (true); + for (qname::iterator i (n.begin ()); i < n.end (); ++i) + { + if (i->empty ()) + continue; + + if (f) + f = false; + else + os << '.'; + + os << *i; + } + + return os; + } + + istream& + operator>> (istream& is, qname& n) + { + n.clear (); + + string s; + is >> s; + + if (!is.fail ()) + { + string::size_type p (string::npos); + + for (size_t i (0); i < s.size (); ++i) + { + char c (s[i]); + + if (c == '.') + { + if (p == string::npos) + n.append (string (s, 0, i)); + else + n.append (string (s, p + 1, i - p - 1)); + + p = i; + } + } + + if (p == string::npos) + n.append (s); + else + n.append (string (s, p + 1, string::npos)); + } + + return is; + } + } +} |