rtxCppXmlSTLString.h
Go to the documentation of this file.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 size_t getLenInBytes (const OSUTF8CHAR* xstr) const;
00060
00061 void newString (const OSUTF8CHAR* pString, size_t nbytes = 0);
00062
00063 inline void newString (const char* pString, size_t nbytes = 0) {
00064 newString ((const OSUTF8CHAR*) pString, nbytes);
00065 }
00066
00067 void xstrncat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr, size_t nbytes);
00068
00069 inline void xstrcat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr) {
00070 xstrncat (dststr, srcstr, getLenInBytes(srcstr));
00071 }
00072
00073 public:
00077 OSXMLSTLStringClass();
00078
00086 OSXMLSTLStringClass (const OSUTF8CHAR* strval,
00087 OSBOOL cdata_ = FALSE);
00088
00098 OSXMLSTLStringClass (const OSUTF8CHAR* strval, size_t nbytes,
00099 OSBOOL cdata_ = FALSE);
00100
00108 OSXMLSTLStringClass (const char* strval,
00109 OSBOOL cdata_ = FALSE);
00110
00116 OSXMLSTLStringClass (const OSXMLSTRING& str);
00117
00123 OSXMLSTLStringClass (const OSXMLSTLStringClass& str);
00124
00129 virtual ~OSXMLSTLStringClass();
00130
00140 void appendValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00141
00146 OSRTBaseType* clone () const { return new OSXMLSTLStringClass (*this); }
00147
00157 void copyValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00158
00168 inline void copyValue (const char* cstring, size_t nbytes = 0) {
00169 copyValue ((const OSUTF8CHAR*) cstring, nbytes);
00170 }
00171
00175 inline const char* c_str () const {
00176 if (value)
00177 return value->c_str();
00178 else
00179 return NULL;
00180 }
00181
00185 inline const OSUTF8CHAR* getValue () const {
00186 if (value)
00187 return (const OSUTF8CHAR*) value->c_str();
00188 else
00189 return NULL;
00190 }
00191
00199 inline OSBOOL isCDATA () const { return cdata; }
00200
00208 inline void setCDATA (OSBOOL bvalue) { cdata = bvalue; }
00209
00215 inline void print (const char* name) {
00216
00217
00218 rtxPrintUTF8CharStr (name, (0 == value) ? (const OSUTF8CHAR*)0 :
00219 (const OSUTF8CHAR*)value->c_str());
00220 }
00221
00230 void setValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00231
00240 inline void setValue (const char* cstring, size_t nbytes = 0) {
00241 setValue ((const OSUTF8CHAR*) cstring, nbytes);
00242 }
00243
00251 inline void setValue (OSRTMemBuf& membuf) {
00252 setValue (membuf.getData(), membuf.getDataLen());
00253 }
00254
00258 OSXMLSTLStringClass& operator= (const OSXMLSTLStringClass& original);
00259
00263 OSXMLSTLStringClass& operator= (const char* original);
00264
00268 OSXMLSTLStringClass& operator= (const OSUTF8CHAR* original);
00272 inline operator const char* () const { return c_str(); }
00273
00277 inline operator const OSUTF8CHAR* () const { return getValue(); }
00278
00282 inline int length () {
00283 return (value == 0) ?
00284 0 : (int)rtxUTF8Len((const OSUTF8CHAR*)value->c_str());
00285 }
00286
00290 inline int size () {
00291 return (value == 0) ?
00292 0 : (int)rtxUTF8LenBytes((const OSUTF8CHAR*)value->c_str());
00293 }
00294
00305 virtual int decodeXML (OSCTXT* pctxt);
00306
00320 virtual int encodeXML (OSRTMessageBufferIF& msgbuf,
00321 const OSUTF8CHAR* elemName, OSXMLNamespace* pNS);
00322
00323 } ;
00324 #endif
00325 #endif