From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- .../xsd-frontend/semantic-graph/schema.hxx | 281 +++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx (limited to 'libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx') diff --git a/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx b/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx new file mode 100644 index 0000000..10d2f75 --- /dev/null +++ b/libxsd-frontend/xsd-frontend/semantic-graph/schema.hxx @@ -0,0 +1,281 @@ +// file : xsd-frontend/semantic-graph/schema.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX +#define XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX + +#include + +#include +#include + +namespace XSDFrontend +{ + namespace SemanticGraph + { + // + // + class Schema; + + + class Uses: public virtual Edge + { + public: + Schema& + user () const + { + return *user_; + } + + Schema& + schema () const + { + return *schema_; + } + + Path + path () const + { + return path_; + } + + protected: + friend class Bits::Graph; + + Uses (Path const& path) + : path_ (path) + { + } + + Void + set_left_node (Schema& s) + { + user_ = &s; + } + + Void + set_right_node (Schema& s) + { + schema_ = &s; + } + + private: + Path path_; + Schema* user_; + Schema* schema_; + }; + + + // + // + class Implies: public virtual Uses + { + protected: + friend class Bits::Graph; + + Implies (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Sources: public virtual Uses + { + protected: + friend class Bits::Graph; + + Sources (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Includes: public virtual Uses + { + protected: + friend class Bits::Graph; + + Includes (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Imports: public virtual Uses + { + protected: + friend class Bits::Graph; + + Imports (Path const& path) + : Uses (path) + { + } + }; + + + // + // + class Schema: public virtual Scope, + private Bits::Graph, + public NonCopyable + { + typedef + Cult::Containers::Vector + UsesList; + + typedef + Cult::Containers::Vector + UsedList; + + public: + Schema (Path const& file, UnsignedLong line, UnsignedLong column) + : SemanticGraph::Node (file, line, column) + { + } + + public: + typedef + Bits::PointerIterator + UsesIterator; + + UsesIterator + uses_begin () const + { + return uses_.begin (); + } + + UsesIterator + uses_end () const + { + return uses_.end (); + } + + typedef + Bits::PointerIterator + UsedIterator; + + UsedIterator + used_begin () const + { + return used_.begin (); + } + + UsedIterator + used_end () const + { + return used_.end (); + } + + Boolean + used_p () const + { + return used_begin () != used_end (); + } + + virtual NamesIteratorPair + find (Name const& name) const; + + public: + using Bits::Graph::new_edge; + using Bits::Graph::reset_left_node; + using Bits::Graph::reset_right_node; + using Bits::Graph::add_edge_left; + using Bits::Graph::add_edge_right; + using Bits::Graph::delete_node; + using Bits::Graph::delete_edge; + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column) + { + return graph ().new_node (file, line, column); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0) + { + return graph ().new_node (file, line, column, a0); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0, A1 const& a1) + { + return graph ().new_node (file, line, column, a0, a1); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0, A1 const& a1, A2 const& a2) + { + return graph ().new_node (file, line, column, a0, a1, a2); + } + + template + T& + new_node (Path const& file, UnsignedLong line, UnsignedLong column, + A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) + { + return graph ().new_node (file, line, column, a0, a1, a2, a3); + } + + protected: + //@@ gcc bug #21146 + // + friend class Bits::Graph; + + using Scope::add_edge_left; + using Node::add_edge_right; + + Void + add_edge_left (Uses& e) + { + uses_.push_back (&e); + } + + Void + add_edge_right (Uses& e) + { + used_.push_back (&e); + } + + private: + Bits::Graph& + graph () + { + return *this; + } + + private: + UsesList uses_; + UsedList used_; + + private: + typedef Cult::Containers::Set SchemaSet; + + Void + find_ (Name const& name, NamesList&, SchemaSet&) const; + + mutable NamesList names_; + mutable SchemaSet schemas_; + }; + } +} + +#endif // XSD_FRONTEND_SEMANTIC_GRAPH_SCHEMA_HXX -- cgit v1.2.3