aboutsummaryrefslogtreecommitdiff
path: root/odb/pragma.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-04-26 11:29:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-04-26 11:29:05 +0200
commit8e046e3ea7e88f872205c2b65cb7f9b86aaabd93 (patch)
treeaba1ae331454eb1e0cf9525faf8a084d3652bda0 /odb/pragma.cxx
parent6c88333c2e0232aed9e0b3c9077306f09e36c65c (diff)
Make session optional
Diffstat (limited to 'odb/pragma.cxx')
-rw-r--r--odb/pragma.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/odb/pragma.cxx b/odb/pragma.cxx
index 698551a..e2dc4cc 100644
--- a/odb/pragma.cxx
+++ b/odb/pragma.cxx
@@ -493,6 +493,17 @@ check_spec_decl_type (tree d,
return false;
}
}
+ else if (p == "session")
+ {
+ // Session can be used only for namespaces and objects.
+ //
+ if (tc != NAMESPACE_DECL && !CLASS_TYPE_P (d))
+ {
+ error (l) << "name '" << name << "' in db pragma " << p << " does "
+ << "not refer to a namespace or class" << endl;
+ return false;
+ }
+ }
else if (p == "schema")
{
// For now schema can be used only for namespaces and objects.
@@ -727,6 +738,42 @@ handle_pragma (cpp_reader* reader,
tt = pragma_lex (&t);
}
+ else if (p == "session")
+ {
+ // session
+ // session (true|false)
+ //
+
+ // Make sure we've got the correct declaration type.
+ //
+ if (decl != 0 && !check_spec_decl_type (decl, decl_name, p, loc))
+ return;
+
+ tt = pragma_lex (&t);
+
+ if (tt == CPP_OPEN_PAREN)
+ {
+ tt = pragma_lex (&t);
+
+ string s;
+ if (tt != CPP_NAME ||
+ ((s = IDENTIFIER_POINTER (t)) != "true" && s != "false"))
+ {
+ error () << "true or false expected in db pragma " << p << endl;
+ return;
+ }
+
+ tt = pragma_lex (&t);
+ if (tt != CPP_CLOSE_PAREN)
+ {
+ error () << "')' expected at the end of db pragma " << p << endl;
+ return;
+ }
+
+ val = (s == "true");
+ tt = pragma_lex (&t);
+ }
+ }
else if (p == "schema")
{
// schema (<name>)