LibXmlDomWriter.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _LibXmlDomWriter_hxx_
00022 #define _LibXmlDomWriter_hxx_
00023
00024 #include <iosfwd>
00025 #include <libxml++/document.h>
00026
00027 namespace xmlpp
00028 {
00029 class Document;
00030 class Node;
00031 }
00032
00033 namespace CLAM
00034 {
00035
00041 class LibXmlDomWriter
00042 {
00043 public:
00044 LibXmlDomWriter()
00045 {
00046 mShouldIndent=false;
00047 mShouldCanonicalize=false;
00048 }
00049
00050 void write(std::ostream & target, xmlpp::Node * node)
00051 {
00052 xmlpp::Document document;
00053 document.create_root_node_by_import(node);
00054 write(target, &document);
00055 }
00056
00057 void write(std::ostream & target, xmlpp::Document * node)
00058 {
00059 if (mShouldIndent)
00060 node->write_to_stream_formatted(target,"UTF-8");
00061 else
00062 node->write_to_stream(target,"UTF-8");
00063 }
00064
00065 void DoCanonicalFormat(bool shouldDo = true)
00066 {
00067 mShouldCanonicalize=shouldDo;
00068 }
00069 void DoIndentedFormat(bool shouldDo = true)
00070 {
00071 mShouldIndent=shouldDo;
00072 }
00073 private:
00074 bool mShouldIndent;
00075 bool mShouldCanonicalize;
00076 };
00077
00078
00079
00080 }
00081 #endif//_LibXmlDomWriter_hxx_
00082