diff options
Diffstat (limited to 'DAnCE/tools/Config_Handlers/XSCRT')
18 files changed, 0 insertions, 2648 deletions
diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Elements.hpp b/DAnCE/tools/Config_Handlers/XSCRT/Elements.hpp deleted file mode 100644 index 0c8b6979282..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Elements.hpp +++ /dev/null @@ -1,572 +0,0 @@ -// file : XSCRT/Elements.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_ELEMENTS_HPP -#define XSCRT_ELEMENTS_HPP - -#include <map> -#include <string> -#include <sstream> -#include "ace/ace_wchar.h" -// #include <iostream> //@@ tmp - -#include <XSCRT/Parser.hpp> -#include "ace/Refcounted_Auto_Ptr.h" - -namespace XSCRT -{ - struct IdentityProvider - { - virtual bool - before (IdentityProvider const&) const = 0; - - virtual ~IdentityProvider (void) - { - - } - }; - - class Type - { - public: - - virtual ~Type (void) - { - } - - protected: - Type (void) - : container_ (0) - { - } - - template <typename C> - Type (XML::Element<C> const&) - : container_ (0) - { - } - - template <typename C> - Type (XML::Attribute<C> const&) - : container_ (0) - { - } - - Type (Type const&) - : container_ (0) - { - } - - Type& - operator= (Type const&) - { - //@@ I don't need this. - //if (map_.get ()) map_->clear (); // Flush the map. - return *this; - } - - public: - Type const* - container () const - { - return container_ ? container_ : this; - } - - Type* - container () - { - return container_ ? container_ : this; - } - - - Type const* - root () const - { - Type const* r = container (); - - //@@ VC6 can't handle this inside the loop. - // - Type const* c = r->container (); - - for (; c != r; c = c->container ()) r = c; - - return r; - } - - Type* - root () - { - Type* r = container (); - - for (Type* c = r->container (); c != r; c = c->container ()) r = c; - - return r; - } - - //@@ - //protected: - - public: - virtual void - container (Type* c) - { - if (container_ == c) return; - - // Revoke registrations from our old container. - // - if (container_ != 0 && map_.get ()) - { - for (Map_::iterator i (map_->begin ()); i != map_->end (); ++i) - { - //std::wcerr << "revoking " << i->second - // << " to " << container_ << std::endl; - - container_->unregister_id (*(i->first)); - } - } - - // Copy registrations to our new container. - // - if (c != 0 && map_.get ()) - { - for (Map_::iterator i (map_->begin ()); i != map_->end (); ++i) - { - //std::wcerr << "copying " << i->second - // << " to " << c << std::endl; - - c->register_id (*(i->first), i->second); - } - } - - container_ = c; - } - - //@@ - //protected: - - public: - void - register_id (IdentityProvider const& id, Type* t) - { - if (map_.get () == 0) - { - map_ = std::auto_ptr<Map_> (new Map_); - } - - if (!map_->insert ( - std::pair<IdentityProvider const*, Type*> (&id, t)).second) - { - throw 1; - } - - if (container () != this) container ()->register_id (id, t); - } - - void - unregister_id (IdentityProvider const& id) - { - if (map_.get ()) - { - Map_::iterator it (map_->find (&id)); - - if (it != map_->end ()) - { - map_->erase (it); - - if (container () != this) container ()->unregister_id (id); - - return; - } - } - - throw 1; - } - - Type* - lookup_id (IdentityProvider const& id) const - { - if (map_.get ()) - { - Map_::const_iterator it (map_->find (&id)); - - if (it != map_->end ()) - { - return it->second; - } - } - - return 0; - } - - //Get and set methods for the idref_map_ data member - Type* get_idref (const char* name) - { - std::basic_string<ACE_TCHAR> name_string (ACE_TEXT_CHAR_TO_TCHAR(name)); - std::map<std::basic_string<ACE_TCHAR>, XSCRT::Type*>::iterator i = - this->idref_map_.find(name_string); - if (i != idref_map_.end()) - { - return i->second; - } - else - { - return 0; - } - } - - Type* get_idref (const wchar_t *name) - { - std::basic_string<ACE_TCHAR> name_string (ACE_TEXT_WCHAR_TO_TCHAR(name)); - std::map<std::basic_string<ACE_TCHAR>, XSCRT::Type*>::iterator i = - this->idref_map_.find(name_string); - if (i != idref_map_.end()) - { - return i->second; - } - else - { - return 0; - } - } - - - void set_idref (std::basic_string<ACE_TCHAR> name, Type* new_idref) - { - this->idref_map_.insert(std::pair<std::basic_string<ACE_TCHAR>,Type*>(name, new_idref)); - return; - } - - private: - - //Data member to handle unbounded IDREF attributes and elements - std::map<std::basic_string<ACE_TCHAR>, XSCRT::Type*> idref_map_; - - Type* container_; - - struct IdentityComparator - { - bool operator () (IdentityProvider const* x, - IdentityProvider const* y) const - { - return x->before (*y); - } - }; - - typedef - std::map<IdentityProvider const*, Type*, IdentityComparator> - Map_; - - std::auto_ptr<Map_> map_; - }; - - // Fundamental types template. - // - // - template <typename X> - class FundamentalType : public Type - { - public: - // Trait for marshaling a FundamentalType X - typedef X CDR_Type__; -#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x620) - typedef ACE_Refcounted_Auto_Ptr < FundamentalType, ACE_Null_Mutex > _ptr; -#endif /* !__BORLANDC__ */ - - FundamentalType () - { - } - - template<typename C> - FundamentalType (XML::Element<C> const& e) - { - std::basic_stringstream<C> s; - s << e.value (); - s >> x_; - } - - template<typename C> - FundamentalType (XML::Attribute<C> const& a) - { - std::basic_stringstream<C> s; - s << a.value (); - s >> x_; - } - - FundamentalType (X const& x) - : x_ (x) - { - } - - FundamentalType& - operator= (X const& x) - { - x_ = x; - return *this; - } - - public: - operator X const& () const - { - return x_; - } - - operator X& () - { - return x_; - } - - protected: - X x_; - }; - -#if !((defined (__GNUC__) && (__GNUC__ == 3 && (__GNUC_MINOR__ < 3))) || \ - (defined (__BORLANDC__) && (__BORLANDC__ < 0x620)) || \ - (defined (__SUNPRO_CC) && (__SUNPRO_CC <= 0x5100))) - - // Stuff for normal compilers. - // - - // Specialization for `signed char' - // - // - template<> - template<typename C> - inline - FundamentalType<signed char>:: - FundamentalType (XML::Element<C> const& e) - { - std::basic_stringstream<C> s; - s << e.value (); - - short t; - s >> t; - - x_ = static_cast<signed char> (t); - } - - template<> - template<typename C> - inline - FundamentalType<signed char>:: - FundamentalType (XML::Attribute<C> const& a) - { - std::basic_stringstream<C> s; - s << a.value (); - - short t; - s >> t; - - x_ = static_cast<signed char> (t); - } - - // Specialization for `unsigned char' - // - // - template<> - template<typename C> - inline - FundamentalType<unsigned char>:: - FundamentalType (XML::Element<C> const& e) - { - std::basic_stringstream<C> s; - s << e.value (); - - unsigned short t; - s >> t; - - x_ = static_cast<unsigned char> (t); - } - - template<> - template<typename C> - inline - FundamentalType<unsigned char>:: - FundamentalType (XML::Attribute<C> const& a) - { - std::basic_stringstream<C> s; - s << a.value (); - - unsigned short t; - s >> t; - - x_ = static_cast<unsigned char> (t); - } - -#else - - // Stuff for broken VC6 & gcc < 3.3. Don't like what you see - use better - // compiler! - // - - // Specialization for signed char. - // - template <> - class FundamentalType<signed char> : public Type - { - public: - FundamentalType () - { - } - - template<typename C> - FundamentalType (XML::Element<C> const& e) - { - std::basic_stringstream<C> s; - s << e.value (); - - short t; - s >> t; - - x_ = static_cast<signed char> (t); - } - - template<typename C> - FundamentalType (XML::Attribute<C> const& a) - { - std::basic_stringstream<C> s; - s << a.value (); - - short t; - s >> t; - - x_ = static_cast<signed char> (t); - } - - FundamentalType (signed char const& x) - : x_ (x) - { - } - - FundamentalType& - operator= (signed char const& x) - { - x_ = x; - return *this; - } - - public: - operator signed char const& () const - { - return x_; - } - - operator signed char& () - { - return x_; - } - - protected: - signed char x_; - }; - - // Specialization for unsigned char. - // - template <> - class FundamentalType<unsigned char> : public Type - { - public: - FundamentalType () - { - } - - template<typename C> - FundamentalType (XML::Element<C> const& e) - { - std::basic_stringstream<C> s; - s << e.value (); - - unsigned short t; - s >> t; - - x_ = static_cast<unsigned char> (t); - } - - template<typename C> - FundamentalType (XML::Attribute<C> const& a) - { - std::basic_stringstream<C> s; - s << a.value (); - - unsigned short t; - s >> t; - - x_ = static_cast<unsigned char> (t); - } - - FundamentalType (unsigned char const& x) - : x_ (x) - { - } - - FundamentalType& - operator= (unsigned char const& x) - { - x_ = x; - return *this; - } - - public: - operator unsigned char const& () const - { - return x_; - } - - operator unsigned char& () - { - return x_; - } - - protected: - unsigned char x_; - }; - -#endif - - - // Specialization for bool. - // - // - - template<> - template<> - inline - FundamentalType<bool>:: - FundamentalType (XML::Element<char> const& e) - { - x_ = (e.value () == "true") || (e.value () == "1"); - } - - template<> - template<> - inline - FundamentalType<bool>:: - FundamentalType (XML::Element<wchar_t> const& e) - { - x_ = (e.value () == L"true") || (e.value () == L"1"); - } - - template<> - template<> - inline - FundamentalType<bool>:: - FundamentalType (XML::Attribute<char> const& a) - { - x_ = (a.value () == "true") || (a.value () == "1"); - } - - template<> - template<> - inline - FundamentalType<bool>:: - FundamentalType (XML::Attribute<wchar_t> const& a) - { - x_ = (a.value () == L"true") || (a.value () == L"1"); - } - -} - -#include <XSCRT/Elements.ipp> -#include <XSCRT/Elements.tpp> - -#endif // XSCRT_ELEMENTS_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Elements.ipp b/DAnCE/tools/Config_Handlers/XSCRT/Elements.ipp deleted file mode 100644 index 414f03eb031..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Elements.ipp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSC/Elements.ipp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSC -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Elements.tpp b/DAnCE/tools/Config_Handlers/XSCRT/Elements.tpp deleted file mode 100644 index 7539a36d75f..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Elements.tpp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSC/Elements.tpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSC -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.hpp b/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.hpp deleted file mode 100644 index e2ab4b64956..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.hpp +++ /dev/null @@ -1,182 +0,0 @@ -// file : XSCRT/ExtendedTypeInfo.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_EXTENDED_TYPE_INFO_HPP -#define XSCRT_EXTENDED_TYPE_INFO_HPP - -#include <map> -#include <vector> -#include <typeinfo> - -namespace XSCRT -{ - // - // - // - class TypeId - { - public: - template<typename T> - TypeId (T const& t); - - TypeId (std::type_info const& tid); - - public: - bool - operator == (TypeId const& other) const; - - bool - operator != (TypeId const& other) const; - - bool - operator < (TypeId const& other) const; - - /* - friend std::ostream& - operator << (std::ostream& os, TypeId const& t); - */ - - public: - char const* - name () const - { - return tid_->name (); - } - - private: - std::type_info const* tid_; - }; - - - // - // - // - class ExtendedTypeInfo - { - public: - - // - // - // - struct Access - { - enum Value - { - private_, - protected_, - public_ - }; - }; - - - // - // - // - class BaseInfo - { - public: - BaseInfo (Access::Value access, bool virtual_base, TypeId const& tid); - - public: - ExtendedTypeInfo const& - type_info () const; - - Access::Value - access () const; - - bool - virtual_base () const; - - private: - TypeId tid_; - mutable ExtendedTypeInfo const* ti_; - bool virtual_base_; - Access::Value access_; - }; - - private: - typedef - std::vector<BaseInfo> - BaseInfoList; - - public: - typedef - BaseInfoList::const_iterator - BaseIterator; - - public: - ExtendedTypeInfo (TypeId const& tid); - - TypeId - type_id () const; - - BaseIterator - begin_base () const; - - BaseIterator - end_base () const; - - void - add_base (Access::Value access, bool virtual_base, TypeId const& tid); - - private: - TypeId tid_; - BaseInfoList base_; - }; - - typedef - std::map<TypeId, ExtendedTypeInfo> - ExtendedTypeInfoMap; - - - ExtendedTypeInfoMap& - extended_type_info_map (); - - - class NotAvailable {}; - - - template<typename T> - ExtendedTypeInfo const& - extended_type_info (T const& t) - { - return extended_type_info (typeid (t)); - } - - template<typename T> - ExtendedTypeInfo const& - extended_type_info () - { - return extended_type_info (typeid (T)); - } - - //@@ Had to use function template specialization because VC6 - // cannot handle simply overloaded functions. - // - - template <> - inline - ExtendedTypeInfo const& - extended_type_info<TypeId> (TypeId const& tid) - { - ExtendedTypeInfoMap::const_iterator i ( - extended_type_info_map ().find (tid)); - - if (i == extended_type_info_map ().end ()) throw NotAvailable (); - - return i->second; - } - - template <> - inline - ExtendedTypeInfo const& - extended_type_info<std::type_info> (std::type_info const& tid) - { - return extended_type_info (TypeId (tid)); - } -} - -#include <XSCRT/ExtendedTypeInfo.ipp> - -#endif // XSCRT_EXTENDED_TYPE_INFO_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.ipp b/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.ipp deleted file mode 100644 index 6c4fba2cf88..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/ExtendedTypeInfo.ipp +++ /dev/null @@ -1,141 +0,0 @@ -// file : XSCRT/ExtendedTypeInfo.ipp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - - -/* - * @@HACK: Visual Studio. - * I think the return value for operator== for type_info - * in VC7 (perhaps others) is int when is should be bool. - * This causes a warning about converting the return value from - * int to bool. - */ -#ifdef _MSC_VER -# pragma warning( disable: 4800 ) -#endif - -namespace XSCRT -{ - // TypeId - // - // - inline - TypeId:: - TypeId (std::type_info const& tid) - : tid_ (&tid) - { - } - - inline - bool TypeId:: - operator == (TypeId const& other) const - { - return *tid_ == *other.tid_; - } - - inline - bool TypeId:: - operator != (TypeId const& other) const - { - return *tid_ != *other.tid_; - } - - inline - bool TypeId:: - operator < (TypeId const& other) const - { - return tid_->before (*other.tid_); - } - - - // ExtendedTypeInfo::BaseInfo - // - // - - inline - ExtendedTypeInfo::BaseInfo:: - BaseInfo (Access::Value access, bool virtual_base, TypeId const& tid) - : tid_ (tid), - ti_ (0), - virtual_base_ (virtual_base), - access_ (access) - { - } - - inline - ExtendedTypeInfo const& ExtendedTypeInfo::BaseInfo:: - type_info () const - { - if (ti_ == 0) ti_ = &(extended_type_info (tid_)); - - return *ti_; - } - - - inline - ExtendedTypeInfo::Access::Value ExtendedTypeInfo::BaseInfo:: - access () const - { - return access_; - } - - inline - bool ExtendedTypeInfo::BaseInfo:: - virtual_base () const - { - return virtual_base_; - } - - - // ExtendedTypeInfo - // - // - inline - ExtendedTypeInfo:: - ExtendedTypeInfo (TypeId const& tid) - : tid_ (tid) - { - } - - inline - TypeId ExtendedTypeInfo:: - type_id () const - { - return tid_; - } - - inline - ExtendedTypeInfo::BaseIterator ExtendedTypeInfo:: - begin_base () const - { - return base_.begin (); - } - - - inline - ExtendedTypeInfo::BaseIterator ExtendedTypeInfo:: - end_base () const - { - return base_.end (); - } - - inline - void ExtendedTypeInfo:: - add_base (Access::Value access, bool virtual_base, TypeId const& tid) - { - base_.push_back (BaseInfo (access, virtual_base, tid)); - } - - // ExtendedTypeInfoMap - // - // - - inline - ExtendedTypeInfoMap& - extended_type_info_map () - { - static ExtendedTypeInfoMap extended_type_info_map_; - - return extended_type_info_map_; - } -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Parser.hpp b/DAnCE/tools/Config_Handlers/XSCRT/Parser.hpp deleted file mode 100644 index 5fa1e827f8d..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Parser.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// file : XSCRT/Parser.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_PARSER_HPP -#define XSCRT_PARSER_HPP - -#include <string> - -#include "XSCRT/XML.hpp" - -namespace XSCRT -{ - template <typename C> - class Parser - { - public: - Parser (XML::Element<C> const& e) - : e_ (e.dom_element ()->getChildNodes ()), ei_ (0), - a_ (e.dom_element ()->getAttributes ()), ai_ (0) - { - } - - bool - more_elements () const - { - return e_->getLength () > ei_; - } - - XML::Element<C> - next_element () - { - return XML::Element<C> (XML::dom_cast <xercesc::DOMElement*> (e_->item (ei_++))); - } - - bool - more_attributes () const - { - return a_->getLength () > ai_; - } - - XML::Attribute<C> - next_attribute () - { - return XML::Attribute<C> ( - XML::dom_cast <xercesc::DOMAttr*> (a_->item (ai_++))); - } - - private: - xercesc::DOMNodeList const* e_; - unsigned long ei_; - - xercesc::DOMNamedNodeMap const* a_; - unsigned long ai_; - - private: - Parser (Parser const&); - - void - operator= (Parser const&); - }; -} - -#include "XSCRT/Parser.ipp" -#include "XSCRT/Parser.tpp" - -#endif // XSCRT_PARSER_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Parser.ipp b/DAnCE/tools/Config_Handlers/XSCRT/Parser.ipp deleted file mode 100644 index f7de09602ae..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Parser.ipp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/Parser.ipp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Parser.tpp b/DAnCE/tools/Config_Handlers/XSCRT/Parser.tpp deleted file mode 100644 index 75b9f48eb1f..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Parser.tpp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/Parser.tpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.hpp b/DAnCE/tools/Config_Handlers/XSCRT/Traversal.hpp deleted file mode 100644 index befd0478295..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.hpp +++ /dev/null @@ -1,266 +0,0 @@ -// file : XSCRT/Traversal.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_TRAVERSAL_HPP -#define XSCRT_TRAVERSAL_HPP - -#include <map> -#include <set> -#include <vector> - -#include "XSCRT/ExtendedTypeInfo.hpp" - -namespace XSCRT -{ - namespace Traversal - { - // - // - // - template<typename B> - class TraverserBase - { - protected: - virtual - ~TraverserBase (); - - //@@ VC6 - public: - virtual void - trampoline (B& n) = 0; - - virtual void - trampoline (B const& n) = 0; - }; - - - // - // - // - template <typename B> - class DispatcherBase - { - public: - virtual - ~DispatcherBase (); - - virtual void - dispatch (B& n); - - virtual void - dispatch (B const& n); - - void - map (TypeId id, TraverserBase<B>& t) - { - //wcerr << "map for " << id.name () << " to " << &t - // << " in " << &traversal_map_ << endl; - - //@@ VC6 - Traversers& traversers = traversal_map_[id]; - traversers.push_back (&t); - } - - public: - typedef - std::vector<TraverserBase<B>*> - Traversers; - - typedef - std::map<TypeId, Traversers> - TraversalMap; - - typedef - typename TraversalMap::const_iterator - Iterator; - - Iterator - begin () const - { - return traversal_map_.begin (); - } - - Iterator - end () const - { - return traversal_map_.end (); - } - - private: - struct TypeInfoComparator - { - bool - operator () (ExtendedTypeInfo const& x, - ExtendedTypeInfo const& y) const - { - return x.type_id () < y.type_id (); - } - }; - - typedef - std::map<ExtendedTypeInfo, unsigned long, TypeInfoComparator> - LevelMap; - - typedef - std::set<ExtendedTypeInfo, TypeInfoComparator> - TypeInfoSet; - - static unsigned long - compute_levels (ExtendedTypeInfo const& ti, - unsigned long cur, - LevelMap& map); - - static void - flatten_tree (ExtendedTypeInfo const& ti, TypeInfoSet& set); - - private: - TraversalMap traversal_map_; - }; - - - // - // - // - template <typename B> - class Dispatcher : public virtual DispatcherBase<B> - { - public: - Dispatcher () - : merge_ (true) - { - } - - void - traverser (DispatcherBase<B>& d) - { - for (typename DispatcherBase<B>::Iterator - i (d.begin ()), end (d.end ()); - i != end; ++i) - { - for (typename DispatcherBase<B>::Traversers::const_iterator - t (i->second.begin ()), end (i->second.end ()); - t != end; ++t) - { - dispatcher_.map (i->first, **t); - } - } - } - - public: - virtual void - dispatch (B& n) - { - merge (); - dispatcher_.dispatch (n); - } - - virtual void - dispatch (B const& n) - { - merge (); - dispatcher_.dispatch (n); - } - - using DispatcherBase<B>::begin; - using DispatcherBase<B>::end; - - private: - void - merge () - { - if (merge_) - { - for (typename DispatcherBase<B>::Iterator - i (begin ()), e (end ()); i != e; ++i) - { - for (typename DispatcherBase<B>::Traversers::const_iterator - t (i->second.begin ()), e (i->second.end ()); t != e; ++t) - { - dispatcher_.map (i->first, **t); - } - } - - merge_ = false; - } - } - - protected: - // DispatcherBase<B>& - // traverser () - // { - // return dispatcher_; - // } - - template <typename X, typename A, typename I> - void - iterate_and_dispatch (I begin, I end, X& x, void (X::*next)(A&), A& a) - { - for (; begin != end;) - { - dispatch (*begin); - - if (++begin != end) (x.*next) (a); - } - } - - private: - bool merge_; - DispatcherBase<B> dispatcher_; - }; - - - - // - // - // - template <typename T, typename B> - struct Traverser : TraverserBase<B>, virtual Dispatcher<B> - { - typedef - T - Type; - - Traverser () - { - DispatcherBase<B>::map (typeid (Type), *this); - } - - virtual void - traverse (Type&) - { - abort (); - } - - virtual void - traverse (Type const&) - { - abort (); - } - - protected: - virtual void - trampoline (B& n) - { - //wcerr << "trampoline for " << &n << " to type " - // << typeid (Type).name () << endl; - - traverse (dynamic_cast<Type&> (n)); - } - - virtual void - trampoline (B const& n) - { - //wcerr << "trampoline for " << &n << " to type " - // << typeid (Type).name () << endl; - - traverse (dynamic_cast<Type const&> (n)); - } - }; - } -} - -#include <XSCRT/Traversal.ipp> -#include <XSCRT/Traversal.tpp> - -#endif // XSCRT_TRAVERSAL_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.ipp b/DAnCE/tools/Config_Handlers/XSCRT/Traversal.ipp deleted file mode 100644 index bc2a462334a..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.ipp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/Traversal.ixx -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.tpp b/DAnCE/tools/Config_Handlers/XSCRT/Traversal.tpp deleted file mode 100644 index 51889c0fb9b..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Traversal.tpp +++ /dev/null @@ -1,195 +0,0 @@ -// file : XSCRT/Traversal.txx -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ - namespace Traversal - { - // TraverserBase - // - // - - template<typename B> - TraverserBase<B>:: - ~TraverserBase () - { - } - - // DispatcherBase - // - // - - template <typename B> - DispatcherBase<B>:: - ~DispatcherBase () - { - } - - //@@ merge after dropping VC6 - // - // - template <typename B> - void DispatcherBase<B>:: - dispatch (B& n) - { - LevelMap levels; - - //@@ VC6 - ExtendedTypeInfo const& ti = extended_type_info (n); - - unsigned long max = compute_levels (ti, 0, levels); - - - //wcerr << "starting dispatch process for " - // << typeid (n).name () << " with " - // << max << " levels" << endl; - - for (unsigned long l = 0; l < max + 1; ++l) - { - TypeInfoSet dispatched; - - for (typename LevelMap::const_iterator - i (levels.begin ()), e (levels.end ()); - i != e; ++i) - { - if (i->second == l) - { - typename TraversalMap::const_iterator v ( - traversal_map_.find (i->first.type_id ())); - - if (v != traversal_map_.end ()) - { - //wcerr << "dispatching traversers for " - // << typeid (n).name () << " as " - // << i->first.type_id ().name () << endl; - - //@@ VC6 - Traversers const& traversers = v->second; - for (typename Traversers::const_iterator - ti (traversers.begin ()), te (traversers.end ()); - ti != te; ++ti) - { - (*ti)->trampoline (n); - } - - flatten_tree (i->first, dispatched); - } - } - } - - // Remove traversed types from the level map. - // - //@@ VC6 - { - for (typename TypeInfoSet::const_iterator i = dispatched.begin (); - i != dispatched.end (); - ++i) - { - levels.erase (*i); - } - } - } - } - - template <typename B> - void DispatcherBase<B>:: - dispatch (B const& n) - { - LevelMap levels; - - //@@ VC6 - ExtendedTypeInfo const& ti = extended_type_info (n); - - unsigned long max = compute_levels (ti, 0, levels); - - - //wcerr << "starting dispatch process for " - // << typeid (n).name () << " with " - // << max << " levels" << endl; - - //wcerr << "using " << &traversal_map_ << " traversal map" << endl; - - for (unsigned long l = 0; l < max + 1; ++l) - { - TypeInfoSet dispatched; - - for (typename LevelMap::const_iterator - i (levels.begin ()), e (levels.end ()); - i != e; ++i) - { - if (i->second == l) - { - typename TraversalMap::const_iterator v ( - traversal_map_.find (i->first.type_id ())); - - if (v != traversal_map_.end ()) - { - //wcerr << "dispatching traversers for " - // << typeid (n).name () << " as " - // << i->first.type_id ().name () << endl; - - //@@ VC6 - Traversers const& traversers = v->second; - for (typename Traversers::const_iterator - ti (traversers.begin ()), te (traversers.end ()); - ti != te; ++ti) - { - (*ti)->trampoline (n); - } - - flatten_tree (i->first, dispatched); - } - } - } - - // Remove traversed types from the level map. - // - //@@ VC6 - { - for (typename TypeInfoSet::const_iterator i = dispatched.begin (); - i != dispatched.end (); - ++i) - { - levels.erase (*i); - } - } - } - } - - template <typename B> - unsigned long DispatcherBase<B>:: - compute_levels (ExtendedTypeInfo const& ti, - unsigned long cur, - LevelMap& map) - { - unsigned long ret = cur; - - if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur; - - for (ExtendedTypeInfo::BaseIterator i = ti.begin_base (); - i != ti.end_base (); - i++) - { - unsigned long t = compute_levels (i->type_info (), cur + 1, map); - if (t > ret) ret = t; - } - - return ret; - } - - template <typename B> - void DispatcherBase<B>:: - flatten_tree (ExtendedTypeInfo const& ti, TypeInfoSet& set) - { - set.insert (ti); - - for (ExtendedTypeInfo::BaseIterator i = ti.begin_base (); - i != ti.end_base (); - i++) - { - flatten_tree (i->type_info (), set); - } - } - } -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Writer.hpp b/DAnCE/tools/Config_Handlers/XSCRT/Writer.hpp deleted file mode 100644 index 6fdd82f6f3e..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Writer.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// file : XSCRT/Writer.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_WRITER_HPP -#define XSCRT_WRITER_HPP - -#include <stack> -#include <string> - -#include "XSCRT/XML.hpp" - -namespace XSCRT -{ - template <typename C> - class Writer - { - public: - Writer (XML::Element<C>& e) - : attr__ (0) - { - push_ (e); - } - - protected: - // This c-tor should never be called. - // - Writer () - { - abort (); - } - - public: - void - push_ (XML::Element<C> const& e) - { - stack_.push (e); - } - - void - pop_ () - { - stack_.pop (); - } - - XML::Element<C>& - top_ () - { - return stack_.top (); - } - - public: - XML::Attribute<C>* - attr_ () - { - return attr__; - } - - void - attr_ (XML::Attribute<C>* a) - { - attr__ = a; - } - - private: - std::stack<XML::Element<C> > stack_; - - XML::Attribute<C>* attr__; - - private: - Writer (Writer const&); - - void - operator= (Writer const&); - }; -} - -#include <XSCRT/Writer.ipp> -#include <XSCRT/Writer.tpp> - -#endif // XSCRT_WRITER_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Writer.ipp b/DAnCE/tools/Config_Handlers/XSCRT/Writer.ipp deleted file mode 100644 index caa9fc99235..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Writer.ipp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/Writer.ipp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/Writer.tpp b/DAnCE/tools/Config_Handlers/XSCRT/Writer.tpp deleted file mode 100644 index 8593004687f..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/Writer.tpp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/Writer.tpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/XML.hpp b/DAnCE/tools/Config_Handlers/XSCRT/XML.hpp deleted file mode 100644 index d0fdd30affe..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/XML.hpp +++ /dev/null @@ -1,493 +0,0 @@ -// file : XSCRT/XML.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - - -#ifndef XSCRT_XML_HPP -#define XSCRT_XML_HPP - -#include <string> - -#include <xercesc/dom/DOM.hpp> -#include <xercesc/util/XMLString.hpp> - -namespace XSCRT -{ - namespace XML - { - //@@ VC6 - // - template <typename C> - std::basic_string<C> - transcode (XMLCh const* s, C*); - - template <typename C> - XMLCh* - transcode (std::basic_string<C> const& s); - - // - // - // - class string - { - public : - template <typename C> - string (std::basic_string<C> const& s) - : s_ (XSCRT::XML::transcode<C> (s)) - { - } - - template <typename C> - string (C const* s) - : s_ (XSCRT::XML::transcode<C> (s)) - { - } - - ~string () - { - delete[] s_; - } - - XMLCh const* - c_str () const - { - return s_; - } - - private : - XMLCh* s_; - }; - - - template <> - inline - std::basic_string<char> - transcode<char> (XMLCh const* s, char*) - { - if (s == 0) return std::basic_string<char> (); - - char* buf = xercesc::XMLString::transcode (s); - - std::basic_string<char> r (buf); - - xercesc::XMLString::release (&buf); - - return r; - } - - template <> - inline - std::basic_string<wchar_t> - transcode<wchar_t> (XMLCh const* s, wchar_t*) - { - if (s == 0) return std::basic_string<wchar_t> (); - - // std::wcerr << s << std::endl; - - std::basic_string<wchar_t> r (xercesc::XMLString::stringLen (s), L'0'); - - for (std::size_t i (0); *s != XMLCh (0); ++s, ++i) - { - r[i] = *s; - } - - return r; - } - - template <> - inline - XMLCh* - transcode (std::basic_string<char> const& s) - { - return xercesc::XMLString::transcode (s.c_str ()); - } - - template <> - inline - XMLCh* - transcode (std::basic_string<wchar_t> const& s) - { - //@@ VC6 - std::size_t l = s.length (); - - //@@ VC6 - XMLCh* r = new XMLCh[l + 1]; - XMLCh* ir = r; - - for (std::size_t i (0); i < l; ++ir, ++i) - { - *ir = static_cast<XMLCh>(s[i]); - //std::wcerr << s[i] << "->" << *ir << std::endl; - } - - *ir = XMLCh (0); - - // std::wcerr << r << std::endl; - - return r; - } - - - template <typename C> - class Element; - - template <typename C> - std::basic_string<C> - ns_prefix (std::basic_string<C> const& ns, Element<C> const& e); - - // Casting helpers, made necessary by the Xerces project's braindead - // avoidance of RTTI. - template <typename DERIVED> struct dom_traits; - - // Specializations for different node types - template <> - struct dom_traits<xercesc::DOMElement *> - { - static const xercesc::DOMNode::NodeType node_type = xercesc::DOMNode::ELEMENT_NODE; - }; - - template <> - struct dom_traits<xercesc::DOMAttr *> - { - static const xercesc::DOMNode::NodeType node_type = xercesc::DOMNode::ATTRIBUTE_NODE; - }; - - template <typename DERIVED_PTR> - DERIVED_PTR dom_cast (xercesc::DOMNode *node) - { - DERIVED_PTR elem = 0; - if ((node != 0) && - (node->getNodeType () == dom_traits<DERIVED_PTR>::node_type)) - { - elem = reinterpret_cast <DERIVED_PTR> (node); - } - return elem; - } - - template <typename C> - class Element - { - typedef std::basic_string<C> string_; - - public: - Element (xercesc::DOMElement const* e) - : e_ (0), - ce_ (e), - name_ (transcode<C> (e->getLocalName (), 0)), - namespace__ (transcode<C> (e->getNamespaceURI (), 0)) - { - } - - Element (xercesc::DOMElement* e) - : e_ (e), - ce_ (e), - name_ (transcode<C> (e->getLocalName (), 0)), - namespace__ (transcode<C> (e->getNamespaceURI (), 0)) - { - } - - Element (string_ const& name, Element& parent) - : e_ (0), - ce_ (0), - name_ (name) - { - xercesc::DOMDocument* doc ( - parent.dom_element ()->getOwnerDocument ()); - - e_ = doc->createElement (string (name).c_str ()); - - parent.dom_element ()->appendChild (e_); - - ce_ = e_; - } - - Element (string_ const& name, string_ const& ns, Element& parent) - : e_ (0), - ce_ (0), - name_ (name), - namespace__ (ns) - { - string_ prefix (ns_prefix (ns, parent)); - - xercesc::DOMDocument* doc ( - parent.dom_element ()->getOwnerDocument ()); - - e_ = doc->createElementNS ( - string (ns).c_str (), - string (prefix.empty () - ? name - : prefix + string_ (1, ':') + name).c_str ()); - - parent.dom_element ()->appendChild (e_); - - ce_ = e_; - } - - public: - string_ - name () const - { - return name_; - } - - string_ - namespace_ () const - { - return namespace__; - } - - public: - Element<C> - parent () const - { - return dom_cast <xercesc::DOMElement const*>(ce_->getParentNode ()); - } - - public: - string_ - value () const - { - return XML::transcode<C> (dom_element ()->getTextContent (), 0); - } - - void - value (string_ const& v) - { - xercesc::DOMText* text ( - dom_element ()->getOwnerDocument ()->createTextNode( - string (v).c_str ())); - - dom_element ()->appendChild (text); - } - - public: - string_ - operator[] (string_ const& s) const - { - //@@ VC6 - XMLCh const* value = ce_->getAttribute (string (s).c_str ()); - - return transcode<C> (value, 0); - } - - public: - xercesc::DOMElement const* - dom_element () const - { - return ce_; - } - - xercesc::DOMElement* - dom_element () - { - return e_; - } - - private: - xercesc::DOMElement* e_; - xercesc::DOMElement const* ce_; - - string_ name_; - string_ namespace__; - }; - - - template <typename C> - class Attribute - { - typedef std::basic_string<C> string_; - - public: - Attribute (xercesc::DOMAttr const* a) - : a_ (0), - ca_ (a), - name_ (transcode<C> (a->getLocalName (), 0)), - value_ (transcode<C> (a->getValue (), 0)) - { - } - - Attribute (xercesc::DOMAttr* a) - : a_ (a), - ca_ (a), - name_ (transcode<C> (a->getLocalName (), 0)), - value_ (transcode<C> (a->getValue (), 0)) - { - } - - Attribute (string_ const& name, - string_ const& v, - Element<C>& parent) - : a_ (0), - ca_ (0), - name_ (name), - value_ () - { - xercesc::DOMDocument* doc ( - parent.dom_element ()->getOwnerDocument ()); - - a_ = doc->createAttribute (string (name).c_str ()); - - value (v); - - parent.dom_element ()->setAttributeNode (a_); - - ca_ = a_; - } - - Attribute (string_ const& name, - string_ const& ns, - string_ const& v, - Element<C>& parent) - : a_ (0), - ca_ (0), - name_ (name), - value_ () - { - string_ prefix (ns_prefix (ns, parent)); - - xercesc::DOMDocument* doc ( - parent.dom_element ()->getOwnerDocument ()); - - a_ = doc->createAttributeNS ( - string (ns).c_str (), - string (prefix.empty () - ? name - : prefix + string_ (1, ':') + name).c_str ()); - - value (v); - - parent.dom_element ()->setAttributeNodeNS (a_); - - ca_ = a_; - } - - string_ - name () const - { - return name_; - } - - string_ - value () const - { - return value_; - } - - void - value (string_ const& v) - { - value_ = v; - a_->setValue (string (v).c_str ()); - } - - public: - xercesc::DOMAttr const* - dom_attribute () const - { - return ca_; - } - - xercesc::DOMAttr* - dom_attribute () - { - return a_; - } - - private: - - private: - xercesc::DOMAttr* a_; - xercesc::DOMAttr const* ca_; - - string_ name_; - string_ value_; - }; - - template <typename C> - std::basic_string<C> - prefix (std::basic_string<C> const& n) - { - std::size_t i (0); - while (i < n.length () && n[i] != ':') ++i; - - //std::wcerr << "prefix " << n << " " - // << std::wstring (n, i == n.length () ? i : 0, i) << std::endl; - - return std::basic_string<C> (n, i == n.length () ? i : 0, i); - } - - template <typename C> - std::basic_string<C> - uq_name (std::basic_string<C> const& n) - { - std::size_t i (0); - while (i < n.length () && n[i] != ':') ++i; - - return std::basic_string<C> (n.c_str () + (i == n.length () ? 0 : i + 1)); - } - - template <typename C> - std::basic_string<C> - ns_name (Element<C> const& e, std::basic_string<C> const& n) - { - std::basic_string<C> wp (prefix (n)); - - //@@ VC6 - XMLCh const* xns = e.dom_element ()->lookupNamespaceURI ( - wp.empty () ? 0 : string (wp).c_str ()); - - - std::basic_string<C> ns ( - xns ? transcode<C> (xns, 0) : std::basic_string<C> ()); - - return ns; - - } - - template <typename C> - std::basic_string<C> - fq_name (Element<C> const& e, std::basic_string<C> const& n) - { - std::basic_string<C> ns (ns_name (e, n)); - std::basic_string<C> un (uq_name (n)); - - return ns.empty () ? un : (ns + C ('#') + un); - } - - class no_prefix {}; - - template <typename C> - std::basic_string<C> - ns_prefix (std::basic_string<C> const& ns, Element<C> const& e) - { - string xns (ns); - -#if defined(XERCES_VERSION_MAJOR) && XERCES_VERSION_MAJOR > 2 - XMLCh const* p (e.dom_element ()->lookupPrefix (xns.c_str ())); -#else - XMLCh const* p (e.dom_element ()->lookupNamespacePrefix (xns.c_str (), false)); -#endif - - if (p == 0) - { - bool r (e.dom_element ()->isDefaultNamespace (xns.c_str ())); - - if (r) - { - return std::basic_string<C> (); - } - else - { - throw no_prefix (); - } - } - - return transcode<C> (p, 0); - } - } -} - -#include "XSCRT/XML.ipp" -#include "XSCRT/XML.tpp" - -#endif // XSCRT_XML_HPP diff --git a/DAnCE/tools/Config_Handlers/XSCRT/XML.ipp b/DAnCE/tools/Config_Handlers/XSCRT/XML.ipp deleted file mode 100644 index 4a7b83efd1c..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/XML.ipp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/XML.ipp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/XML.tpp b/DAnCE/tools/Config_Handlers/XSCRT/XML.tpp deleted file mode 100644 index 63023a05d28..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/XML.tpp +++ /dev/null @@ -1,7 +0,0 @@ -// file : XSCRT/XML.tpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -namespace XSCRT -{ -} diff --git a/DAnCE/tools/Config_Handlers/XSCRT/XMLSchema.hpp b/DAnCE/tools/Config_Handlers/XSCRT/XMLSchema.hpp deleted file mode 100644 index 95575267eee..00000000000 --- a/DAnCE/tools/Config_Handlers/XSCRT/XMLSchema.hpp +++ /dev/null @@ -1,588 +0,0 @@ -// file : XSCRT/XMLSchema.hpp -// author : Boris Kolpackov <boris@dre.vanderbilt.edu> -// cvs-id : $Id$ - -#ifndef XSCRT_XMLSCHEMA_HPP -#define XSCRT_XMLSCHEMA_HPP - -#include <string> -// #include <iostream> //@@ tmp - -#include "XSCRT/Elements.hpp" - -namespace XMLSchema -{ - typedef XSCRT::FundamentalType<signed char> byte; - typedef XSCRT::FundamentalType<unsigned char> unsignedByte; - - typedef XSCRT::FundamentalType<short> short_; - typedef XSCRT::FundamentalType<unsigned short> unsignedShort; - - typedef XSCRT::FundamentalType<int> int_; - typedef XSCRT::FundamentalType<unsigned int> unsignedInt; - - typedef XSCRT::FundamentalType<long long> long_; - typedef XSCRT::FundamentalType<unsigned long long> unsignedLong; - - //@@ It would be nice to use some arbitrary-length integer class. - // - typedef long_ decimal; - typedef decimal integer; - typedef integer nonPositiveInteger; - typedef integer nonNegativeInteger; - typedef nonNegativeInteger positiveInteger; - typedef nonPositiveInteger negativeInteger; - - - typedef XSCRT::FundamentalType<bool> boolean; - - typedef XSCRT::FundamentalType<float> float_; - typedef XSCRT::FundamentalType<double> double_; - - // Just to make GCC 3.3 and other broken compilers shutup. - // - using std::basic_string; - - - template <typename C> - class string : public XSCRT::Type, public basic_string<C> - { - protected: - typedef basic_string<C> Base__ ; - - public: - - //@@ VC6 does not inject XSCRT::Type into the scope so I have - // to qualify it all the time. - // - - string () - { - } - - string (XSCRT::XML::Element<C> const& e) - : Base__ (e.value ()) - { - } - - string (XSCRT::XML::Attribute<C> const& a) - : Base__ (a.value ()) - { - } - - string (Base__ const& x) - : Base__ (x) - { - } - - string& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - - template <typename C> - class normalizedString : public string<C> - { - protected: - typedef typename string<C>::Base__ Base__; - - public: - normalizedString () - { - } - - normalizedString (XSCRT::XML::Element<C> const& e) - : string<C> (e) - { - } - - normalizedString (XSCRT::XML::Attribute<C> const& a) - : string<C> (a) - { - } - - normalizedString (Base__ const& x) - : string<C> (x) - { - } - - normalizedString& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - - template <typename C> - class token : public normalizedString<C> - { - protected: - typedef typename normalizedString<C>::Base__ Base__; - - public: - token () - { - } - - token (XSCRT::XML::Element<C> const& e) - : normalizedString<C> (e) - { - } - - token (XSCRT::XML::Attribute<C> const& a) - : normalizedString<C> (a) - { - } - - token (Base__ const& x) - : normalizedString<C> (x) - { - } - - token& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - - template <typename C> - class NMTOKEN : public token<C> - { - protected: - typedef typename token<C>::Base__ Base__; - - public: - NMTOKEN () - { - } - - NMTOKEN (XSCRT::XML::Element<C> const& e) - : token<C> (e) - { - } - - NMTOKEN (XSCRT::XML::Attribute<C> const& a) - : token<C> (a) - { - } - - NMTOKEN (Base__ const& x) - : token<C> (x) - { - } - - NMTOKEN& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - template <typename C> - class Name: public token<C> - { - protected: - typedef typename token<C>::Base__ Base__; - - public: - Name() - { - } - - Name(XSCRT::XML::Element<C> const& e) - : token<C> (e) - { - } - - Name(XSCRT::XML::Attribute<C> const& a) - : token<C> (a) - { - } - - Name(Base__ const& x) - : token<C> (x) - { - } - - Name& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - - template <typename C> - class NCName: public Name<C> - { - protected: - typedef typename Name<C>::Base__ Base__; - - public: - NCName() - { - } - - NCName(XSCRT::XML::Element<C> const& e) - : Name<C> (e) - { - } - - NCName(XSCRT::XML::Attribute<C> const& a) - : Name<C> (a) - { - } - - NCName(Base__ const& x) - : Name<C> (x) - { - } - - NCName& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - template <typename C> - class QName: public Name<C> - { - protected: - typedef typename Name<C>::Base__ Base__; - - public: - QName() - { - } - - QName(XSCRT::XML::Element<C> const& e) - : Name<C> (e) - { - } - - QName(XSCRT::XML::Attribute<C> const& a) - : Name<C> (a) - { - } - - QName(Base__ const& x) - : Name<C> (x) - { - } - - QName& - operator= (Base__ const& x) - { - static_cast<Base__&> (*this) = x; - return *this; - } - }; - - template <typename C> - struct IdentityProvider : XSCRT::IdentityProvider - { - IdentityProvider (NCName<C> const& id) - : id_ (id) - { - } - - virtual bool - before (XSCRT::IdentityProvider const& y) const - { - return id_ < dynamic_cast<IdentityProvider const&> (y).id_; - } - - private: - NCName<C> const& id_; - - private: - IdentityProvider (IdentityProvider const&); - - IdentityProvider& - operator= (IdentityProvider const&); - }; - - - template <typename C> - class ID : public NCName<C> - { - protected: - typedef typename NCName<C>::Base__ Base__; - - public: - ~ID() - { - unregister_id (); - } - - ID () - : id_provider_ (*this) - { - } - - ID (XSCRT::XML::Element<C> const& e) - : NCName<C> (e), id_provider_ (*this) - { - } - - ID (XSCRT::XML::Attribute<C> const& a) - : NCName<C> (a), id_provider_ (*this) - { - } - - ID (ID const& x) - : NCName<C> (x), id_provider_ (*this) - { - } - - ID (Base__ const& x) - : NCName<C> (x), id_provider_ (*this) - { - } - - ID& - operator= (Base__ const& x) - { - unregister_id (); - - static_cast<NCName<C>&>(*this) = x; - - register_id (); - - return *this; - } - - ID& - operator= (ID const& x) - { - unregister_id (); - - static_cast<NCName<C>&>(*this) = static_cast<NCName<C> const&>(x); - - register_id (); - - return *this; - } - - public: - using NCName<C>::container; - - virtual void - container (XSCRT::Type* c) - { - unregister_id (); - - NCName<C>::container (c); - - register_id (); - } - - private: - using NCName<C>::empty; - using NCName<C>::root; - - void - register_id () - { - if (container () != this && !empty ()) - { - //std::wcerr << "registering " << container () - // << " as '" << *this - // << "' on " << container () << std::endl; - container ()->register_id (id_provider_, container ()); - } - } - - void - unregister_id () - { - if (container () != this && !empty ()) - { - //std::wcerr << "un-registering " << container () - // << " as '" << *this - // << "' on " << container () << std::endl; - container ()->unregister_id (id_provider_); - } - } - - private: - IdentityProvider<C> id_provider_; - }; - - struct IDREF_Base : public XSCRT::Type - { - virtual XSCRT::Type* - get () const = 0; - }; - - template <typename C> - class IDREF : public IDREF_Base - { - public: - IDREF () - : id_provider_ (id_) - { - } - - IDREF (XSCRT::XML::Element<C> const& e) - : id_ (e), id_provider_ (id_) - { - } - - IDREF (XSCRT::XML::Attribute<C> const& a) - : id_ (a), id_provider_ (id_) - { - } - - IDREF (IDREF const& x) - : id_ (x.id_), id_provider_ (id_) - { - } - - IDREF (basic_string<C> const& id) - : id_ (id), id_provider_ (id_) - { - } - - IDREF& - operator= (IDREF const& x) - { - id_ = x.id_; - return *this; - } - - IDREF& - operator= (basic_string<C> const& x) - { - id_ = x; - return *this; - } - - public: - XSCRT::Type* - operator-> () const - { - return get (); - } - - XSCRT::Type& - operator* () const - { - return *(get ()); - } - - virtual XSCRT::Type* - get () const - { - if (!id_.empty () && container () != this) - { - return root ()->lookup_id (id_provider_); - } - else - { - return 0; - } - } - - // conversion to bool - // - typedef XSCRT::Type* (IDREF::*bool_convertable)() const; - - operator bool_convertable () const - { - return get () ? &IDREF::operator-> : 0; - } - - private: - NCName<C> id_; - IdentityProvider<C> id_provider_; - }; -} - -// Traversal -// -// - -#include "XSCRT/Traversal.hpp" - -namespace XMLSchema -{ - namespace Traversal - { - template <typename T> - struct Traverser : XSCRT::Traversal::Traverser<T, XSCRT::Type>, - XSCRT::Traversal::Traverser<IDREF_Base, XSCRT::Type> - { - typedef - T - Type; - - virtual void - traverse (XMLSchema::IDREF_Base& r) - { - if (r.get ()) dispatch (*(r.get ())); - } - }; - - typedef Traverser<byte> byte; - typedef Traverser<unsignedByte> unsignedByte; - - typedef Traverser<short_> short_; - typedef Traverser<unsignedShort> unsignedShort; - - typedef Traverser<int_> int_; - typedef Traverser<unsignedInt> unsignedInt; - - typedef Traverser<long_> long_; - typedef Traverser<unsignedLong> unsignedLong; - - typedef Traverser<boolean> boolean; - - typedef Traverser<float_> float_; - typedef Traverser<double_> double_; - - template <typename C> - struct string : Traverser<XMLSchema::string<C> > - { - }; - - template <typename C> - struct ID : Traverser<XMLSchema::ID<C> > - { - }; - } -} - - -// ExtendedTypeInfo for XML Schema types -// -// - -#include "XSCRT/ExtendedTypeInfo.hpp" - -namespace XMLSchema -{ - template <typename C> - struct TypeInfoInitializer - { - TypeInfoInitializer (XSCRT::ExtendedTypeInfoMap&); - }; -} - -#include "XSCRT/XMLSchema.ipp" -#include "XSCRT/XMLSchema.tpp" - -#endif // XSCRT_XMLSCHEMA_HPP |