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


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