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 _RTXCPPXMLSTRING_H_
00029 #define _RTXCPPXMLSTRING_H_
00030
00031 #include "rtxsrc/OSRTBaseType.h"
00032 #include "rtxsrc/OSRTMemBuf.h"
00033 #include "rtxsrc/rtxPrint.h"
00034 #include "rtxsrc/rtxUTF8.h"
00035 #include "rtxsrc/rtxXmlStr.h"
00036
00037 #define DEFAULT_CAPACITY 40
00038
00039 class OSRTMessageBufferIF;
00040 struct OSXMLNamespace;
00041
00046 class EXTRTCLASS OSXMLStringClass : public OSRTBaseType {
00047 protected:
00048 OSUTF8CHAR* value;
00049 OSBOOL cdata;
00050 size_t mCapacityIncrement;
00051 size_t mCurrentBufferSize;
00052 size_t mCurrentStringSize;
00053
00054 size_t getRequiredCapacity (const char* pString) const;
00055 size_t getRequiredCapacity (const OSUTF8CHAR* pString) const;
00056 size_t getRequiredCapacity (size_t numBytesRequired) const;
00057 size_t getLenInBytes (const OSUTF8CHAR* xstr) const;
00058
00059 void newString (const OSUTF8CHAR* pString, size_t nbytes = 0);
00060
00061 inline void newString (const char* pString, size_t nbytes = 0) {
00062 newString ((const OSUTF8CHAR*) pString, nbytes);
00063 }
00064
00065 void xstrncat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr, size_t nbytes);
00066
00067 inline void xstrcat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr) {
00068 xstrncat (dststr, srcstr, getLenInBytes(srcstr));
00069 }
00070
00071 public:
00075 OSXMLStringClass();
00076
00084 OSXMLStringClass (const OSUTF8CHAR* strval, OSBOOL cdata_ = FALSE);
00085
00095 OSXMLStringClass (const OSUTF8CHAR* strval, size_t nbytes,
00096 OSBOOL cdata_ = FALSE);
00097
00105 OSXMLStringClass (const char* strval, OSBOOL cdata_ = FALSE);
00106
00112 OSXMLStringClass (const OSXMLSTRING& str);
00113
00119 OSXMLStringClass (const OSXMLStringClass& str);
00120
00125 virtual ~OSXMLStringClass();
00126
00136 void appendValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00137
00142 OSRTBaseType* clone () const { return new OSXMLStringClass (*this); }
00143
00152 inline int compare (const OSUTF8CHAR* value2) const {
00153 return rtxUTF8Strcmp (value, value2);
00154 }
00155
00165 void copyValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00166
00176 inline void copyValue (const char* cstring, size_t nbytes = 0) {
00177 copyValue ((const OSUTF8CHAR*) cstring, nbytes);
00178 }
00179
00183 inline const char* c_str () const {
00184 return (const char*)value;
00185 }
00186
00197 virtual int decodeXML (OSCTXT* pctxt);
00198
00212 virtual int encodeXML (OSRTMessageBufferIF& msgbuf,
00213 const OSUTF8CHAR* elemName, OSXMLNamespace* pNS);
00214
00219 inline OSBOOL equals (const OSUTF8CHAR* value2) const {
00220 return rtxUTF8StrEqual (value, value2);
00221 }
00222
00226 inline const OSUTF8CHAR* getValue () const {
00227 return value;
00228 }
00229
00237 inline OSBOOL isCDATA () const { return cdata; }
00238
00246 inline void setCDATA (OSBOOL bvalue) { cdata = bvalue; }
00247
00253 inline void print (const char* name) { rtxPrintUTF8CharStr (name, value); }
00254
00263 void setValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00264
00273 inline void setValue (const char* cstring, size_t nbytes = 0) {
00274 setValue ((const OSUTF8CHAR*) cstring, nbytes);
00275 }
00276
00284 inline void setValue (OSRTMemBuf& membuf) {
00285 setValue (membuf.getData(), membuf.getDataLen());
00286 }
00287
00291 OSXMLStringClass& operator= (const OSXMLStringClass& original);
00292
00296 OSXMLStringClass& operator= (const char* original);
00297
00301 OSXMLStringClass& operator= (const OSUTF8CHAR* original);
00305 inline operator const char* () const { return c_str(); }
00306
00310 inline operator const OSUTF8CHAR* () const { return getValue(); }
00311
00315 inline size_t length () const {
00316 return (value == 0) ? 0 : rtxUTF8Len (value);
00317 }
00318
00322 inline size_t size () {
00323 return (value == 0) ? 0 : rtxUTF8LenBytes (value);
00324 }
00325
00326 } ;
00327
00328 #endif