ximol/xml/comment.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 comment Interface.
00024         
00025         \author Tournois Florent
00026         \version 1.0
00027 
00028     $Id: comment.hpp,v 1.4 2004/02/22 10:27:34 tournois Exp $
00029     $Log: comment.hpp,v $
00030     Revision 1.4  2004/02/22 10:27:34  tournois
00031     Add some doc.
00032 
00033     Revision 1.3  2004/02/22 09:54:21  tournois
00034     Change years on the copyright.
00035 
00036     Revision 1.2  2004/01/19 20:40:55  tournois
00037     Add min, max and digits facet.
00038     Create the control flow file.
00039 
00040     Revision 1.1  2004/01/08 20:02:30  tournois
00041     Add XIMOL_XML_NAMESPACE_PATH::comment and assignment mainuplator.
00042 
00043     Revision 1.1  2004/01/07 21:13:10  tournois
00044     no message
00045 
00046 
00047   */
00048 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00049 #ifndef XIMOL_XML_COMMENT_HPP_
00050 #define XIMOL_XML_COMMENT_HPP_
00051 
00052 #include <ximol/sstream.hpp>
00053 #include <ximol/parser/utils.hpp>
00054 #include <ximol/assignment.hpp>
00055 
00056 XIMOL_XML_BEGIN_NAMESPACE
00057 
00058 //=============================================================================
00059 /// class for the qualified name
00060 //=============================================================================
00061 template < typename T >
00062 class manipulator_comment
00063 {
00064 public:
00065     typedef T object_type;
00066 
00067 public:
00068     manipulator_comment(object_type & x)
00069         :x_(x)
00070     {};
00071 
00072     manipulator_comment(const manipulator_comment<T> & x)
00073         :x_(x.x_)
00074     {};
00075 
00076     void set(const xstring & x)
00077     {
00078         assignment_to_string::equality(x_, x);
00079     };
00080 
00081     xstring get() const
00082     {
00083         return str<std::wstring>::cast(x_);
00084     };
00085 
00086 private:
00087     const manipulator_comment<T> & operator=(const manipulator_comment<T> & x);
00088 
00089 private:
00090     object_type & x_;
00091 
00092 }; // end of class manipulator_comment<T>
00093 
00094 //-----------------------------------------------------------------------------
00095 // PutTo operator for the comment.
00096 //-----------------------------------------------------------------------------
00097 template < typename T >
00098 xostream& operator<<(xostream& xos, const manipulator_comment<T>& m)
00099 {
00100         XIMOL_PARSER_USING_NAMESPACE;
00101     write_comment(xos,m.get());
00102         return xos;
00103 };
00104 
00105 //-----------------------------------------------------------------------------
00106 // PutTo operator for the comment.
00107 //-----------------------------------------------------------------------------
00108 template < typename T >
00109 xistream& operator>>(xistream& xis, manipulator_comment<T>& m)
00110 {
00111         XIMOL_PARSER_USING_NAMESPACE;
00112     xstring xstr;
00113     read_comment(xis,xstr);
00114     m.set(xstr);
00115         return xis;
00116 };
00117 
00118 template < typename T > manipulator_comment<T> comment( T & t) 
00119 { 
00120     return manipulator_comment<T>(t); 
00121 };
00122 
00123 XIMOL_XML_END_NAMESPACE
00124 
00125 #endif // #ifndef XIMOL_XML_COMMENT_HPP_


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