ximol/xml/etag.hpp

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 Define etag Interface.
00024         
00025         \author Tournois Florent
00026         \version 1.0
00027 
00028     $Id: etag.hpp,v 1.10 2004/03/04 18:45:29 tournois Exp $
00029     $Log: etag.hpp,v $
00030     Revision 1.10  2004/03/04 18:45:29  tournois
00031     Compatibility with gcc.
00032 
00033     Revision 1.9  2004/03/03 22:05:30  tournois
00034     Add a short roadmap.
00035     Add BOOST_NO_STD_WSTRING for gcc.
00036 
00037     Revision 1.8  2004/02/25 18:59:13  tournois
00038     imporve the gcc compatibility.
00039 
00040     Revision 1.7  2004/02/22 10:27:34  tournois
00041     Add some doc.
00042 
00043     Revision 1.6  2004/02/22 09:54:21  tournois
00044     Change years on the copyright.
00045 
00046     Revision 1.5  2004/02/21 20:03:58  tournois
00047     Change the stag, etag, open_stag, box and rebox template with macro.
00048 
00049     Revision 1.4  2004/02/10 12:33:46  tournois
00050     no message
00051 
00052     Revision 1.3  2003/12/03 12:50:37  hfp
00053     include dependencies and type forwarding
00054 
00055     Revision 1.2  2003/12/03 12:39:36  hfp
00056     include dependencies and type forwarding
00057 
00058     Revision 1.1  2003/11/19 20:52:54  tournois
00059     Add new manipulator for stag and etag.
00060     Correct bugs and add tests.
00061 
00062 
00063   */
00064 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00065 #ifndef XIMOL_XML_ETAG_HPP_
00066 #define XIMOL_XML_ETAG_HPP_
00067 
00068 #include <ximol/qname.hpp>
00069 #include <ximol/control_flow.hpp>
00070 #include <ximol/parser/utils.hpp>
00071 
00072 
00073 XIMOL_XML_BEGIN_NAMESPACE
00074 
00075 //=============================================================================
00076 /// Manipulator for the start tag.
00077 //=============================================================================
00078 template < typename Qname >
00079 struct manipulator_etag
00080 {
00081     manipulator_etag():qname_(NULL){};
00082     manipulator_etag(Qname qname):qname_(new Qname(qname)){};
00083     manipulator_etag(const manipulator_etag<Qname> & x):qname_(new Qname(*x.qname_)){};
00084     ~manipulator_etag(){ delete qname_; };
00085 
00086     Qname * qname_;
00087 private:
00088     manipulator_etag<Qname> & operator=(const manipulator_etag<Qname> & x);
00089 };
00090 
00091 //-----------------------------------------------------------------------------
00092 // PutTo operator for the etag.
00093 //-----------------------------------------------------------------------------
00094 template < typename Qname>
00095 xostream& operator<<(xostream& xos, const manipulator_etag<Qname>& m)
00096 {
00097         XIMOL_PARSER_USING_NAMESPACE;
00098     if (m.qname_==NULL) {
00099         write_etag(xos);
00100     } else { 
00101         if (m.qname_->is_prefix_set())
00102             write_etag(xos,m.qname_->get_local(),m.qname_->get_prefix());
00103         else 
00104             write_etag(xos,m.qname_->get_local());
00105     };
00106         return xos;
00107 };
00108 
00109 //-----------------------------------------------------------------------------
00110 // PutTo operator for the etag.
00111 //-----------------------------------------------------------------------------
00112 template < typename Qname>
00113 xistream& operator>>(xistream& xis, manipulator_etag<Qname> m)
00114 {
00115         XIMOL_PARSER_USING_NAMESPACE;
00116     xstring prefix, local;
00117 
00118     if (has_skip_whitespace(xis)) 
00119         read_optionnal_space(xis);
00120 
00121     read_etag(xis, local, prefix);
00122     if (m.qname_!=NULL) {
00123         m.qname_->set_local(local);
00124         if (m.qname_->is_prefix_set())
00125             m.qname_->set_prefix(prefix);
00126     };
00127         return xis;
00128 };
00129 
00130 // define all function etag(string1, string2)
00131 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2) \
00132     XIMOL_EXPORT manipulator_etag< qualified_name<type1, type2> > etag(type1 & prefix, type2 & local); 
00133 #include <ximol/config/define_functions_prefix_local.hpp>
00134 
00135 // define all function etag(string1)
00136 #define XIMOL_HEADER_DEFINE_FUNCTION(type1) \
00137     XIMOL_EXPORT manipulator_etag< qualified_name<type1, type1> > etag(type1 & local); 
00138 #include <ximol/config/define_functions_local.hpp>
00139 
00140 XIMOL_EXPORT manipulator_etag< qualified_name< ::std::wstring, ::std::wstring> > etag();
00141 
00142 XIMOL_XML_END_NAMESPACE
00143 
00144 #endif // #ifndef XIMOL_XML_ETAG_HPP_


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