ximol/xml/xml_decl.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002  *                                                                           *
00003  * library XiMoL                                                             *
00004  * Copyright (C) 2002, 2003, 2004 Florent Tournois                           *
00005  *                                                                           *
00006  * This library is free software; you can redistribute it and/or             *
00007  * modify it under the terms of the GNU Lesser General Public                *
00008  * License as published by the Free Software Foundation; either              *
00009  * version 2.1 of the License, or (at your option) any later version.        *
00010  *                                                                           *
00011  * This library is distributed in the hope that it will be useful,           *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00014  * Lesser General Public License for more details.                           *
00015  *                                                                           *
00016  * You should have received a copy of the GNU Lesser General Public          *
00017  * License along with this library; if not, write to the Free Software       *
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   *
00019  *                                                                           *
00020 \*****************************************************************************/
00021 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 /** \file 
00023         \brief xml_decl implementation.
00024         
00025         \author Tournois Florent
00026         \version 1.0
00027 
00028     $Id: xml_decl.cpp,v 1.3 2004/02/22 10:27:34 tournois Exp $
00029     $Log: xml_decl.cpp,v $
00030     Revision 1.3  2004/02/22 10:27:34  tournois
00031     Add some doc.
00032 
00033     Revision 1.2  2004/02/22 09:54:21  tournois
00034     Change years on the copyright.
00035 
00036     Revision 1.1  2004/01/06 21:04:10  tournois
00037     no message
00038 
00039 
00040   */
00041 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00042 #include <ximol/xml/xml_decl.hpp>
00043 #include <ximol/xml/context.hpp>
00044 #include <ximol/stream.hpp>
00045 #include <ximol/str_cast.hpp>
00046 #include <ximol/parser/utils.hpp>
00047 
00048 XIMOL_XML_BEGIN_NAMESPACE
00049 
00050 //-----------------------------------------------------------------------------
00051 // Common manipulator.
00052 //-----------------------------------------------------------------------------
00053 xostream& operator<<(xostream& xos, const xml_declaration_alone&)
00054 {
00055         XIMOL_PARSER_USING_NAMESPACE;
00056         write_xml_decl(xos,
00057                                  xos.context.get_version_num(),
00058                                  xos.context.get_encoding_decl(),
00059                              xos.context.get_sd_decl() ? L"yes" : L"no"
00060         );
00061 
00062         return xos;
00063 }
00064 
00065 //-----------------------------------------------------------------------------
00066 // Common manipulator.
00067 //-----------------------------------------------------------------------------
00068 xistream& operator>>(xistream& xis, xml_declaration_alone&)
00069 {
00070         XIMOL_PARSER_USING_NAMESPACE;
00071 
00072         xstring ver_, enc_;
00073         bool sdd_;
00074 
00075         read_xml_decl(xis, ver_, enc_, sdd_);
00076 
00077         xis.context.set_version_num(ver_),
00078         xis.context.set_encoding_decl(enc_),
00079         xis.context.set_sd_decl(sdd_);
00080 
00081         if (enc_.length() > 1) 
00082                 xis.encoding(str< ::std::string>::cast(enc_).c_str());
00083 
00084         return xis;
00085 }
00086 
00087 XIMOL_XML_END_NAMESPACE


Donate to the XiMoL project SourceForge.net Logo If you have any questions about XiMoL, you could write to tournois@users.sourceforge.net.