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
00051 class EXTRTCLASS OSXMLSTLStringClass : public OSRTBaseType {
00052 protected:
00053 std::string* value;
00054 OSBOOL cdata;
00055
00056 size_t getLenInBytes (const OSUTF8CHAR* xstr) const;
00057
00058 void newString (const OSUTF8CHAR* pString, size_t nbytes = 0);
00059
00060 inline void newString (const char* pString, size_t nbytes = 0) {
00061 newString ((const OSUTF8CHAR*) pString, nbytes);
00062 }
00063
00064 void xstrncat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr, size_t nbytes);
00065
00066 inline void xstrcat (OSUTF8CHAR* dststr, const OSUTF8CHAR* srcstr) {
00067 xstrncat (dststr, srcstr, getLenInBytes(srcstr));
00068 }
00069
00070 public:
00074 OSXMLSTLStringClass();
00075
00083 OSXMLSTLStringClass (const OSUTF8CHAR* strval,
00084 OSBOOL cdata_ = FALSE);
00085
00095 OSXMLSTLStringClass (const OSUTF8CHAR* strval, size_t nbytes,
00096 OSBOOL cdata_ = FALSE);
00097
00105 OSXMLSTLStringClass (const char* strval,
00106 OSBOOL cdata_ = FALSE);
00107
00113 OSXMLSTLStringClass (const OSXMLSTRING& str);
00114
00120 OSXMLSTLStringClass (const OSXMLSTLStringClass& str);
00121
00126 virtual ~OSXMLSTLStringClass();
00127
00137 void appendValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00138
00143 OSRTBaseType* clone () const { return new OSXMLSTLStringClass (*this); }
00144
00154 void copyValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00155
00165 inline void copyValue (const char* cstring, size_t nbytes = 0) {
00166 copyValue ((const OSUTF8CHAR*) cstring, nbytes);
00167 }
00168
00172 inline const char* c_str () const {
00173 if (value)
00174 return value->c_str();
00175 else
00176 return NULL;
00177 }
00178
00182 inline const OSUTF8CHAR* getValue () const {
00183 if (value)
00184 return (const OSUTF8CHAR*) value->c_str();
00185 else
00186 return NULL;
00187 }
00188
00196 inline OSBOOL isCDATA () const { return cdata; }
00197
00205 inline void setCDATA (OSBOOL bvalue) { cdata = bvalue; }
00206
00212 inline void print (const char* name) {
00213 rtxPrintUTF8CharStr (name, (const OSUTF8CHAR*)value->c_str());
00214 }
00215
00224 void setValue (const OSUTF8CHAR* utf8str, size_t nbytes = 0);
00225
00234 inline void setValue (const char* cstring, size_t nbytes = 0) {
00235 setValue ((const OSUTF8CHAR*) cstring, nbytes);
00236 }
00237
00245 inline void setValue (OSRTMemBuf& membuf) {
00246 setValue (membuf.getData(), membuf.getDataLen());
00247 }
00248
00252 OSXMLSTLStringClass& operator= (const OSXMLSTLStringClass& original);
00253
00257 OSXMLSTLStringClass& operator= (const char* original);
00258
00262 OSXMLSTLStringClass& operator= (const OSUTF8CHAR* original);
00266 inline operator const char* () const { return c_str(); }
00267
00271 inline operator const OSUTF8CHAR* () const { return getValue(); }
00272
00276 inline int length () {
00277 return (value == 0) ?
00278 0 : (int)rtxUTF8Len((const OSUTF8CHAR*)value->c_str());
00279 }
00280
00284 inline int size () {
00285 return (value == 0) ?
00286 0 : (int)rtxUTF8LenBytes((const OSUTF8CHAR*)value->c_str());
00287 }
00288
00289 } ;
00290 #endif
00291 #endif