diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-06-22 11:50:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-06-22 11:50:03 +0200 |
commit | 54110801525371740298d5cae378bfc778749935 (patch) | |
tree | f0f125135b2a1bcf1eea49a559b49d00ea25d879 /xsd/cxx/elements.hxx | |
parent | 3f4a7a6b2a3b708ea69b980494f6e49eb0c02ebc (diff) |
Get rid of dependency on libcult
Diffstat (limited to 'xsd/cxx/elements.hxx')
-rw-r--r-- | xsd/cxx/elements.hxx | 136 |
1 files changed, 66 insertions, 70 deletions
diff --git a/xsd/cxx/elements.hxx b/xsd/cxx/elements.hxx index 9ae4db8..f978f51 100644 --- a/xsd/cxx/elements.hxx +++ b/xsd/cxx/elements.hxx @@ -6,15 +6,13 @@ #ifndef CXX_ELEMENTS_HXX #define CXX_ELEMENTS_HXX +#include <set> +#include <map> +#include <vector> #include <ostream> #include <cutl/re.hxx> -#include <cult/types.hxx> -#include <cult/containers/set.hxx> -#include <cult/containers/map.hxx> -#include <cult/containers/vector.hxx> - #include <xsd-frontend/semantic-graph.hxx> #include <xsd-frontend/traversal.hxx> @@ -27,8 +25,6 @@ namespace CXX { using std::endl; - typedef WideString String; - // On some platforms std::toupper can be something other than a // function with C++ linkage. @@ -42,7 +38,7 @@ namespace CXX struct UnrepresentableCharacter { - UnrepresentableCharacter (String const& str, Size pos) + UnrepresentableCharacter (String const& str, size_t pos) : str_ (str), pos_ (pos) { } @@ -53,7 +49,7 @@ namespace CXX return str_; } - Size + size_t position () const { return pos_; @@ -61,14 +57,14 @@ namespace CXX private: String str_; - Size pos_; + size_t pos_; }; struct NoNamespaceMapping { NoNamespaceMapping (SemanticGraph::Path const& file, - UnsignedLong line, - UnsignedLong column, + size_t line, + size_t column, String const& ns) : file_ (file), line_ (line), @@ -84,13 +80,13 @@ namespace CXX return file_; } - UnsignedLong + size_t line () const { return line_; } - UnsignedLong + size_t column () const { return column_; @@ -104,8 +100,8 @@ namespace CXX private: SemanticGraph::Path file_; - UnsignedLong line_; - UnsignedLong column_; + size_t line_; + size_t column_; String ns_; }; @@ -141,12 +137,12 @@ namespace CXX public: typedef cutl::re::wregex RegexPat; typedef cutl::re::wregexsub Regex; - typedef Cult::Containers::Vector<Regex> RegexMapping; - typedef Cult::Containers::Map<String, String> MapMapping; - typedef Cult::Containers::Map<String, String> MappingCache; + typedef std::vector<Regex> RegexMapping; + typedef std::map<String, String> MapMapping; + typedef std::map<String, String> MappingCache; - typedef Cult::Containers::Map<String, String> ReservedNameMap; - typedef Cult::Containers::Set<String> KeywordSet; + typedef std::map<String, String> ReservedNameMap; + typedef std::set<String> KeywordSet; typedef CXX::options options_type; @@ -220,11 +216,11 @@ namespace CXX // advanced by 1 if this Unicode character takes more than one // underlying character. // - static UnsignedLong - unicode_char (String const& str, Size& pos); + static unsigned int + unicode_char (String const& str, size_t& pos); - static UnsignedLong - unicode_char (WideChar const*& p); + static unsigned int + unicode_char (wchar_t const*& p); // Escape C++ keywords and illegal characters. // @@ -271,7 +267,7 @@ namespace CXX // Fully-qualified C++ name. // String - fq_name (SemanticGraph::Nameable& n, Char const* name_key = "name"); + fq_name (SemanticGraph::Nameable& n, char const* name_key = "name"); public: static SemanticGraph::Type& @@ -282,7 +278,7 @@ namespace CXX process_include_path (String const&) const; public: - static Boolean + static bool skip (SemanticGraph::Member& m) { // "Subsequent" local element. @@ -291,28 +287,28 @@ namespace CXX m.context ().count ("min") == 0; } - static UnsignedLong + static size_t min (SemanticGraph::Member const& m) { - return m.context ().get<UnsignedLong> ("min"); + return m.context ().get<size_t> ("min"); } - static UnsignedLong + static size_t min (SemanticGraph::Any const& a) { - return a.context ().get<UnsignedLong> ("min"); + return a.context ().get<size_t> ("min"); } - static UnsignedLong + static size_t max (SemanticGraph::Member const& m) { - return m.context ().get<UnsignedLong> ("max"); + return m.context ().get<size_t> ("max"); } - static UnsignedLong + static size_t max (SemanticGraph::Any const& a) { - return a.context ().get<UnsignedLong> ("max"); + return a.context ().get<size_t> ("max"); } public: @@ -380,16 +376,16 @@ namespace CXX KeywordSet keyword_set_; }; - inline UnsignedLong Context:: - unicode_char (String const& str, Size& pos) + inline unsigned int Context:: + unicode_char (String const& str, size_t& pos) { - if (sizeof (WideChar) == 4) + if (sizeof (wchar_t) == 4) { return str[pos]; } - else if (sizeof (WideChar) == 2) + else if (sizeof (wchar_t) == 2) { - WideChar x (str[pos]); + wchar_t x (str[pos]); if (x < 0xD800 || x > 0xDBFF) return x; @@ -400,16 +396,16 @@ namespace CXX return 0; } - inline UnsignedLong Context:: - unicode_char (WideChar const*& p) + inline unsigned int Context:: + unicode_char (wchar_t const*& p) { - if (sizeof (WideChar) == 4) + if (sizeof (wchar_t) == 4) { return *p; } - else if (sizeof (WideChar) == 2) + else if (sizeof (wchar_t) == 2) { - WideChar x (*p); + wchar_t x (*p); if (x < 0xD800 || x > 0xDBFF) return x; @@ -432,7 +428,7 @@ namespace CXX } private: - Cult::Containers::Set<SemanticGraph::Schema*> schemas_; + std::set<SemanticGraph::Schema*> schemas_; }; // Usual namespace mapping. @@ -444,10 +440,10 @@ namespace CXX // First scope name if always empty (global scope). The last flag // signals the last scope. // - virtual Void - enter (Type&, String const& name, Boolean last) = 0; + virtual void + enter (Type&, String const& name, bool last) = 0; - virtual Void + virtual void leave () = 0; }; @@ -462,10 +458,10 @@ namespace CXX { } - virtual Void + virtual void pre (Type&); - virtual Void + virtual void post (Type&); private: @@ -478,30 +474,30 @@ namespace CXX template <typename X> struct Has : X { - Has (Boolean& result) + Has (bool& result) : result_ (result) { } - virtual Void + virtual void traverse (typename X::Type&) { result_ = true; } private: - Boolean& result_; + bool& result_; }; // Checks if scope 'Y' names any of 'X' // template <typename X, typename Y> - Boolean + bool has (Y& y) { using SemanticGraph::Scope; - Boolean result (false); + bool result (false); Has<X> t (result); for (Scope::NamesIterator i (y.names_begin ()), e (y.names_end ()); @@ -514,12 +510,12 @@ namespace CXX // Checks if the compositor has any particle of 'X' // template <typename X> - Boolean + bool has_particle (SemanticGraph::Compositor& y) { using SemanticGraph::Compositor; - Boolean result (false); + bool result (false); Has<X> t (result); for (Compositor::ContainsIterator i (y.contains_begin ()), @@ -539,7 +535,7 @@ namespace CXX // Specialization for Complex // template <typename X> - Boolean + bool has_particle (SemanticGraph::Complex& c) { return c.contains_compositor_p () && @@ -558,61 +554,61 @@ namespace CXX Traversal::Fundamental::Id, Traversal::Fundamental::IdRef { - virtual Void + virtual void fundamental_type (SemanticGraph::Fundamental::Type& t) = 0; - virtual Void + virtual void fundamental_template (SemanticGraph::Fundamental::Type& t) = 0; - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Type& t) { fundamental_type (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::String& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NormalizedString& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Token& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Name& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NameToken& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::NCName& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::Id& t) { fundamental_template (t); } - virtual Void + virtual void traverse (SemanticGraph::Fundamental::IdRef& t) { fundamental_template (t); |