00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef VRS_IO_XMLWRITERUTIL_H
00026 #define VRS_IO_XMLWRITERUTIL_H
00027
00028 #include <vrs/so.h>
00029
00030 namespace VRS {
00031 template<typename T> class Iterator;
00032 template<typename T> class Stack;
00033 }
00034
00035 namespace VRS {
00036
00037
00038
00041 class VRS_CORE_API XMLWriterUtil : public SharedObj {
00042 public:
00043
00047 XMLWriterUtil(std::ostream& target, int indentPerLevel = 2);
00048
00050 void writeXMLDeclaration(
00051 const std::string& version="1.0",
00052 const std::string& encoding="utf-8"
00053 );
00054
00056 typedef std::pair<std::string, std::string> XMLAttribute;
00057
00062 virtual void writeOpenTag(
00063 const std::string& elementName,
00064 SO<VRS::Iterator<XMLAttribute> > attributes = NULL,
00065 bool singleLine = false
00066 );
00067
00070 virtual void writeOpenCloseTag(
00071 const std::string& elementName,
00072 SO<VRS::Iterator<XMLAttribute> > attributes = NULL
00073 );
00074
00077 virtual void writeCloseTag();
00078
00080 std::ostream& target();
00081
00082 VRS_TYPEINFO(XMLWriterUtil, SharedObj);
00083
00084 private:
00085 std::ostream* m_target;
00086 SO<VRS::Stack<std::string> > m_openTags;
00087 std::string m_indent;
00088 int m_singleLineRecursion;
00089 };
00090
00091 }
00092
00093 #endif // VRS_IO_XMLWRITERUTIL_H