diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-26 17:18:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-26 17:18:12 +0200 |
commit | 6692558ba588c76f5e61eb7ed9a1040d36cb9ed7 (patch) | |
tree | 6f7a29e911713829583bc573e938591383f8486c /odb/semantics/relational/name.cxx | |
parent | 84cb9f184bc24ef7151ab9931b46311b03219b14 (diff) |
Add support for extra database info in primary key
Use that to handle Oracle sequence name and SQLite lax auto ids.
Diffstat (limited to 'odb/semantics/relational/name.cxx')
-rw-r--r-- | odb/semantics/relational/name.cxx | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/odb/semantics/relational/name.cxx b/odb/semantics/relational/name.cxx index 861bac2..8c1af33 100644 --- a/odb/semantics/relational/name.cxx +++ b/odb/semantics/relational/name.cxx @@ -35,58 +35,54 @@ namespace semantics return r; } - ostream& - operator<< (ostream& os, qname const& n) + qname qname:: + from_string (std::string const& s) { - bool f (true); - for (qname::iterator i (n.begin ()); i < n.end (); ++i) + using std::string; + + qname n; + + string::size_type p (string::npos); + + for (size_t i (0); i < s.size (); ++i) { - if (i->empty ()) - continue; + char c (s[i]); - if (f) - f = false; - else - os << '.'; + if (c == '.') + { + if (p == string::npos) + n.append (string (s, 0, i)); + else + n.append (string (s, p + 1, i - p - 1)); - os << *i; + p = i; + } } - return os; + if (p == string::npos) + n.append (s); + else + n.append (string (s, p + 1, string::npos)); + + return n; + } + + ostream& + operator<< (ostream& os, qname const& n) + { + return os << n.string (); } 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)); - } + n = qname::from_string (s); + else + n.clear (); return is; } |