ximol/xml/box.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 box Interface.
00024         
00025         \author Tournois Florent
00026         \version 1.0
00027 
00028     $Id: box.hpp,v 1.7 2004/02/22 10:27:34 tournois Exp $
00029     $Log: box.hpp,v $
00030     Revision 1.7  2004/02/22 10:27:34  tournois
00031     Add some doc.
00032 
00033     Revision 1.6  2004/02/22 09:54:21  tournois
00034     Change years on the copyright.
00035 
00036     Revision 1.5  2004/02/21 20:03:58  tournois
00037     Change the stag, etag, open_stag, box and rebox template with macro.
00038 
00039     Revision 1.4  2004/02/04 11:42:25  tournois
00040     no message
00041 
00042     Revision 1.3  2004/01/25 17:32:56  tournois
00043     no message
00044 
00045     Revision 1.2  2004/01/15 21:26:01  tournois
00046     no message
00047 
00048     Revision 1.1  2004/01/09 18:26:29  tournois
00049     Add box and content manipulator.
00050 
00051     Revision 1.5  2003/12/10 20:32:18  tournois
00052     Fix somes bugs about attributes and now tests are all check.
00053 
00054     Revision 1.4  2003/12/09 19:57:28  tournois
00055     Fix some bugs about attributes classes.
00056 
00057     Revision 1.3  2003/12/03 12:50:37  hfp
00058     include dependencies and type forwarding
00059 
00060     Revision 1.2  2003/11/27 15:31:55  hfp
00061     partially adapted to vc6.
00062 
00063     Revision 1.1  2003/11/19 20:52:54  tournois
00064     Add new manipulator for stag and etag.
00065     Correct bugs and add tests.
00066 
00067 
00068   */
00069 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00070 #ifndef XIMOL_XML_BOX_HPP_
00071 #define XIMOL_XML_BOX_HPP_
00072 
00073 #include <ximol/xml/stag.hpp>
00074 #include <ximol/xml/etag.hpp>
00075 #include <ximol/parser/utils.hpp>
00076 
00077 XIMOL_XML_BEGIN_NAMESPACE
00078 
00079 //=============================================================================
00080 /// Manipulator for the start tag.
00081 //=============================================================================
00082 template < typename String1, typename String2, typename Att, typename T >
00083 struct manipulator_box 
00084 {
00085 public:
00086     typedef qualified_name<String1,String2> qname_type;
00087     typedef manipulator_stag< qname_type, Att> stag_type;
00088 public:
00089     manipulator_box(const stag_type & stag, T & t):stag_(stag),t_(t){};
00090     manipulator_box(const manipulator_box<String1, String2, Att, T> & x):stag_(x.stag_),t_(x.t_){};
00091 
00092     stag_type stag_;
00093     T & t_;
00094 private:
00095     manipulator_box<String1, String2, Att, T> & operator=(const manipulator_box<String1, String2, Att, T> & x);
00096 };
00097 
00098 //-----------------------------------------------------------------------------
00099 // PutTo operator for the box.
00100 //-----------------------------------------------------------------------------
00101 template < typename String1, typename String2, typename Att, typename T >
00102 xostream& operator<<(xostream& xos, const manipulator_box<String1, String2, Att, T>& m)
00103 {
00104     return xos << m.stag_ << m.t_ << xml::etag();
00105 };
00106 
00107 //-----------------------------------------------------------------------------
00108 // PutTo operator for the box.
00109 //-----------------------------------------------------------------------------
00110 template < typename String1, typename String2, typename Att, typename T >
00111 xistream& operator>>(xistream& xis, manipulator_box<String1, String2, Att, T>& m)
00112 {
00113         return xis >> m.stag_ >> m.t_ >> xml::etag();
00114 };
00115 
00116 // define all function box(string1, string2, attributes,t)
00117 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2, type3) \
00118     template < typename T > \
00119     manipulator_box < type1, type2, type3, T > \
00120     box( type1 & prefix, type2 & local, type3 & att, T& t) { \
00121     return manipulator_box< type1, type2, type3, T >(stag(prefix,local,att),t);  };
00122 
00123 #include <ximol/config/define_functions_prefix_local_attributes.hpp>
00124 
00125 // define all function box(string1, string2,t)
00126 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2) \
00127     template < typename T > \
00128     manipulator_box < type1, type2, xml::attributes, T > \
00129     box( type1 & prefix, type2 & local, T& t) { \
00130     return manipulator_box< type1, type2, xml::attributes, T >(stag(prefix,local),t);  };
00131 #include <ximol/config/define_functions_prefix_local.hpp>
00132 
00133 // define all function box(string1, attribute,t)
00134 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type3) \
00135     template < typename T > \
00136     manipulator_box < type1, type1, type3, T > \
00137     box( type1 & local, type3 & att, T& t) { \
00138     return manipulator_box< type1, type1, type3, T >(stag(local,att),t);  };
00139 #include <ximol/config/define_functions_local_attributes.hpp>
00140 
00141 // define all function box(string1,t)
00142 #define XIMOL_HEADER_DEFINE_FUNCTION(type1) \
00143     template < typename T > \
00144     manipulator_box < type1, type1, xml::attributes, T > \
00145     box( type1 & local, T& t) { \
00146     return manipulator_box< type1, type1, xml::attributes, T >(stag(local),t);  };
00147 #include <ximol/config/define_functions_local.hpp>
00148 
00149 // define all function rebox(string1, string2, attributes,t)
00150 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2, type3) \
00151     template < typename T > \
00152     manipulator_box < type1, type2, type3, T > \
00153     rebox( type1 & prefix, type2 & local, type3 & att, T& t) { \
00154     return manipulator_box< type1, type2, type3, T >(open_stag(prefix,local,att),t);  };
00155 
00156 #include <ximol/config/define_functions_prefix_local_attributes.hpp>
00157 
00158 // define all function rebox(string1, string2,t)
00159 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type2) \
00160     template < typename T > \
00161     manipulator_box < type1, type2, xml::attributes, T > \
00162     rebox( type1 & prefix, type2 & local, T& t) { \
00163     return manipulator_box< type1, type2, xml::attributes, T >(open_stag(prefix,local),t);  };
00164 #include <ximol/config/define_functions_prefix_local.hpp>
00165 
00166 // define all function rebox(string1, attribute,t)
00167 #define XIMOL_HEADER_DEFINE_FUNCTION(type1, type3) \
00168     template < typename T > \
00169     manipulator_box < type1, type1, type3, T > \
00170     rebox( type1 & local, type3 & att, T& t) { \
00171     return manipulator_box< type1, type1, type3, T >(open_stag(local,att),t);  };
00172 #include <ximol/config/define_functions_local_attributes.hpp>
00173 
00174 // define all function rebox(string1,t)
00175 #define XIMOL_HEADER_DEFINE_FUNCTION(type1) \
00176     template < typename T > \
00177     manipulator_box < type1, type1, xml::attributes, T > \
00178     rebox( type1 & local, T& t) { \
00179     return manipulator_box< type1, type1, xml::attributes, T >(open_stag(local),t);  };
00180 #include <ximol/config/define_functions_local.hpp>
00181 
00182 XIMOL_XML_END_NAMESPACE
00183 
00184 #endif // #ifndef XIMOL_XML_BOX_HPP_


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