summaryrefslogtreecommitdiff
path: root/odb/odb/semantics/relational/name.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-01-22 15:58:08 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-01-24 17:02:47 +0300
commit823026b58211a4166de06ac243d978dcb9930271 (patch)
tree97b43039cb769f8bee410e8536f9f945f2825153 /odb/odb/semantics/relational/name.cxx
parentb56b9c6796d8853758f0f5967488260d61b788e2 (diff)
Turn odb repository into muti-package repository
Also remove the autoconf/make-based build system.
Diffstat (limited to 'odb/odb/semantics/relational/name.cxx')
-rw-r--r--odb/odb/semantics/relational/name.cxx89
1 files changed, 89 insertions, 0 deletions
diff --git a/odb/odb/semantics/relational/name.cxx b/odb/odb/semantics/relational/name.cxx
new file mode 100644
index 0000000..6eb2e16
--- /dev/null
+++ b/odb/odb/semantics/relational/name.cxx
@@ -0,0 +1,89 @@
+// file : odb/semantics/relational/name.cxx
+// 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;
+ }
+
+ qname qname::
+ from_string (std::string const& s)
+ {
+ using std::string;
+
+ qname n;
+
+ 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 n;
+ }
+
+ ostream&
+ operator<< (ostream& os, qname const& n)
+ {
+ return os << n.string ();
+ }
+
+ istream&
+ operator>> (istream& is, qname& n)
+ {
+ string s;
+ is >> s;
+
+ if (!is.fail ())
+ n = qname::from_string (s);
+ else
+ n.clear ();
+
+ return is;
+ }
+ }
+}