00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VCSN_XML_INTERNAL_IOS_HH
00019 # define VCSN_XML_INTERNAL_IOS_HH
00020
00029 # include <iostream>
00030
00031 # include <xercesc/dom/DOM.hpp>
00032 # include <xercesc/util/BinInputStream.hpp>
00033 # include <xercesc/sax/InputSource.hpp>
00034 # include <xercesc/framework/XMLFormatter.hpp>
00035
00037 # if (XERCES_VERSION_MAJOR == 2)
00038 # define XMLSize_t unsigned int
00039 # define XERCES_FILEPOS XMLSize_t
00040 # elif (XERCES_VERSION_MAJOR > 2)
00041 # define XERCES_FILEPOS XMLFilePos
00042 # else
00043 # error "Unsupported Xerces-C++ major version (too old)."
00044 # endif
00045
00046 XERCES_CPP_NAMESPACE_BEGIN
00047
00055 template<class Ostream>
00056 class XMLPARSER_EXPORT XMLXercesStream : public XMLFormatTarget
00057 {
00058 public:
00059
00062 XMLXercesStream(std::ostream& os) : os_(os) {};
00063 ~XMLXercesStream() {};
00065
00069 virtual void writeChars(const XMLByte* const toWrite,
00070 const XMLSize_t,
00071 XMLFormatter* const);
00072
00073 virtual void flush() {};
00074
00075 private:
00079 XMLXercesStream(const XMLXercesStream&);
00080 XMLXercesStream& operator=(const XMLXercesStream&);
00081
00082 Ostream& os_;
00083 };
00084
00085 XERCES_CPP_NAMESPACE_END
00086
00087 namespace vcsn
00088 {
00089 namespace xml
00090 {
00091 class BinCxxInputStream : public xercesc::BinInputStream
00092 {
00093 private:
00094 std::istream* _in;
00095 unsigned int _pos;
00096
00097 public:
00098 BinCxxInputStream(std::istream* in) : _in(in), _pos(0) { }
00099 virtual XERCES_FILEPOS curPos() const;
00100 virtual XMLSize_t readBytes(XMLByte *const toFill,
00101 const XMLSize_t maxToRead);
00102 virtual const XMLCh* getContentType () const { return 0; }
00103 };
00104
00105 class CxxInputSource : public xercesc::InputSource
00106 {
00107 private:
00108 std::istream* _in;
00109
00110 public:
00111 CxxInputSource(std::istream* in) : InputSource(), _in(in) {}
00112 virtual BinCxxInputStream* makeStream() const;
00113 };
00114
00115 void print_xml(std::ostream& out,
00116 xercesc::DOMImplementation* impl,
00117 xercesc::DOMElement* root);
00118
00119 }
00120
00121 }
00122
00123 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00124 # include <vaucanson/xml/internal/ios.hxx>
00125 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
00126
00127 #endif // ! VCSN_XML_IOS_HH