summaryrefslogtreecommitdiff
path: root/odb/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:29:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:29:02 +0200
commitbb76e9388009ed0bb2512034f8cd48a7d19aabb3 (patch)
tree0b43ebff1c36a35bf7cf66c670f04707d4334e38 /odb/context.cxx
parent633f9c5ac574750799efdfe5d1eb31db40a267da (diff)
Next chunk of functionality
Diffstat (limited to 'odb/context.cxx')
-rw-r--r--odb/context.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/odb/context.cxx b/odb/context.cxx
index c90086e..33aa73d 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -114,6 +114,53 @@ context (context& c)
}
string context::
+table_name (semantics::type& t) const
+{
+ if (t.count ("table"))
+ return t.get<string> ("table");
+ else
+ return t.name ();
+}
+
+string context::
+column_name (semantics::data_member& m) const
+{
+ if (m.count ("column"))
+ return m.get<string> ("column");
+ else
+ {
+ string s (m.name ());
+ size_t n (s.size ());
+
+ // Do basic processing: remove trailing and leading underscores
+ // as well as the 'm_' prefix.
+ //
+ // @@ What if the resulting names conflict?
+ //
+ size_t b (0), e (n - 1);
+
+ if (n > 2 && s[0] == 'm' && s[1] == '_')
+ b += 2;
+
+ for (; b <= e && s[b] == '_'; b++) ;
+ for (; e >= b && s[e] == '_'; e--) ;
+
+ return b > e ? s : string (s, b, e - b + 1);
+ }
+}
+
+string context::
+db_type (semantics::data_member& m) const
+{
+ if (m.count ("type"))
+ return m.get<string> ("type");
+ else
+ {
+ return "INT";
+ }
+}
+
+string context::
escape (string const& name) const
{
typedef string::size_type size;