- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# ios.hxx

    00001 // ios.hxx: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2004, 2005, 2006, 2008, 2009 The Vaucanson Group.
    00006 //
    00007 // This program is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU General Public License
    00009 // as published by the Free Software Foundation; either version 2
    00010 // of the License, or (at your option) any later version.
    00011 //
    00012 // The complete GNU General Public Licence Notice can be found as the
    00013 // `COPYING' file in the root directory.
    00014 //
    00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    00016 //
    00017 #ifndef VCSN_XML_INTERNAL_IOS_HXX
    00018 # define VCSN_XML_INTERNAL_IOS_HXX
    00019
    00020 # include <vaucanson/xml/internal/ios.hh>
    00021
    00022 XERCES_CPP_NAMESPACE_BEGIN
    00023
    00024 template<class Ostream>
    00025 void
    00026 XMLPARSER_EXPORT
    00027 XMLXercesStream<Ostream>::writeChars(const XMLByte* const toWrite,
    00028                                      const XMLSize_t,
    00029                                      XMLFormatter* const)
    00030 {
    00031   os_ << toWrite;
    00032 }
    00033
    00034 XERCES_CPP_NAMESPACE_END
    00035
    00036 namespace vcsn
    00037 {
    00038   namespace xml
    00039   {
    00040     inline
    00041     XMLSize_t
    00042     BinCxxInputStream::readBytes(XMLByte *const toFill,
    00043                                  const XMLSize_t maxToRead)
    00044     {
    00045       // istream::readsome does not seem to work on SunOS
    00046       unsigned s = _in->rdbuf()->sgetn((char *)toFill, maxToRead);
    00047       _pos += s;
    00048       return s;
    00049     }
    00050
    00051     inline
    00052     XERCES_FILEPOS
    00053     BinCxxInputStream::curPos() const
    00054     {
    00055       return _pos;
    00056     }
    00057
    00058     inline
    00059     BinCxxInputStream*
    00060     CxxInputSource::makeStream() const
    00061     {
    00062       return new BinCxxInputStream(_in);
    00063     }
    00064
    00065     void
    00066     print_xml(std::ostream& out,
    00067               xercesc::DOMImplementation* impl,
    00068               xercesc::DOMElement* root)
    00069     {
    00070       using namespace xercesc;
    00071
    00072       XMLXercesStream<std::ostream>* outstream = new XMLXercesStream<std::ostream>(out);
    00073
    00074 # if XERCES_VERSION_MAJOR == 2
    00075       DOMWriter* writer = impl->createDOMWriter();
    00076
    00077       if (writer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
    00078         writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
    00079
    00080       writer->writeNode(outstream, *root);
    00081 # elif XERCES_VERSION_MAJOR > 2
    00082       DOMLSSerializer* writer = impl->createLSSerializer();
    00083       DOMLSOutput *target = impl->createLSOutput();
    00084       target->setByteStream(outstream);
    00085       DOMConfiguration *config = writer->getDomConfig();
    00086
    00087       if (config->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true))
    00088         config->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true);
    00089
    00090       writer->write(root, target);
    00091 # else
    00092 #  error "Unsupported Xerces-C++ major version (too old)."
    00093 # endif
    00094
    00095       writer->release();
    00096
    00097       delete outstream;
    00098     }
    00099
    00100   } // ! xml
    00101
    00102 } // ! vcsn
    00103
    00104 #endif // ! VCSN_XML_INTERNAL_IOS_HXX