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: content.cpp,v 1.3 2004/02/22 10:27:34 tournois Exp $ 00029 $Log: content.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/09 18:26:29 tournois 00037 Add box and content manipulator. 00038 00039 Revision 1.1 2004/01/06 21:04:10 tournois 00040 no message 00041 00042 00043 */ 00044 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00045 #include <ximol/xml/content.hpp> 00046 #include <ximol/xml/context.hpp> 00047 #include <ximol/stream.hpp> 00048 #include <ximol/error.hpp> 00049 #include <ximol/translation.hpp> 00050 #include <ximol/str_cast.hpp> 00051 #include <ximol/parser/utils.hpp> 00052 #include <ximol/parser/def_signs.hpp> 00053 00054 XIMOL_XML_BEGIN_NAMESPACE 00055 00056 //----------------------------------------------------------------------------- 00057 // 00058 //----------------------------------------------------------------------------- 00059 manipulator_char_data_content::manipulator_char_data_content(const xstring& xstr) 00060 :content_(xstr) 00061 {} 00062 00063 //----------------------------------------------------------------------------- 00064 // 00065 //----------------------------------------------------------------------------- 00066 manipulator_char_data_content::manipulator_char_data_content(const manipulator_char_data_content& x) 00067 :content_(x.xstr()) 00068 {} 00069 00070 //----------------------------------------------------------------------------- 00071 // 00072 //----------------------------------------------------------------------------- 00073 manipulator_char_data_content& manipulator_char_data_content::operator=(const manipulator_char_data_content& x) 00074 { 00075 if (this==&x) return *this; 00076 content_.str(x.xstr()); 00077 return *this; 00078 } 00079 00080 //----------------------------------------------------------------------------- 00081 // 00082 //----------------------------------------------------------------------------- 00083 manipulator_char_data_content& manipulator_char_data_content::operator=(const xstring& xstr) 00084 { 00085 content_.str(xstr); 00086 return *this; 00087 } 00088 00089 //----------------------------------------------------------------------------- 00090 // 00091 //----------------------------------------------------------------------------- 00092 ::std::basic_istringstream<xchar_t>& manipulator_char_data_content::istr() 00093 { 00094 return content_; 00095 } 00096 00097 //----------------------------------------------------------------------------- 00098 // 00099 //----------------------------------------------------------------------------- 00100 xstring manipulator_char_data_content::xstr() const 00101 { 00102 return content_.str(); 00103 } 00104 00105 //----------------------------------------------------------------------------- 00106 // 00107 //----------------------------------------------------------------------------- 00108 void manipulator_char_data_content::xstr(const xstring & xstr) 00109 { 00110 content_.str(xstr); 00111 } 00112 00113 //----------------------------------------------------------------------------- 00114 // 00115 //----------------------------------------------------------------------------- 00116 ::std::string manipulator_char_data_content::str() const 00117 { 00118 return XIMOL_NAMESPACE_PATH::str< ::std::string>::cast(content_.str()); 00119 } 00120 00121 //----------------------------------------------------------------------------- 00122 // 00123 //----------------------------------------------------------------------------- 00124 void manipulator_char_data_content::str(const ::std::string & str) 00125 { 00126 content_.str( XIMOL_NAMESPACE_PATH::str< ::std::wstring>::cast(str)); 00127 } 00128 00129 //----------------------------------------------------------------------------- 00130 // content manipulator 00131 //----------------------------------------------------------------------------- 00132 manipulator_char_data_content char_data_content(xistream& xis) 00133 { 00134 XIMOL_PARSER_USING_NAMESPACE; 00135 00136 xstring result; 00137 xstring temp; 00138 xchar_t xc; 00139 00140 bool end_loop=false; 00141 while ( (!end_loop) && (xis.get(xc)) ) 00142 { 00143 switch (xc) 00144 { 00145 case XCHAR_AMPERSAND: 00146 read_reference(xis, temp, 1); 00147 result += temp; 00148 break; 00149 case XCHAR_LESS_THAN_SIGN: 00150 xis.get(xc); 00151 switch (xc) 00152 { 00153 case XCHAR_EXCLAMATION_MARK: // comment 00154 xis.get(xc); 00155 switch (xc) 00156 { 00157 case XCHAR_HYPHEN_MINUS: 00158 read_comment(xis, temp, 3); 00159 break; 00160 case XCHAR_LEFT_SQUARE_BRACKET: 00161 read_cd_sect(xis, temp, 3); 00162 result += temp; 00163 break; 00164 default: 00165 XIMOL_THROW << _(L"Waiting for '-' or '['") << XIMOL_AS_ERROR; 00166 } 00167 break; 00168 case XCHAR_QUESTION_MARK: // PI 00169 read_pi(xis,2); 00170 break; 00171 default: // element 00172 xis.putback(xc); 00173 xis.putback(XCHAR_LESS_THAN_SIGN); 00174 end_loop=true; 00175 break; 00176 } 00177 break; 00178 default: 00179 result+=xc; 00180 } 00181 } 00182 return result; 00183 } 00184 00185 XIMOL_XML_END_NAMESPACE