00001 /* 00002 ot_lib - Object Type Library 00003 Copyright (C) 2002 Alessandro Bonfanti 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alessandro Bonfanti 00020 xjbon@tin.it 00021 */ 00022 00023 00024 #ifndef OT_STRING_H 00025 #define OT_STRING_H 00026 00027 // ----------------------------------------------------------------------------------- 00029 00030 // ----------------------------------------------------------------------------------- 00031 00032 class ot_string : public ot_obj 00033 { 00034 private: 00035 00037 string m_value; 00038 00039 public: 00040 00041 // ######################################### 00042 // CONSTRUCTORS & DESTRUCTOR 00043 // ######################################### 00044 00047 ot_string(const string &val=""); 00048 00049 // Copy constructor 00050 ot_string(const ot_string &c); 00051 00053 virtual ~ot_string(); 00054 00055 00056 // ######################################### 00057 // IMPLEMENTATIONS OF THE VIRTUAL FUNCTIONS 00058 // ######################################### 00059 00061 ot_obj *dup(void) const; 00062 00066 void asXml(ostream &s=cout,int i=0) const; 00067 00070 bool asData(ostream &s) const; 00071 00072 00073 // ######################################### 00074 // PROPIETARY FUNCTIONS 00075 // ######################################### 00076 00079 const string & get(void) const; 00080 00081 00082 // ######################################### 00083 // MATH OPERATOR 00084 // ######################################### 00085 00087 const ot_string & operator= (const ot_string &c); 00088 00090 const ot_string & operator= (const string &v); 00091 00093 bool operator == (const ot_string &v) const; 00094 00096 bool operator == (const string &v); 00097 00099 bool operator != (const ot_string &v); 00100 00102 bool operator != (const string &v); 00103 00105 bool operator == (const ot_obj *o) const 00106 { 00107 if(o && o->getType()==getType()) return(*this==*((ot_string *) o)); 00108 else return(false); 00109 } 00110 00111 00112 00114 const ot_string operator + (const ot_string &c) const; 00115 00117 void operator += (const ot_string &c); 00118 00120 template <class X> void operator += (X x); 00121 00123 template <class X> void operator << (X x); 00124 }; 00125 00126 00127 template <class X> void ot_string::operator += (X x) 00128 { 00129 stringstream str; 00130 00131 str << x << ends; 00132 00133 m_value += str.str(); 00134 } 00135 00136 00137 template <class X> void ot_string::operator << (X x) 00138 { 00139 stringstream str; 00140 00141 str << x << ends; 00142 00143 m_value += str.str(); 00144 } 00145 00146 #else 00147 #endif 00148