diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-10 17:54:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-05-10 17:54:18 +0200 |
commit | 443293aaf09eca7c3b88d621d056c4effee2c248 (patch) | |
tree | a35c7b2354295b5b73462c0806e04e2deef58171 /cli/semantics/class.hxx | |
parent | 4f9022f24c4591391637121c7274d9855b37bd93 (diff) |
Implement option class inheritance
For now multiple, non-virtual inheritance is supported. An option class
can now also be declared abstract using the class c = 0 {...}; syntax.
New option, --exclude-base, controls whether base class information is
present in usage and documentation.
Diffstat (limited to 'cli/semantics/class.hxx')
-rw-r--r-- | cli/semantics/class.hxx | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/cli/semantics/class.hxx b/cli/semantics/class.hxx index be0b9f9..f5f12c8 100644 --- a/cli/semantics/class.hxx +++ b/cli/semantics/class.hxx @@ -6,17 +6,101 @@ #ifndef CLI_SEMANTICS_CLASS_HXX #define CLI_SEMANTICS_CLASS_HXX +#include <vector> + #include <semantics/elements.hxx> namespace semantics { + class class_; + + class inherits: public edge + { + public: + class_& + base () const + { + return *base_; + } + + class_& + derived () const + { + return *derived_; + } + + public: + void + set_left_node (class_& n) + { + derived_ = &n; + } + + void + set_right_node (class_& n) + { + base_ = &n; + } + + protected: + class_* base_; + class_* derived_; + }; + class class_: public scope { + private: + typedef std::vector<inherits*> inherits_list; + + public: + bool + abstract () const + { + return abstract_; + } + + void + abstract (bool a) + { + abstract_ = a; + } + + public: + typedef pointer_iterator<inherits_list::const_iterator> inherits_iterator; + + inherits_iterator + inherits_begin () const + { + return inherits_.begin (); + } + + inherits_iterator + inherits_end () const + { + return inherits_.end (); + } + public: class_ (path const& file, size_t line, size_t column) - : node (file, line, column) + : node (file, line, column), abstract_ (false) + { + } + + void + add_edge_left (inherits& e) { + inherits_.push_back (&e); } + + void + add_edge_right (inherits&) {} + + using scope::add_edge_left; + using scope::add_edge_right; + + private: + bool abstract_; + inherits_list inherits_; }; } |