From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- libxsd/xsd/cxx/tree/std-ostream-operators.hxx | 274 ++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 libxsd/xsd/cxx/tree/std-ostream-operators.hxx (limited to 'libxsd/xsd/cxx/tree/std-ostream-operators.hxx') diff --git a/libxsd/xsd/cxx/tree/std-ostream-operators.hxx b/libxsd/xsd/cxx/tree/std-ostream-operators.hxx new file mode 100644 index 0000000..e7c9964 --- /dev/null +++ b/libxsd/xsd/cxx/tree/std-ostream-operators.hxx @@ -0,0 +1,274 @@ +// file : xsd/cxx/tree/std-ostream-operators.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSD_CXX_TREE_STD_OSTREAM_OPERATORS_HXX +#define XSD_CXX_TREE_STD_OSTREAM_OPERATORS_HXX + +#include + +#include +#include +#include +#include + +namespace xsd +{ + namespace cxx + { + namespace tree + { + // type + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const type&) + { + return os; + } + + + // simple_type + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const simple_type&) + { + return os; + } + + + // fundamental_base + // + template + inline + std::basic_ostream& + operator<< (std::basic_ostream& os, fundamental_base x) + { + T& r (x); + return os << r; + } + + // optional: see containers.hxx + // + + // list + // + + // This is an xsd:list-style format (space-separated). + // + template + std::basic_ostream& + operator<< (std::basic_ostream& os, const list& v) + { + for (typename list::const_iterator + b (v.begin ()), e (v.end ()), i (b); i != e; ++i) + { + if (i != b) + os << C (' '); + + os << *i; + } + + return os; + } + + + // Operators for built-in types. + // + + + // string + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const string& v) + { + const std::basic_string& r (v); + return os << r; + } + + + // normalized_string + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const normalized_string& v) + { + const B& r (v); + return os << r; + } + + + // token + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const token& v) + { + const B& r (v); + return os << r; + } + + + // nmtoken + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const nmtoken& v) + { + const B& r (v); + return os << r; + } + + + // nmtokens + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const nmtokens& v) + { + const list& r (v); + return os << r; + } + + + // name + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const name& v) + { + const B& r (v); + return os << r; + } + + + // ncname + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const ncname& v) + { + const B& r (v); + return os << r; + } + + + // language + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const language& v) + { + const B& r (v); + return os << r; + } + + + // id + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const id& v) + { + const B& r (v); + return os << r; + } + + + // idref + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const idref& v) + { + const B& r (v); + return os << r; + } + + + // idrefs + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const idrefs& v) + { + const list& r (v); + return os << r; + } + + + // uri + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const uri& v) + { + const std::basic_string& r (v); + return os << r; + } + + + // qname + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, + const qname& n) + { + if (n.qualified ()) + os << n.namespace_ () << C ('#'); + + return os << n.name (); + } + + + // base64_binary + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const base64_binary& v) + { + return os << v.encode (); + } + + + // hex_binary + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const hex_binary& v) + { + return os << v.encode (); + } + + + // entity + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const entity& v) + { + const B& r (v); + return os << r; + } + + + // entities + // + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const entities& v) + { + const list& r (v); + return os << r; + } + } + } +} + +#include + +#endif // XSD_CXX_TREE_STD_OSTREAM_OPERATORS_HXX -- cgit v1.1