aboutsummaryrefslogtreecommitdiff
path: root/odb/context.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/context.hxx')
-rw-r--r--odb/context.hxx102
1 files changed, 65 insertions, 37 deletions
diff --git a/odb/context.hxx b/odb/context.hxx
index 84e9f70..54f6832 100644
--- a/odb/context.hxx
+++ b/odb/context.hxx
@@ -9,11 +9,13 @@
#include <map>
#include <set>
#include <stack>
+#include <vector>
#include <string>
#include <ostream>
#include <cstddef> // std::size_t
#include <iostream>
+#include <cutl/re.hxx>
#include <cutl/shared-ptr.hxx>
#include <odb/options.hxx>
@@ -23,6 +25,15 @@
using std::endl;
using std::cerr;
+// Regex.
+//
+using cutl::re::regex;
+using cutl::re::regexsub;
+
+typedef std::vector<regexsub> regex_mapping;
+
+//
+//
class generation_failed {};
// Keep this enum synchronized with the one in libodb/odb/pointer-traits.hxx.
@@ -51,6 +62,7 @@ class context
public:
typedef std::size_t size_t;
typedef std::string string;
+ typedef std::vector<string> strings;
typedef std::ostream ostream;
typedef ::options options_type;
@@ -316,6 +328,19 @@ public:
bool
has_a (semantics::type&, unsigned short flags);
+public:
+ // Process include path by adding the prefix, putting it through
+ // the include regex list, and adding opening and closing include
+ // characters ("" or <>) if necessary. The prefix argument indicates
+ // whether the include prefix specified with the --include-prefix
+ // option should be added. The open argument can be used to specify
+ // the opening character. It can have three values: ", <, or \0. In
+ // case of \0, the character is determined based on the value of the
+ // --include-with-bracket option.
+ //
+ string
+ process_include_path (string const&, bool prefix = true, char open = '\0');
+
// Diverge output.
//
public:
@@ -350,8 +375,45 @@ private:
return c.get<X> (key);
}
+public:
+ typedef std::set<string> keyword_set_type;
+
+ struct db_type_type
+ {
+ db_type_type () {}
+ db_type_type (string const& t, string const& it)
+ : type (t), id_type (it)
+ {
+ }
+
+ string type;
+ string id_type;
+ };
+ typedef std::map<string, db_type_type> type_map_type;
+
protected:
- struct data;
+ struct data
+ {
+ virtual
+ ~data () {}
+ data (std::ostream& os)
+ : os_ (os.rdbuf ()), top_object_ (0), object_ (0)
+ {
+ }
+
+ public:
+ std::ostream os_;
+ std::stack<std::streambuf*> os_stack_;
+
+ semantics::class_* top_object_;
+ semantics::class_* object_;
+
+ keyword_set_type keyword_set_;
+ type_map_type type_map_;
+
+ regex_mapping include_regex_;
+ };
+
typedef cutl::shared_ptr<data> data_ptr;
data_ptr data_;
@@ -361,9 +423,10 @@ public:
options_type const& options;
database const db;
- typedef std::set<string> keyword_set_type;
keyword_set_type const& keyword_set;
+ regex_mapping const& include_regex;
+
bool embedded_schema;
// Outermost object currently being traversed.
@@ -375,20 +438,6 @@ public:
//
semantics::class_*& object;
- struct db_type_type
- {
- db_type_type () {}
- db_type_type (string const& t, string const& it)
- : type (t), id_type (it)
- {
- }
-
- string type;
- string id_type;
- };
-
- typedef std::map<string, db_type_type> type_map_type;
-
// Per-database customizable functionality.
//
protected:
@@ -420,27 +469,6 @@ protected:
semantics::context&,
column_type_flags);
-protected:
- struct data
- {
- virtual
- ~data () {}
- data (std::ostream& os)
- : os_ (os.rdbuf ()), top_object_ (0), object_ (0)
- {
- }
-
- public:
- std::ostream os_;
- std::stack<std::streambuf*> os_stack_;
-
- semantics::class_* top_object_;
- semantics::class_* object_;
-
- keyword_set_type keyword_set_;
- type_map_type type_map_;
- };
-
public:
typedef context root_context;