namespace alps { class oxstream { public: oxstream(); oxstream(std::ostream& os, boost::uint32_t incr = 2); oxstream(const boost::filesystem::path& file, boost::uint32_t incr = 2); oxstream& operator<<(const std::string& t); oxstream& operator<<(const char t); oxstream& operator<<(const char * t); oxstream& operator<<(const bool t); oxstream& operator<<(const signed char t); oxstream& operator<<(const unsigned char t); oxstream& operator<<(const short t); oxstream& operator<<(const unsigned short t); oxstream& operator<<(const int t); oxstream& operator<<(const unsigned int t); oxstream& operator<<(const long t); oxstream& operator<<(const unsigned long t); oxstream& operator<<(const long long t); oxstream& operator<<(const unsigned long long t); oxstream& operator<<(const float t); oxstream& operator<<(const double t); oxstream& operator<<(const long double t); oxstream& operator<<(const XMLAttribute& c); oxstream& operator<<(const XMLAttributes& c); // for manipulators template<class T> oxstream& operator<<(T (*fn)(const std::string&)); oxstream& operator<<(oxstream& (*fn)(oxstream& oxs)); std::ostream& stream(); }; // manipulator functions detail::header_t header(const std::string& enc); detail::start_tag_t start_tag(const std::string& name); detail::stylesheet_t stylesheet(const std::string& url); detail::end_tag_t end_tag(const std::string& name = ""); template<class T> detail::attribute_t attribute(const std::string& name, const T& value); detail::pi_t processing_instruction(const std::string& name); detail::attribute_t xml_namespace(const std::string& name, const std::string& url); oxstream& start_comment(oxstream& oxs); oxstream& end_comment(oxstream& oxs); oxstream& start_cdata(oxstream& oxs); oxstream& end_cdata(oxstream& oxs); oxstream& no_linebreak(oxstream& oxs); std::string convert(const std::string& str); } // namespace alps
default constructor. By default, the output stream is std::cout.oxstream();
constracts an oxstream with the output stream set to os. If incr is provided, the offset increment is set to incr.oxstream(std::ostream& os, boost::uint32_t incr = 2);
constracts an oxstream which outputs into a file file. If incr is provided, the offset increment is set to incr.oxstream(const boost::filesystem::path& file, boost::uint32_t incr = 2);
outputs a string to the stream. Note that special characters, such as "&"and "<", are not automatically replaced by the character entities. Use the convert helper function explicitly for escaping special characters.oxstream& operator<<(const std::string& t);
outputs POD data to the stream. Note that special characters, such as "&"and "<", are not automatically replaced by the character entities. Use the convert helper function explicitly for escaping special characters.oxstream& operator<<(const char t); oxstream& operator<<(const char * t); oxstream& operator<<(const bool t); oxstream& operator<<(const signed char t); oxstream& operator<<(const unsigned char t); oxstream& operator<<(const short t); oxstream& operator<<(const unsigned short t); oxstream& operator<<(const int t); oxstream& operator<<(const unsigned int t); oxstream& operator<<(const long t); oxstream& operator<<(const unsigned long t); oxstream& operator<<(const long long t); oxstream& operator<<(const unsigned long long t); oxstream& operator<<(const float t); oxstream& operator<<(const double t); oxstream& operator<<(const long double t);
adds an attribute to the current start tag (see also Manipulators).oxstream& operator<<(const XMLAttribute& c);
adds attribute tos the current start tag (see also Manipulators).oxstream& operator<<(const XMLAttributes& c);
<?xml version="1.0"?>
<?xml version="1.0" encoding="enc"?>
<?xml-stylesheet type="text/xsl" href="URL to my stylesheet"?>
<?my-processing-instruction?>
<mytag xmlns:MyNameSpace="MyURL">
will print out the following XML to the standard output.double x = 3.14; alps::oxstream oxs; oxs << alps::header("MyEncoding"); oxs << alps::stylesheet("URL to my stylesheet") << alps::processing_instruction("my_pi"); oxs << alps::start_tag("tag0") << alps::attribute("name0", 1) << "this is a text" << alps::start_tag("tag1") << alps::start_tag("tag2") << alps::xml_namespace("MyNameSpace", "MyURL") << "text 2 " << "text 3 " << std::endl << alps::precision(3.14159265358979323846, 3) << ' ' << alps::precision(3.14159265358979323846, 6) << '\n' << "text 4" << std::endl << alps::convert("text <&\">'") << alps::start_tag("tag3") << alps::end_tag << x << alps::start_tag("tag4") << alps::no_linebreak << "no linebreak" << alps::end_tag << alps::end_tag("tag2") << alps::end_tag("tag1") << alps::end_tag;
<?xml version="1.0" encoding="MyEncoding"?> <?xml-stylesheet type="text/xsl" href="URL to my stylesheet"?> <?my_pi?> <tag0 name0="1"> this is a text <tag1> <tag2 xmlns:MyNameSpace="MyURL"> text 2 text 3 3.14 3.14159 text 4 text <&">' <tag3/> 3.14 <tag4>no linebreak</tag4> </tag2> </tag1> </tag0>
copyright (c) 1994-2010 by Matthias Troyer
Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)