00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXCPPXMLSTLSTRING_H_
00029 #define _RTXCPPXMLSTLSTRING_H_
00030
00031 #ifdef HAS_STL
00032 #ifdef _MSC_VER
00033
00034 #pragma warning( push, 3 )
00035 #endif
00036 #include <string>
00037 #ifdef _MSC_VER
00038 #pragma warning( pop )
00039 #endif
00040 #include "rtxsrc/OSRTBaseType.h"
00041 #include "rtxsrc/OSRTMemBuf.h"
00042 #include "rtxsrc/rtxPrint.h"
00043 #include "rtxsrc/rtxUTF8.h"
00044 #include "rtxsrc/rtxXmlStr.h"
00045
00046 class OSRTMessageBufferIF;
00047 struct OSXMLNamespace;
00048
00054 class EXTRTCLASS OSXMLSTLStringClass : public OSRTBaseType {
00055 protected:
00056 std::string value;
00057 OSBOOL cdata;
00058
00059 public:
00063 OSXMLSTLStringClass();
00064
00072 OSXMLSTLStringClass (const OSUTF8CHAR* strval, OSBOOL cdata_ = FALSE);
00073
00083 OSXMLSTLStringClass (const OSUTF8CHAR* strval, size_t nbytes,
00084 OSBOOL cdata_ = FALSE);
00085
00093 OSXMLSTLStringClass (const char* strval, OSBOOL cdata_ = FALSE);
00094
00100 OSXMLSTLStringClass (const OSXMLSTRING& str);
00101
00107 OSXMLSTLStringClass (const OSXMLSTLStringClass& str);
00108
00118 void appendValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00119
00124 OSRTBaseType* clone () const { return new OSXMLSTLStringClass (*this); }
00125
00134 inline int compare (const OSUTF8CHAR* value2) const {
00135 return value.compare ((const char*)value2);
00136 }
00137
00147 void copyValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00148
00158 inline void copyValue (const char* cstring, size_t nbytes = 0) {
00159 copyValue ((const OSUTF8CHAR*) cstring, nbytes);
00160 }
00161
00165 inline const char* c_str () const { return value.c_str(); }
00166
00171 inline OSBOOL equals (const OSUTF8CHAR* value2) const {
00172 return value.compare ((const char*)value2) == 0;
00173 }
00174
00179 inline std::string& getString () { return value; }
00180
00184 inline const OSUTF8CHAR* getValue () const {
00185 return (const OSUTF8CHAR*) value.c_str();
00186 }
00187
00195 inline OSBOOL isCDATA () const { return cdata; }
00196
00204 inline void setCDATA (OSBOOL bvalue) { cdata = bvalue; }
00205
00211 inline void print (const char* name) {
00212 rtxPrintUTF8CharStr (name, (const OSUTF8CHAR*) value.c_str());
00213 }
00214
00224 inline void setValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0) {
00225 copyValue (utf8str, nbytes);
00226 }
00227
00237 inline void setValue (const char* cstring, size_t nbytes = 0) {
00238 setValue ((const OSUTF8CHAR*) cstring, nbytes);
00239 }
00240
00247 inline void setValue (OSRTMemBuf& membuf) {
00248 setValue (membuf.getData(), membuf.getDataLen());
00249 }
00250
00254 OSXMLSTLStringClass& operator= (const OSXMLSTLStringClass& original);
00255
00259 OSXMLSTLStringClass& operator= (const char* original);
00260
00264 OSXMLSTLStringClass& operator= (const OSUTF8CHAR* original);
00268 inline operator const char* () const { return c_str(); }
00269
00273 inline operator const OSUTF8CHAR* () const { return getValue(); }
00274
00278 inline size_t length () const { return value.length(); }
00279
00283 inline size_t size () const { return value.size(); }
00284
00295 virtual int decodeXML (OSCTXT* pctxt);
00296
00310 virtual int encodeXML (OSRTMessageBufferIF& msgbuf,
00311 const OSUTF8CHAR* elemName, OSXMLNamespace* pNS);
00312
00313 } ;
00314 #endif
00315 #endif