From 2bc006daa59995085626b3e9c0754823bf9d95a5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 29 Jun 2011 14:08:29 +0200 Subject: Add --include-regex and --include-regex-trace options This requires libcutl update. --- odb/context.hxx | 102 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 37 deletions(-) (limited to 'odb/context.hxx') 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 #include #include +#include #include #include #include // std::size_t #include +#include #include #include @@ -23,6 +25,15 @@ using std::endl; using std::cerr; +// Regex. +// +using cutl::re::regex; +using cutl::re::regexsub; + +typedef std::vector 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 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 (key); } +public: + typedef std::set 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 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 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_ptr; data_ptr data_; @@ -361,9 +423,10 @@ public: options_type const& options; database const db; - typedef std::set 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 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 os_stack_; - - semantics::class_* top_object_; - semantics::class_* object_; - - keyword_set_type keyword_set_; - type_map_type type_map_; - }; - public: typedef context root_context; -- cgit v1.1