ZeusBase-Library  2.0.4
String.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch)
3  *****************************************************************************
4  * Project : Zeus Base Library
5  * Module : String
6  * Package : Zeus.ZeusBase.System
7  * Author : Benjamin Hadorn
8  * Date : 27.12.2011
9  * System : Zeus-Framework
10  *****************************************************************************
11  * Licence: *
12  * This library is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU Lesser General Public License as *
14  * published by the Free Software Foundation; either version *
15  * 2.1 of the License, or (at your option) any later version. *
16  * *
17  * This library is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU Lesser General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU Lesser General Public *
23  * License along with this library; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
25  *****************************************************************************/
26 
27 /*****************************************************************************
28  * Changes:
29  * 27.12.2011 bha: created zeus 2.0
30  *****************************************************************************/
31 
32 #ifndef StringH
33 #define StringH
34 
37 
38 
39 #ifdef _MSC_VER
40  #pragma warning(push, 1) // Avoid Visual Studio 6.0 level 4 and 3 compiler warnings.
41 #endif
42 
43 #include <stdlib.h>
44 #include <stdarg.h>
45 #include <limits.h>
46 
47 #ifdef _MSC_VER
48  #pragma warning(pop)
49 #endif
50 
51 
52 #ifdef USE_BCB_BINDINGS
53 namespace System
54 {
55  class WideString;
56  #ifdef ENABLE_BCB_UNICODESTRING
57  class UnicodeString;
58  #endif
59 }; //System
60 #endif
61 
62 #ifdef USE_STL_BINDINGS
63  #ifdef _MSC_VER
64  #pragma warning(push, 1) // Avoid Visual Studio 6.0 level 4 and 3 compiler warnings.
65  #pragma warning(disable: 4701) // Previous pragma has no effect!
66  #endif
67 
68  #include <string>
69 
70  #ifdef _MSC_VER
71  #pragma warning(default: 4701)
72  #pragma warning(pop)
73  #endif
74 #endif
75 
76 #ifdef USE_QT_BINDINGS
77  class QString;
78 #endif
79 
80 
81 //#include "assert.h"
82 
84 
85 //defines the minimum size of the string
86 #define STRING_MIN_SIZE 10
87 
88 /****************************************************************************/
93 /****************************************************************************/
94 #define INIT_TSTRING \
95  m_pWBuffer(NULL), \
96  m_pCBuffer(NULL), \
97  m_iSize(0), \
98  m_uiMemSize(0) \
99 
100 
101 /******************************************************************************/
112 /******************************************************************************/
114 {
115  public:
116  //---------------------------------------------------------------------
117  // constructors
118  TString();
119  TString(const wchar_t* data);
120  TString(const char* data);
121  TString(wchar_t wcChar, Uint uiCount=1);
122  TString(char cChar, Uint uiCount=1);
123  TString(const TString& strString);
124  TString(const IString& strString);
125  TString(const IString* pString);
126  TString(Int32 lValue);
127  TString(Int64 ldValue);
128  TString(Uint32 ulValue);
129  TString(Uint64 uldValue);
130  TString(Float fValue);
131  TString(Float fValue, Uint uiDigits);
132  TString(bool bValue);
133 
134  //If the int is a seperate type -> add two extra constructors
135  #if !defined(DECLARE_INT32_AS_INT)
136  TString(int iValue);
137  TString(unsigned int uiValue);
138  #endif
139 
140  // 4 constructors for the concatenation of 2 strings with increased performance:
141  TString(const TString& rstr1, const TString& rstr2);
142  TString(const TString& rstr, const wchar_t* pwc);
143  TString(const wchar_t* pwc, const TString& rstr);
144  TString(const wchar_t* pwc1, const wchar_t* pwc2);
145  // 8 constructors for the concatenation of 3 strings with increased performance:
146  TString(const TString& rstr1, const TString& rstr2, const TString& rstr3);
147  TString(const TString& rstr1, const TString& rstr2, const wchar_t* pwc);
148  TString(const TString& rstr1, const wchar_t* pwc, const TString& rstr2);
149  TString(const TString& rstr, const wchar_t* pwc1, const wchar_t* pwc2);
150  TString(const wchar_t* pwc, const TString& rstr1, const TString& rstr2);
151  TString(const wchar_t* pwc1, const TString& rstr, const wchar_t* pwc2);
152  TString(const wchar_t* pwc1, const wchar_t* pwc2, const TString& rstr);
153  TString(const wchar_t* pwc1, const wchar_t* pwc2, const wchar_t* pwc3);
154 
155  #ifdef USE_STL_BINDINGS
156  TString(const std::wstring& rInstr);
157  TString(const std::string& rInstr);
158  #endif //USE_STL_BINDINGS
159 
160  #ifdef USE_BCB_BINDINGS
161  TString(const System::WideString& rInstr);
162  #ifdef ENABLE_BCB_UNICODESTRING
163  TString(const System::UnicodeString& rInstr);
164  #endif
165  #endif
166 
167  #ifdef USE_QT_BINDINGS
168  TString(const QString& rInStr);
169  #endif
170 
171  //---------------------------------------------------------------------
172  // advanced constructors
173  TString(wchar_t* pwcData, Uint uiBufferSize, bool bAdoptPointer);
174 
175  /**********************************************************************/
178  /**********************************************************************/
179  inline virtual ~TString()
180  {
181  clearBuffers();
182  }
183 
184  //---------------------------------------------------------------------
185  //static methods
186  static TString formatFloat(Float fValue,
187  Float fRoundPrecision = 0,
188  Uint uiTailingZeros = 0,
189  Uint uiLeadingZeros = 1);
190  static TString formatInt( Int iValue,
191  Uint uiLeadingZeros);
192  static TString format(const char* pcFormat, ...);
193  static TString format(const wchar_t* pwcFormat, ...);
194  static TString format(const IString& rFormat, ...);
195  static TString formatV(const char* pcFormat, va_list Arg);
196  static TString formatV(const wchar_t* pwcFormat, va_list Arg);
197  static TString formatV(const IString& rFormat, va_list Arg);
198 
199  //transcodeing from encoded data to string
200  static TString transcode(const IByteArray& rList);
201  static TString transcodeFromISO_8859_1(const IByteArray& rList);
202  static TString transcodeFromUTF_8(const IByteArray& rList);
203  static TString transcodeFromUTF_16(const IByteArray& rList);
204  static TString transcodeFromUTF_32(const IByteArray& rList);
205 
206  //transcoding a string to encoded data
207  //static TByteArray transcode(const IString& rValue, bool bAsWideChar, bool bNullTerminated = true, bool bAddHeader = true);
208  static TByteArray transcodeToISO_8859_1(const IString& rValue, bool bNullTerminated = true);
209  static TByteArray transcodeToUTF_8(const IString& rValue, bool bNullTerminated = true, bool bAddHeader = true);
210  static TByteArray transcodeToUTF_16(const IString& rValue, bool bNullTerminated = true, bool bAddHeader = true);
211  static TByteArray transcodeToUTF_32(const IString& rValue, bool bNullTerminated = true, bool bAddHeader = true);
212 
213  static TString trimExt(const IString& rSource,
214  const IString& rChars,
215  bool bLeft = true,
216  bool bRight = true);
217 
218 
219  //---------------------------------------------------------------------
220  //Operators
221  TString& operator=(const TString& rInstr);
222  TString& operator=(const IString& rInstr);
223  TString& operator=(const IString* pInstr);
224  TString& operator=(const wchar_t* pData);
225  TString& operator=(const Int iData);
226  TString& operator=(const int iData);
227  TString& operator=(const Uint uiData);
228  TString& operator=(const unsigned int uiData);
229  TString& operator=(const Float fData);
230  TString& operator=(const char* pData);
231  TString& operator=(bool bData);
232  #ifdef USE_STL_BINDINGS
233  TString& operator=(const std::wstring& rInstr);
234  TString& operator=(const std::string& rInstr);
235  #endif
236  #ifdef USE_BCB_BINDINGS
237  TString& operator=(const System::WideString& rInstr);
238  #ifdef ENABLE_BCB_UNICODESTRING
239  TString& operator=(const System::UnicodeString& rInstr);
240  #endif
241  #endif
242 
243  bool operator==(const TString& rInstr) const;
244  bool operator==(const IString& rInstr) const;
245  bool operator==(const IString* pInstr) const;
246  bool operator==(const wchar_t* pInbuffer) const;
247  bool operator==(const char* pInbuffer) const;
248  bool operator==(const Float fData) const;
249  bool operator==(const Int iData) const;
250  bool operator==(const int iData) const;
251  bool operator==(const Uint uiData) const;
252  bool operator==(const unsigned int uiData) const;
253  bool operator==(bool bData) const;
254  #ifdef USE_STL_BINDINGS
255  bool operator==(const std::wstring& rInstr) const;
256  bool operator==(const std::string& rInstr) const;
257  #endif
258  #ifdef USE_BCB_BINDINGS
259  bool operator==(const System::WideString& rInstr) const;
260  #ifdef ENABLE_BCB_UNICODESTRING
261  bool operator==(const System::UnicodeString& rInstr) const;
262  #endif
263  #endif
264 
265  TString operator+ (const TString& rInstr) const;
266  TString operator+ (const IString& rInstr) const;
267  TString operator+ (const wchar_t* pInbuffer) const;
268  TString operator+ (const char* pInbuffer) const;
269  TString operator+ (const wchar_t wc) const;
270  TString operator+ (const char c) const;
271  TString operator+ (const Int iInval) const;
272  TString operator+ (const int iInval) const;
273  TString operator+ (const Uint uiInval) const;
274  TString operator+ (const unsigned int uiInval) const;
275  TString operator+ (const Float fInval) const;
276  #ifdef USE_STL_BINDINGS
277  TString operator+ (const std::wstring& rInstr) const;
278  TString operator+ (const std::string& rInstr) const;
279  #endif
280  bool operator!=(const TString& rInstr) const;
281  bool operator!=(const IString& rInstr) const;
282  bool operator!=(const IString* pInstr) const;
283  bool operator!=(const wchar_t* pInbuffer)const;
284  bool operator!=(const char* pInbuffer) const;
285  bool operator!=(const Float fData) const;
286  bool operator!=(const Int iData) const;
287  bool operator!=(const int iData) const;
288  bool operator!=(const Uint uiData) const;
289  bool operator!=(const unsigned int uiData) const;
290  bool operator!=(const bool bData) const;
291  #ifdef USE_STL_BINDINGS
292  bool operator!=(const std::wstring& rInstr) const;
293  bool operator!=(const std::string& rInstr) const;
294  #endif
295  TString& operator+= (const TString& rInstr);
296  TString& operator+= (const IString& rInstr);
297  TString& operator+= (const wchar_t* pInbuffer);
298  TString& operator+= (const char* pInbuffer);
299  TString& operator+= (const wchar_t wc);
300  TString& operator+= (const char c);
301  TString& operator+= (const Int iInval);
302  TString& operator+= (const int iInval);
303  TString& operator+= (const Uint uiInval);
304  TString& operator+= (const unsigned int uiInval);
305  TString& operator+= (const Float fInval);
306  #ifdef USE_STL_BINDINGS
307  TString& operator+= (const std::wstring& rInstr);
308  TString& operator+= (const std::string& rInstr);
309  #endif //USE_STL_BINDINGS
310 
311  wchar_t& operator[](Int iIndex);
312  bool operator< (const TString& rInStr) const;
313  bool operator<= (const TString& rInStr) const;
314  bool operator> (const TString& rInStr) const;
315  bool operator>= (const TString& rInStr) const;
316 
317  //---------------------------------------------------------------------
318  // Substring-Manipulationen.
319  bool containsChar(const wchar_t wcChar) const;
320  bool containsCharOf(const wchar_t* wcChars) const;
321  Int getFirstCharPos(const wchar_t wcChar) const;
322  Int getFirstCharPosOf(const wchar_t* wcChars) const;
323  Int getLastCharPos(const wchar_t wcChar) const;
324  Int getLastCharPosOf(const wchar_t* wcChars) const;
325  TString deleteSubString(Int iStartIndex, Int iEndIndex = IntMax) const;
326  TString getSubString(Int iStartIndex, Int iEndIndex = IntMax) const;
327  TString getLeft(Int iCharCount) const;
328  TString getRight(Int iCharCount) const;
329  TString deleteLeft(Int iCharCount) const;
330  TString deleteRight(Int iCharCount) const;
331  Int getSubStringCount(const IString& rSubstring) const;
332  TString insert(Int iIndex, const IString& rStrToInsert) const;
333  TString insert(Int iIndex, const TString& rStrToInsert) const;
334  TString remove(const IString& rToRemove, Int* pReplaces = NULL) const;
335  TString remove(const TString& strToRemove, Int* pReplaces = NULL) const;
336  TString removeFirst(const IString& rToRemove) const;
337  TString removeFirst(const TString& rToRemove) const;
338  TString replace(const IString& rToRemove, const IString& rReplace, Int* pReplaces = NULL) const;
339  TString replace(const TString& rToRemove, const TString& rReplace, Int* pReplaces = NULL) const;
340  TString replaceFirst(const IString& rToRemove, const IString& rReplace) const;
341  TString replaceFirst(const TString& rToRemove, const TString& rReplace) const;
342  TString toUpperCase() const;
343  TString toLowerCase() const;
344  TString trim() const;
345  TString trimLeft() const;
346  TString trimRight() const;
347  TString terminated(const IString& rTermination) const;
348  TString terminated(const TString& rTermination) const;
349  TString enclosed(const IString& rEnclosure) const;
350  TString enclosed(const TString& rEnclosure) const;
351  TString enquoted() const;
352  Int64 getHash() const;
353  const wchar_t* getPtrOfChar(Int iStartIndex, wchar_t wcChar) const;
354  const wchar_t* getPtrOfFirstChar(wchar_t wcChar) const;
355  const wchar_t* getPtrOfLastChar(wchar_t wcChar) const;
356  const wchar_t* getPtrOfStr(Int iStartIndex, const IString& rSubString) const;
357  const wchar_t* getPtrOfStr(Int iStartIndex, const TString& rSubString) const;
358  const wchar_t* getPtrOfFirstStr(const IString& rSubString) const;
359  const wchar_t* getPtrOfFirstStr(const TString& rSubString) const;
360  const wchar_t* getPtrOfLastStr(const IString& rSubString) const;
361  const wchar_t* getPtrOfLastStr(const TString& rSubString) const;
362 
363  TString extractSubString(const TString& strBefore, const TString& strAfter = L"",
364  Int iSearchStartPosForBeforeString = 0,
365  Int* piSubStringPos = NULL) const;
366 
367  //---------------------------------------------------------------------
368  //Methods of IString
369  virtual const wchar_t* MQUALIFIER c_bstr() const;
370  virtual const char* MQUALIFIER c_str(BOOL_ERRORRETVAL(pError)) const;
371  virtual Float MQUALIFIER toFloat(Float fPredef = 0.0, bool* pbError = NULL) const;
372  virtual Int MQUALIFIER toInt(Int iPredef = 0, bool* pbError = NULL) const;
373  virtual Uint MQUALIFIER toUint(Uint uiPredef = 0, bool* pbError = NULL) const;
374  virtual Timeval MQUALIFIER toTimeval(Timeval tmPredef = 0, bool* pbError = NULL) const;
375  virtual bool MQUALIFIER toBool(bool bPredef = false, bool* pbError = NULL) const;
376  virtual bool MQUALIFIER isFloat() const;
377  virtual bool MQUALIFIER isInt() const;
378  virtual bool MQUALIFIER isBool() const;
379  virtual bool MQUALIFIER equals(const wchar_t* pInbuffer, bool bIgnoreCase = false) const;
380  virtual bool MQUALIFIER equalsStr(const IString& rInstr, bool bIgnoreCase = false) const;
381  virtual void MQUALIFIER concat(const wchar_t* pInbuffer);
382  virtual void MQUALIFIER concatStr(const IString& rInstr);
383  virtual void MQUALIFIER assign(const wchar_t* pInbuffer);
384  virtual void MQUALIFIER assignStr(const IString& rInstr);
385  virtual Int MQUALIFIER getSize() const;
386  virtual wchar_t MQUALIFIER getChar(Int iIndex) const;
387  virtual Int MQUALIFIER getFirstPos(const wchar_t* pSubBuffer) const;
388  virtual Int MQUALIFIER getFirstPosStr(const IString& rSubString) const;
389  virtual Int MQUALIFIER getLastPos(const wchar_t* pSubBuffer) const;
390  virtual Int MQUALIFIER getLastPosStr(const IString& rSubString) const;
391  virtual void MQUALIFIER clear();
392  virtual bool MQUALIFIER isEmpty() const;
393  virtual bool MQUALIFIER endsWith(const wchar_t* pString) const;
394  virtual bool MQUALIFIER endsWithStr(const IString& rString) const;
395  virtual bool MQUALIFIER startsWith(const wchar_t* pString) const;
396  virtual bool MQUALIFIER startsWithStr(const IString& rString) const;
397  virtual Int MQUALIFIER compareTo(const IString& rString) const;
398  virtual bool MQUALIFIER contains(const wchar_t* pSubString) const;
399  virtual bool MQUALIFIER containsStr(const IString& rSubString) const;
400  virtual Int MQUALIFIER getPos(Int iStartIndex, const wchar_t* pSubBuffer) const;
401  virtual Int MQUALIFIER getPosOfStr(Int iStartIndex, const IString& rSubString) const;
402 
403  protected:
404  /*************************************************************************/
407  /*************************************************************************/
409  {
410  etISO_8859_1 = 0,
411  etUTF_8 = 1,
412  etUTF_16 = 2,
413  etUTF_32 = 3
414  };
415 
416  static TString convertDouble(const Float& rfValue, Int iDigit = 15);
417  static void detectHeader_internal(const IByteArray& rList, Int& riStartIndex, EStringEncoding& reEncoding);
418  static TString transcode_internal(const IByteArray& rList, Int iStartIndex, EStringEncoding eEncoding);
419  static TByteArray transcode_internal(const IString& rValue, EStringEncoding eEncoding, bool bNullTerminated, bool bAddHeader);
420 
421  private:
423  wchar_t* m_pWBuffer;
425  mutable char* m_pCBuffer;
427  static wchar_t m_wcEmpty;
429  mutable Int m_iSize;
431  Uint m_uiMemSize;
432 
433  //---------------------------------------------------------------------
434  void clearBuffers();
435  void clearWBuffer();
436  void clearCBuffer() const;
437  void updateSize() const;
438  wchar_t* convToWStr(const char* pData);
439  char* convToCStr(const wchar_t* pData, bool* pError) const;
440 
441  void adoptPointer(wchar_t* pData, Uint uiMemSize);
442  static void replace_internal(std::wstring& rData, Int iPos, Int iCharsToRemove, const std::wstring& rReplace);
443  void assignInt32(Int32 lValue);
444  void assignInt64(Int64 ldValue);
445  void assignUint32(Uint32 ulValue);
446  void assignUint64(Uint64 uldValue);
447 };
448 
449 
450 
451 //##############################################################################
452 // INLINE
453 /**************************************************************************/
458 /**************************************************************************/
459 inline TString::TString(const wchar_t* pData)
460  : INIT_TSTRING
461 {
462  assign(pData); //calls updateSize();
463 }
464 
465 /**************************************************************************/
469 /**************************************************************************/
470 inline TString::TString(const IString& rString)
471  : INIT_TSTRING
472 {
473  assign(rString.c_bstr()); //calls updateSize();
474 }
475 
476 /**************************************************************************/
480 /**************************************************************************/
481 inline TString::TString(const TString& rString)
482 #if defined(__COLINUX__)
483  : IString(rString),
485 #else
486  : INIT_TSTRING
487 #endif
488 {
489  assign(rString.m_pWBuffer); //calls updateSize();
490 }
491 
492 /**************************************************************************/
497 /**************************************************************************/
498 inline TString::TString(const char* pData)
499  : INIT_TSTRING
500 {
501  //create a wide buffer out of the char array
502  convToWStr(pData);
503  updateSize();
504 }
505 
506 /**************************************************************************/
510 /**************************************************************************/
511 inline TString::TString(Int32 lValue)
512  : INIT_TSTRING
513 {
514  assignInt32(lValue);
515 }
516 
517 /**************************************************************************/
521 /**************************************************************************/
522 inline TString::TString(Int64 ldValue)
523  : INIT_TSTRING
524 {
525  assignInt64(ldValue);
526 }
527 
528 /**************************************************************************/
532 /**************************************************************************/
533 inline TString::TString(Uint32 ulValue)
534  : INIT_TSTRING
535 {
536  assignUint32(ulValue);
537 }
538 
539 /**************************************************************************/
543 /**************************************************************************/
544 inline TString::TString(Uint64 uldValue)
545  : INIT_TSTRING
546 {
547  assignUint64(uldValue);
548 }
549 
550 //If the int is a seperate type -> add two extra constructors
551 #if !defined(DECLARE_INT32_AS_INT)
552 /**************************************************************************/
556 /**************************************************************************/
557 inline TString::TString(int iValue)
558  : INIT_TSTRING
559 {
560  #if defined(__ZEUS32__)
561  assignInt32((Int32)iValue);
562  #elif defined(__ZEUS64__)
563  assignInt64((Int64)iValue);
564  #else
565  #error "TString::TString(int iValue): constructor not implemented for this platform"
566  #endif
567 }
568 
569 /**************************************************************************/
573 /**************************************************************************/
574 inline TString::TString(unsigned int uiValue)
575  : INIT_TSTRING
576 {
577  #if defined(__ZEUS32__)
578  assignUint32((Uint32)uiValue);
579  #elif defined(__ZEUS64__)
580  assignUint64((Uint64)uiValue);
581  #else
582  #error "TString::TString(unsigned int uiValue): constructor not implemented for this platform"
583  #endif
584 }
585 #endif
586 
587 /**************************************************************************/
591 /**************************************************************************/
592 inline TString::TString(Float fValue)
593  : INIT_TSTRING
594 {
595  assignStr(convertDouble(fValue));
596 }
597 
598 
599 /**************************************************************************/
603 /**************************************************************************/
604 inline TString::TString(bool bValue)
605  : INIT_TSTRING
606 {
607  assignInt32(bValue);
608 }
609 
610 
611 /**************************************************************************/
616 /**************************************************************************/
617 inline TString::TString(Float fValue, Uint uiDigits)
618  : INIT_TSTRING
619 {
620  assignStr(convertDouble(fValue, (Int)uiDigits));
621 }
622 
623 #ifdef USE_STL_BINDINGS
624 /***************************************************************************/
628 /***************************************************************************/
629 inline TString::TString(const std::wstring& rInstr)
630  : INIT_TSTRING
631 {
632  assign(rInstr.c_str());
633 }
634 
635 /***************************************************************************/
639 /***************************************************************************/
640 inline TString::TString(const std::string& rInstr)
641  : INIT_TSTRING
642 {
643  convToWStr(rInstr.c_str()); // calls updateSize()
644 }
645 #endif
646 
647 
648 /***************************************************************************/
651 /***************************************************************************/
652 inline TString::TString(wchar_t* pwcData, Uint uiBufferSize, bool bAdoptPointer)
653 {
654  m_pCBuffer = NULL;
655 
656  if (bAdoptPointer)
657  {
658  m_pWBuffer = pwcData;
659  m_uiMemSize = uiBufferSize;
660  updateSize();
661  }
662  else
663  {
664  m_pWBuffer = NULL;
665  m_iSize = 0;
666  m_uiMemSize = 0;
667  assign(pwcData);
668  }
669 }
670 
671 /**************************************************************************/
674 /**************************************************************************/
675 inline void TString::clearBuffers()
676 {
677  clearCBuffer();
678  clearWBuffer();
679 }
680 
681 /**************************************************************************/
688 /**************************************************************************/
689 inline /*static*/ TString TString::transcode(const IByteArray& rList)
690 {
691  Int iStartIndex = 0;
693  TString::detectHeader_internal(rList, iStartIndex, eEncoding);
694  return TString::transcode_internal(rList, iStartIndex, eEncoding);
695 }
696 
697 /**************************************************************************/
702 /**************************************************************************/
703 inline /*static*/ TString TString::transcodeFromISO_8859_1(const IByteArray& rList)
704 {
706 }
707 
708 /**************************************************************************/
713 /**************************************************************************/
714 inline /*static*/ TString TString::transcodeFromUTF_8(const IByteArray& rList)
715 {
716  Int iStartIndex = 0;
717 
718  register Uint8 ui8Char1 = (Uint8)rList.getItemConst(0);
719  register Uint8 ui8Char2 = (Uint8)rList.getItemConst(1);
720  register Uint8 ui8Char3 = (Uint8)rList.getItemConst(2);
721 
722  if (ui8Char1 == 0xBF && ui8Char2 == 0xBB && ui8Char3 == 0xEF)
723  {
724  iStartIndex = 3;
725  }
726  return TString::transcode_internal(rList, iStartIndex, TString::etUTF_8);
727 }
728 
729 /**************************************************************************/
734 /**************************************************************************/
735 inline /*static*/ TString TString::transcodeFromUTF_16(const IByteArray& rList)
736 {
737  Int iStartIndex = 0;
738 
739  register Uint8 ui8Char1 = (Uint8)rList.getItemConst(0);
740  register Uint8 ui8Char2 = (Uint8)rList.getItemConst(1);
741 
742  if (ui8Char1 == 0xFF && ui8Char2 == 0xFE)
743  {
744  iStartIndex = 2;
745  }
746  return TString::transcode_internal(rList, iStartIndex, TString::etUTF_16);
747 }
748 
749 /**************************************************************************/
754 /**************************************************************************/
755 inline /*static*/ TString TString::transcodeFromUTF_32(const IByteArray& rList)
756 {
757  Int iStartIndex = 0;
758 
759  register Uint8 ui8Char1 = (Uint8)rList.getItemConst(0);
760  register Uint8 ui8Char2 = (Uint8)rList.getItemConst(1);
761  register Uint8 ui8Char3 = (Uint8)rList.getItemConst(2);
762  register Uint8 ui8Char4 = (Uint8)rList.getItemConst(3);
763 
764  if (rList.getCount() >= 4 &&
765  ui8Char1 == 0xFF &&
766  ui8Char2 == 0xFE &&
767  ui8Char3 == 0x00 &&
768  ui8Char4 == 0x00)
769  {
770  iStartIndex = 4;
771  }
772  return TString::transcode_internal(rList, iStartIndex, TString::etUTF_32);
773 }
774 
775 /**************************************************************************/
782 /**************************************************************************/
783 inline /*static*/ TByteArray TString::transcodeToISO_8859_1(const IString& rValue, bool bNullTerminated /*= true*/)
784 {
785  return TString::transcode_internal(rValue, TString::etISO_8859_1, bNullTerminated, false);
786 }
787 
788 /**************************************************************************/
796 /**************************************************************************/
797 inline /*static*/ TByteArray TString::transcodeToUTF_8(const IString& rValue, bool bNullTerminated /*= true*/, bool bAddHeader /*= true*/)
798 {
799  return TString::transcode_internal(rValue, TString::etUTF_8, bNullTerminated, bAddHeader);
800 }
801 
802 /**************************************************************************/
810 /**************************************************************************/
811 inline /*static*/ TByteArray TString::transcodeToUTF_16(const IString& rValue, bool bNullTerminated /*= true*/, bool bAddHeader /*= true*/)
812 {
813  return TString::transcode_internal(rValue, TString::etUTF_16, bNullTerminated, bAddHeader);
814 }
815 
816 /**************************************************************************/
824 /**************************************************************************/
825 inline /*static*/ TByteArray TString::transcodeToUTF_32(const IString& rValue, bool bNullTerminated /*= true*/, bool bAddHeader /*= true*/)
826 {
827  return TString::transcode_internal(rValue, TString::etUTF_32, bNullTerminated, bAddHeader);
828 }
829 
830 /**************************************************************************/
836 /**************************************************************************/
837 inline bool TString::containsChar(const wchar_t wcChar) const
838 {
839  return (this->getFirstCharPos(wcChar) >= 0);
840 }
841 
842 /**************************************************************************/
849 /**************************************************************************/
850 inline TString TString::getLeft(Int iCharCount) const
851 {
852  return this->getSubString(0, iCharCount-1);
853 }
854 
855 /**************************************************************************/
862 /**************************************************************************/
863 inline TString TString::getRight(Int iCharCount) const
864 {
865  Int iSize = getSize();
866  return this->getSubString(iSize - iCharCount, iSize-1);
867 }
868 
869 /**************************************************************************/
875 /**************************************************************************/
876 inline TString TString::deleteLeft(Int iCharCount) const
877 {
878  //Violation of the one in and one out restriction, because
879  // - creating an empty TString at the beginning costs time
880  if (iCharCount > 0)
881  {
882  if (iCharCount < getSize())
883  {
884  return (m_pWBuffer + iCharCount);
885  }
886  else
887  {
888  return L"";
889  }
890  }
891  else
892  {
893  return this;
894  }
895 }
896 
897 /**************************************************************************/
903 /**************************************************************************/
904 inline TString TString::deleteRight(Int iCharCount) const
905 {
906  Int iSize = getSize();
907  return getSubString(0, iSize-iCharCount-1);
908 }
909 
910 /**************************************************************************/
916 /**************************************************************************/
917 inline TString TString::insert(Int iIndex, const TString& rStrToInsert) const
918 {
919  return this->insert(iIndex, (const IString&)rStrToInsert);
920 }
921 
922 /******************************************************************************/
929 /******************************************************************************/
930 inline TString TString::remove(const IString& rToRemove, Int* pReplaces /*= NULL*/) const
931 {
932  return replace(rToRemove, (const IString&)TString(L""), pReplaces);
933 }
934 
935 /******************************************************************************/
942 /******************************************************************************/
943 inline TString TString::remove(const TString& rToRemove, Int* pReplaces /*= NULL*/) const
944 {
945  return replace((const IString&)rToRemove, (const IString&)TString(L""), pReplaces);
946 }
947 
948 /******************************************************************************/
954 /******************************************************************************/
955 inline TString TString::removeFirst(const IString& rToRemove) const
956 {
957  return replaceFirst((const IString&)rToRemove, (const IString&)TString(L""));
958 }
959 
960 /******************************************************************************/
966 /******************************************************************************/
967 inline TString TString::removeFirst(const TString& rToRemove) const
968 {
969  return replaceFirst((const IString&)rToRemove, (const IString&)TString(L""));
970 }
971 
972 /******************************************************************************/
980 /******************************************************************************/
981 inline TString TString::replaceFirst(const TString& rToRemove, const TString& rReplace) const
982 {
983  return replaceFirst((const IString&)rToRemove, (const IString&)rReplace);
984 }
985 
986 /******************************************************************************/
991 /******************************************************************************/
992 inline TString TString::terminated(const TString& rTermination) const
993 {
994  return terminated((const IString&) rTermination);
995 }
996 
997 /******************************************************************************/
1002 /******************************************************************************/
1003 inline TString TString::enclosed(const TString& rEnclosure) const
1004 {
1005  return enclosed((const IString&) rEnclosure);
1006 }
1007 
1008 /******************************************************************************/
1017 /******************************************************************************/
1018 inline TString TString::replace(const TString& rToRemove, const TString& rReplace, Int* pReplaces /*= NULL*/) const
1019 {
1020  return replace((const IString&)rToRemove, (const IString&)rReplace, pReplaces);
1021 }
1022 
1023 /**************************************************************************/
1028 /**************************************************************************/
1029 inline TString TString::trim() const
1030 {
1031  return TString::trimExt(*this, TString(L" \t\r\n"), true, true);
1032 }
1033 
1034 /**************************************************************************/
1039 /**************************************************************************/
1041 {
1042  return TString::trimExt(*this, TString(L" \t\r\n"), true, false);
1043 }
1044 
1045 /**************************************************************************/
1050 /**************************************************************************/
1052 {
1053  return TString::trimExt(*this, TString(L" \t\r\n"), false, true);
1054 }
1055 
1056 /***************************************************************************/
1062 /***************************************************************************/
1063 inline TString TString::terminated(const IString& rTermination) const
1064 {
1065  TString strReturn = *this;
1066 
1067  if (!strReturn.endsWithStr(rTermination))
1068  {
1069  strReturn += rTermination;
1070  } // !strReturn.endsWithStr(rTermination).
1071 
1072  return strReturn;
1073 }
1074 
1075 
1076 /***************************************************************************/
1082 /***************************************************************************/
1083 inline TString TString::enclosed(const IString& rEnclosure) const
1084 {
1085  TString strReturn = terminated(rEnclosure);
1086 
1087  if (!this->startsWithStr(rEnclosure))
1088  {
1089  strReturn = TString(rEnclosure) + strReturn;
1090  } // !this->startsWithStr(rEnclosure).
1091 
1092  return strReturn;
1093 }
1094 
1095 
1096 /***************************************************************************/
1101 /***************************************************************************/
1103 {
1104  return enclosed(TString(L"\""));
1105 }
1106 
1107 /***************************************************************************/
1110 /***************************************************************************/
1111 inline const wchar_t* TString::getPtrOfStr(Int iStartIndex, const TString& rSubString) const
1112 {
1113  return getPtrOfStr(iStartIndex, (const IString&)rSubString);
1114 }
1115 
1116 /***************************************************************************/
1119 /***************************************************************************/
1120 inline const wchar_t* TString::getPtrOfFirstStr(const TString& rSubString) const
1121 {
1122  return getPtrOfFirstStr((const IString&)rSubString);
1123 }
1124 
1125 /***************************************************************************/
1128 /***************************************************************************/
1129 inline const wchar_t* TString::getPtrOfLastStr(const TString& rSubString) const
1130 {
1131  return getPtrOfLastStr((const IString&)rSubString);
1132 }
1133 
1134 /**************************************************************************/
1139 /**************************************************************************/
1140 inline /*static*/ TString TString::format(const char* pcFormat, ...)
1141 {
1142  va_list Args;
1143  va_start(Args, pcFormat);
1144  TString strRetval = formatV(pcFormat, Args);
1145  va_end(Args);
1146  return strRetval;
1147 }
1148 
1149 /**************************************************************************/
1154 /**************************************************************************/
1155 inline /*static*/ TString TString::format(const wchar_t* pwcFormat, ...)
1156 {
1157  va_list Args;
1158  va_start(Args, pwcFormat);
1159  TString strRetval = formatV(pwcFormat, Args);
1160  va_end(Args);
1161  return strRetval;
1162 }
1163 
1164 /**************************************************************************/
1169 /**************************************************************************/
1170 inline /*static*/ TString TString::format(const IString& rFormat, ...)
1171 {
1172  va_list Args;
1173  va_start(Args, rFormat);
1174  TString strRetval = formatV(rFormat, Args);
1175  va_end(Args);
1176  return strRetval;
1177 }
1178 
1179 
1180 /**************************************************************************/
1183 /**************************************************************************/
1184 inline const wchar_t* MQUALIFIER TString::c_bstr() const
1185 {
1186  //assert(m_pWBuffer != NULL);
1187  return m_pWBuffer;
1188 }
1189 
1190 /**************************************************************************/
1193 /**************************************************************************/
1194 inline const char* MQUALIFIER TString::c_str(bool* pError) const
1195 {
1196  return convToCStr(m_pWBuffer, pError);
1197 }
1198 
1199 /**************************************************************************/
1202 /**************************************************************************/
1203 inline bool MQUALIFIER TString::isFloat() const
1204 {
1205  bool bError = false;
1206  toFloat(0, &bError);
1207  return !bError;
1208 }
1209 
1210 
1211 /**************************************************************************/
1214 /**************************************************************************/
1215 inline bool MQUALIFIER TString::isInt() const
1216 {
1217  bool bError = false;
1218  toInt(0, &bError);
1219  return !bError;
1220 }
1221 
1222 
1223 /**************************************************************************/
1226 /**************************************************************************/
1227 inline bool MQUALIFIER TString::isBool() const
1228 {
1229  bool bError = false;
1230  toBool(false, &bError);
1231  return !bError;
1232 }
1233 
1234 
1235 /**************************************************************************/
1238 /**************************************************************************/
1239 inline bool MQUALIFIER TString::equalsStr(const IString& rInstr, bool bIgnoreCase /*= false*/) const
1240 {
1241  return this->equals(rInstr.c_bstr(), bIgnoreCase);
1242 }
1243 
1244 /**************************************************************************/
1247 /**************************************************************************/
1248 inline void MQUALIFIER TString::concatStr(const IString& rInstr)
1249 {
1250  concat(rInstr.c_bstr());
1251 }
1252 
1253 /**************************************************************************/
1256 /**************************************************************************/
1257 inline void MQUALIFIER TString::assignStr(const IString& rInstr)
1258 {
1259  this->assign(rInstr.c_bstr());
1260 }
1261 
1262 
1263 /**************************************************************************/
1266 /**************************************************************************/
1267 inline wchar_t MQUALIFIER TString::getChar(Int iIndex) const
1268 {
1269  wchar_t wcRetval = 0x0000;
1270  Int iCounter = getSize();
1271 
1272  if (iIndex < iCounter && iIndex >= 0 && m_pWBuffer != NULL)
1273  {
1274  wcRetval = m_pWBuffer[iIndex];
1275  }
1276  return wcRetval;
1277 }
1278 
1279 /**************************************************************************/
1282 /**************************************************************************/
1283 inline Int MQUALIFIER TString::getSize() const
1284 {
1285  return m_iSize;
1286 }
1287 
1288 /**************************************************************************/
1291 /**************************************************************************/
1292 inline Int MQUALIFIER TString::getFirstPos(const wchar_t* pSubBuffer) const
1293 {
1294  return getPos(0, pSubBuffer);
1295 }
1296 
1297 /**************************************************************************/
1300 /**************************************************************************/
1301 inline Int MQUALIFIER TString::getFirstPosStr(const IString& rSubString)const
1302 {
1303  return getPos(0, rSubString.c_bstr());
1304 }
1305 
1306 /**************************************************************************/
1309 /**************************************************************************/
1310 inline Int MQUALIFIER TString::getLastPosStr(const IString& rSubString)const
1311 {
1312  return getLastPos(rSubString.c_bstr());
1313 }
1314 
1315 
1316 /**************************************************************************/
1319 /**************************************************************************/
1321 {
1322  if (m_pWBuffer != NULL)
1323  {
1324  m_pWBuffer[0] = 0;
1325  } // m_pWBuffer != NULL.
1326 
1327  m_iSize = 0;
1328 }
1329 
1330 
1331 /**************************************************************************/
1334 /**************************************************************************/
1335 inline bool MQUALIFIER TString::isEmpty()const
1336 {
1337  return (getSize() == 0);
1338 }
1339 
1340 /**************************************************************************/
1343 /**************************************************************************/
1344 inline bool MQUALIFIER TString::endsWith(const wchar_t* pString)const
1345 {
1346  return this->endsWithStr(TString(pString));
1347 }
1348 
1349 /**************************************************************************/
1352 /**************************************************************************/
1353 inline bool MQUALIFIER TString::startsWith(const wchar_t* pString)const
1354 {
1355  return this->startsWithStr(TString(pString));
1356 }
1357 
1358 /**************************************************************************/
1361 /**************************************************************************/
1362 inline bool MQUALIFIER TString::contains(const wchar_t* pSubString) const
1363 {
1364  return this->containsStr(TString(pSubString));
1365 }
1366 
1367 /**************************************************************************/
1370 /**************************************************************************/
1371 inline bool MQUALIFIER TString::containsStr(const IString& rSubString) const
1372 {
1373  return (this->getFirstPosStr(rSubString) >= 0);
1374 }
1375 
1376 /**************************************************************************/
1379 /**************************************************************************/
1380 inline Int MQUALIFIER TString::getPosOfStr(Int iStartIndex, const IString& rSubString) const
1381 {
1382  return getPos(iStartIndex, rSubString.c_bstr());
1383 }
1384 
1385 /**************************************************************************/
1389 /**************************************************************************/
1390 inline TString& TString::operator=(const TString& rInstr)
1391 {
1392  assign(rInstr.m_pWBuffer);
1393  return *this;
1394 }
1395 
1396 /**************************************************************************/
1400 /**************************************************************************/
1401 inline TString& TString::operator=(const IString& rInstr)
1402 {
1403  assign(rInstr.c_bstr());
1404  return *this;
1405 }
1406 
1407 
1408 /**************************************************************************/
1412 /**************************************************************************/
1413 inline TString& TString::operator=(const IString* pInstr)
1414 {
1415  if (pInstr == NULL)
1416  {
1417  clear();
1418  } // pInstr == NULL.
1419  else
1420  {
1421  assignStr(*pInstr);
1422  } // pInstr != NULL.
1423 
1424  return *this;
1425 }
1426 
1427 
1428 /**************************************************************************/
1432 /**************************************************************************/
1433 inline TString& TString::operator=(const wchar_t* pData)
1434 {
1435  assign(pData);
1436  return *this;
1437 }
1438 
1439 /**************************************************************************/
1443 /**************************************************************************/
1444 inline TString& TString::operator=(const Int iData)
1445 {
1446  #if defined(__ZEUS32__)
1447  this->assignInt32(iData);
1448  #elif defined(__ZEUS64__)
1449  this->assignInt64(iData);
1450  #else
1451  #error "TString::operator =(const Int iData): assign operator not implemented for this platform"
1452  #endif
1453  return *this;
1454 }
1455 
1456 /**************************************************************************/
1460 /**************************************************************************/
1461 inline TString& TString::operator=(const int iData)
1462 {
1463  #if defined(__ZEUS32__)
1464  this->assignInt32(iData);
1465  #elif defined(__ZEUS64__)
1466  this->assignInt64(iData);
1467  #else
1468  #error "TString::operator =(const int iData): assign operator not implemented for this platform"
1469  #endif
1470  return *this;
1471 }
1472 
1473 /**************************************************************************/
1477 /**************************************************************************/
1478 inline TString& TString::operator=(const Uint uiData)
1479 {
1480  #if defined(__ZEUS32__)
1481  this->assignUint32(static_cast<Uint32>(uiData));
1482  #elif defined(__ZEUS64__)
1483  this->assignUint64(static_cast<Uint32>(uiData));
1484  #else
1485  #error "TString::operator =(const Uint uiData): assign operator not implemented for this platform"
1486  #endif
1487  return *this;
1488 }
1489 
1490 /**************************************************************************/
1494 /**************************************************************************/
1495 inline TString& TString::operator=(const unsigned int uiData)
1496 {
1497  #if defined(__ZEUS32__)
1498  this->assignUint32(static_cast<Uint32>(uiData));
1499  #elif defined(__ZEUS64__)
1500  this->assignUint64(static_cast<Uint32>(uiData));
1501  #else
1502  #error "TString::operator =(const unsigned int uiData): assign operator not implemented for this platform"
1503  #endif
1504  return *this;
1505 }
1506 
1507 /**************************************************************************/
1511 /**************************************************************************/
1512 inline TString& TString::operator=(const Float fData)
1513 {
1514  TString strValue = convertDouble(fData);
1515  this->assign(strValue.m_pWBuffer);
1516  return *this;
1517 }
1518 
1519 
1520 /**************************************************************************/
1524 /**************************************************************************/
1525 inline TString& TString::operator=(const char* pData)
1526 {
1527  m_pWBuffer = convToWStr(pData);
1528  return *this;
1529 }
1530 
1531 
1532 /**************************************************************************/
1536 /**************************************************************************/
1537 inline TString& TString::operator=(bool bData)
1538 {
1539  assignInt32(bData);
1540  return *this;
1541 }
1542 
1543 
1544 #ifdef USE_STL_BINDINGS
1545 /***************************************************************************/
1549 /***************************************************************************/
1550 inline TString& TString::operator=(const std::wstring& rInstr)
1551 {
1552  assign(rInstr.c_str());
1553  return *this;
1554 }
1555 
1556 /***************************************************************************/
1560 /***************************************************************************/
1561 inline TString& TString::operator=(const std::string& rInstr)
1562 {
1563  m_pWBuffer = convToWStr(rInstr.c_str());
1564  return *this;
1565 }
1566 #endif //USE_STL_BINDINGS
1567 
1568 /**************************************************************************/
1572 /**************************************************************************/
1573 inline bool TString::operator==(const TString& rInstr)const
1574 {
1575  return equals(rInstr.m_pWBuffer);
1576 }
1577 
1578 /**************************************************************************/
1582 /**************************************************************************/
1583 inline bool TString::operator==(const IString& rInstr)const
1584 {
1585  return equals(rInstr.c_bstr());
1586 }
1587 
1588 
1589 /**************************************************************************/
1594 /**************************************************************************/
1595 inline bool TString::operator==(const IString* pInstr) const
1596 {
1597  return equals(pInstr == NULL ? NULL : pInstr->c_bstr());
1598 }
1599 
1600 
1601 /**************************************************************************/
1605 /**************************************************************************/
1606 inline bool TString::operator==(const wchar_t* pInbuffer) const
1607 {
1608  return equals(pInbuffer);
1609 }
1610 
1611 /**************************************************************************/
1615 /**************************************************************************/
1616 inline bool TString::operator==(const char* inbuffer)const
1617 {
1618  TString str(inbuffer);
1619  return equals(str.m_pWBuffer);
1620 }
1621 
1622 /**************************************************************************/
1626 /**************************************************************************/
1627 inline bool TString::operator==(const Float fData) const
1628 {
1629  TString strFormat = convertDouble(fData);
1630  return equals(strFormat.m_pWBuffer);
1631 }
1632 
1633 /**************************************************************************/
1637 /**************************************************************************/
1638 inline bool TString::operator==(const Int iData) const
1639 {
1640  TString strData(iData);
1641  return equalsStr(strData);
1642 }
1643 
1644 /**************************************************************************/
1648 /**************************************************************************/
1649 inline bool TString::operator==(const int iData) const
1650 {
1651  TString strData(iData);
1652  return equalsStr(strData);
1653 }
1654 
1655 /**************************************************************************/
1659 /**************************************************************************/
1660 inline bool TString::operator==(const Uint uiData) const
1661 {
1662  TString strData(uiData);
1663  return equalsStr(strData);
1664 }
1665 
1666 /**************************************************************************/
1670 /**************************************************************************/
1671 inline bool TString::operator==(const unsigned int uiData) const
1672 {
1673  TString strData(uiData);
1674  return equalsStr(strData);
1675 }
1676 
1677 
1678 /**************************************************************************/
1682 /**************************************************************************/
1683 inline bool TString::operator==(bool bData) const
1684 {
1685  TString strData(bData);
1686  return equalsStr(strData);
1687 }
1688 
1689 
1690 #ifdef USE_STL_BINDINGS
1691 /***************************************************************************/
1694 /***************************************************************************/
1695 inline bool TString::operator==(const std::wstring& rInstr)const
1696 {
1697  TString str(rInstr.c_str());
1698  return equals(str.m_pWBuffer);
1699 }
1700 
1701 /***************************************************************************/
1704 /***************************************************************************/
1705 inline bool TString::operator==(const std::string& rInstr)const
1706 {
1707  TString str(rInstr.c_str());
1708  return equals(str.m_pWBuffer);
1709 }
1710 #endif // USE_STL_BINDINGS
1711 
1712 /**************************************************************************/
1716 /**************************************************************************/
1717 inline TString TString::operator+ (const TString& rInstr) const
1718 {
1719  TString str(this->m_pWBuffer);
1720  str.concat(rInstr.m_pWBuffer);
1721  return str;
1722 }
1723 
1724 /**************************************************************************/
1728 /**************************************************************************/
1729 inline TString TString::operator+ (const IString& rInstr) const
1730 {
1731  TString str(this->m_pWBuffer);
1732  str.concat(rInstr.c_bstr());
1733  return str;
1734 }
1735 
1736 /**************************************************************************/
1740 /**************************************************************************/
1741 inline TString TString::operator+ (const wchar_t* pInbuffer) const
1742 {
1743  TString str(this->m_pWBuffer);
1744  str.concat(pInbuffer);
1745  return str;
1746 }
1747 
1748 /**************************************************************************/
1752 /**************************************************************************/
1753 inline TString TString::operator+ (const char* pInbuffer) const
1754 {
1755  TString str(this->m_pWBuffer);
1756  TString strC(pInbuffer);
1757  str.concat(strC.m_pWBuffer);
1758  return str;
1759 }
1760 
1761 /**************************************************************************/
1765 /**************************************************************************/
1766 inline TString TString::operator+ (const wchar_t wc) const
1767 {
1768  TString str(this->m_pWBuffer);
1769 
1770  wchar_t wcBuffer[2] = { wc, 0 };
1771  str.concat(wcBuffer);
1772  return str;
1773 }
1774 
1775 /**************************************************************************/
1779 /**************************************************************************/
1780 inline TString TString::operator+ (const char c) const
1781 {
1782  TString str(this->m_pWBuffer);
1783 
1784  wchar_t wcBuffer[2] = { (wchar_t)c, 0 };
1785  str.concat(wcBuffer);
1786  return str;
1787 }
1788 
1789 /**************************************************************************/
1793 /**************************************************************************/
1794 inline TString TString::operator+ (const Int iInval) const
1795 {
1796  TString str(this->m_pWBuffer);
1797  TString strInval(iInval);
1798  str.concatStr(strInval);
1799  return str;
1800 }
1801 
1802 /**************************************************************************/
1806 /**************************************************************************/
1807 inline TString TString::operator+ (const int iInval) const
1808 {
1809  TString str(this->m_pWBuffer);
1810  TString strInval(iInval);
1811  str.concatStr(strInval);
1812  return str;
1813 }
1814 
1815 /**************************************************************************/
1819 /**************************************************************************/
1820 inline TString TString::operator+ (const Uint uiInval) const
1821 {
1822  TString str(this->m_pWBuffer);
1823  TString strInval(uiInval);
1824  str.concatStr(strInval);
1825  return str;
1826 }
1827 
1828 /**************************************************************************/
1832 /**************************************************************************/
1833 inline TString TString::operator+ (const unsigned int uiInval) const
1834 {
1835  TString str(this->m_pWBuffer);
1836  TString strInval(uiInval);
1837  str.concatStr(strInval);
1838  return str;
1839 }
1840 
1841 /**************************************************************************/
1845 /**************************************************************************/
1846 inline TString TString::operator+ (const Float fInval) const
1847 {
1848  TString strTmp(this->m_pWBuffer);
1849  TString strConv = convertDouble(fInval);
1850  strTmp.concatStr(strConv);
1851  return strTmp;
1852 }
1853 
1854 #ifdef USE_STL_BINDINGS
1855 
1856 /***************************************************************************/
1859 /***************************************************************************/
1860 inline TString TString::operator+ (const std::wstring& rInstr) const
1861 {
1862  TString str(this->m_pWBuffer);
1863  TString strC(rInstr.c_str());
1864  str.concat(strC.m_pWBuffer);
1865  return str;
1866 }
1867 
1868 /***************************************************************************/
1871 /***************************************************************************/
1872 inline TString TString::operator+ (const std::string& rInstr) const
1873 {
1874  TString str(this->m_pWBuffer);
1875  TString strC(rInstr.c_str());
1876  str.concat(strC.m_pWBuffer);
1877  return str;
1878 }
1879 #endif //USE_STL_BINDINGS
1880 
1881 /**************************************************************************/
1885 /**************************************************************************/
1886 inline bool TString::operator!=(const TString& rInstr) const
1887 {
1888  return !(equals(rInstr.m_pWBuffer));
1889 }
1890 
1891 /**************************************************************************/
1895 /**************************************************************************/
1896 inline bool TString::operator!=(const IString& rInstr) const
1897 {
1898  return !(equals(rInstr.c_bstr()));
1899 }
1900 
1901 
1902 /**************************************************************************/
1907 /**************************************************************************/
1908 inline bool TString::operator!=(const IString* pInstr) const
1909 {
1910  return !equals(pInstr == NULL ? NULL : pInstr->c_bstr());
1911 }
1912 
1913 
1914 /**************************************************************************/
1918 /**************************************************************************/
1919 inline bool TString::operator!=(const wchar_t* pInbuffer)const
1920 {
1921  return !(equals(pInbuffer));
1922 }
1923 
1924 /**************************************************************************/
1928 /**************************************************************************/
1929 inline bool TString::operator!=(const char* pInbuffer) const
1930 {
1931  TString str(pInbuffer);
1932  return !(equals(str.m_pWBuffer));
1933 }
1934 
1935 /**************************************************************************/
1939 /**************************************************************************/
1940 inline bool TString::operator!=(const Float fData) const
1941 {
1942  TString str(fData);
1943  return !(equals(str.m_pWBuffer));
1944 }
1945 
1946 /**************************************************************************/
1950 /**************************************************************************/
1951 inline bool TString::operator!=(const Int iData) const
1952 {
1953  TString str(iData);
1954  return !(equals(str.m_pWBuffer));
1955 }
1956 
1957 /**************************************************************************/
1961 /**************************************************************************/
1962 inline bool TString::operator!=(const int iData) const
1963 {
1964  TString str(iData);
1965  return !(equals(str.m_pWBuffer));
1966 }
1967 
1968 /**************************************************************************/
1972 /**************************************************************************/
1973 inline bool TString::operator!=(const Uint uiData) const
1974 {
1975  TString str(uiData);
1976  return !(equals(str.m_pWBuffer));
1977 }
1978 
1979 /**************************************************************************/
1983 /**************************************************************************/
1984 inline bool TString::operator!=(const unsigned int uiData) const
1985 {
1986  TString str(uiData);
1987  return !(equals(str.m_pWBuffer));
1988 }
1989 
1990 
1991 /**************************************************************************/
1994 /**************************************************************************/
1995 inline bool TString::operator!=(bool bData) const
1996 {
1997  TString str(bData);
1998  return !(equals(str.m_pWBuffer));
1999 }
2000 
2001 
2002 #ifdef USE_STL_BINDINGS
2003 /***************************************************************************/
2006 /***************************************************************************/
2007 inline bool TString::operator!=(const std::wstring& rInstr) const
2008 {
2009  TString str(rInstr.c_str());
2010  return !equals(str.m_pWBuffer);
2011 }
2012 
2013 /***************************************************************************/
2016 /***************************************************************************/
2017 inline bool TString::operator!=(const std::string& rInstr) const
2018 {
2019  TString str(rInstr.c_str());
2020  return !equals(str.m_pWBuffer);
2021 }
2022 #endif //USE_STL_BINDINGS
2023 
2024 /**************************************************************************/
2029 /**************************************************************************/
2030 inline TString& TString::operator+= (const TString& rInstr)
2031 {
2032  this->concatStr(rInstr);
2033  return *this;
2034 }
2035 
2036 /**************************************************************************/
2041 /**************************************************************************/
2042 inline TString& TString::operator+= (const IString& rInstr)
2043 {
2044  this->concatStr(rInstr);
2045  return *this;
2046 }
2047 
2048 /**************************************************************************/
2053 /**************************************************************************/
2054 inline TString& TString::operator+= (const wchar_t* pInbuffer)
2055 {
2056  this->concat(pInbuffer);
2057  return *this;
2058 }
2059 
2060 /**************************************************************************/
2065 /**************************************************************************/
2066 inline TString& TString::operator+= (const char* pInbuffer)
2067 {
2068  TString strInBuffer(pInbuffer);
2069  this->concatStr(strInBuffer);
2070  return *this;
2071 }
2072 
2073 
2074 /**************************************************************************/
2081 /**************************************************************************/
2082 inline TString& TString::operator+=(const wchar_t wc)
2083 {
2084  wchar_t wcBuffer[2] = { wc, 0 };
2085  concat(wcBuffer);
2086 
2087  return *this;
2088 }
2089 
2090 
2091 /**************************************************************************/
2098 /**************************************************************************/
2099 inline TString& TString::operator+=(const char c)
2100 {
2101  wchar_t wcBuffer[2] = { (wchar_t)c, 0 };
2102  concat(wcBuffer);
2103 
2104  return *this;
2105 }
2106 
2107 
2108 /**************************************************************************/
2113 /**************************************************************************/
2114 inline TString& TString::operator+= (const Int iInval)
2115 {
2116  TString strInVal(iInval);
2117  this->concatStr(strInVal);
2118  return *this;
2119 }
2120 
2121 /**************************************************************************/
2126 /**************************************************************************/
2127 inline TString& TString::operator+= (const int iInval)
2128 {
2129  TString strInVal(iInval);
2130  this->concatStr(strInVal);
2131  return *this;
2132 }
2133 
2134 /**************************************************************************/
2139 /**************************************************************************/
2140 inline TString& TString::operator+= (const Uint uiInval)
2141 {
2142  TString strInVal(uiInval);
2143  this->concatStr(strInVal);
2144  return *this;
2145 }
2146 
2147 /**************************************************************************/
2152 /**************************************************************************/
2153 inline TString& TString::operator+= (const unsigned int uiInval)
2154 {
2155  TString strInVal(uiInval);
2156  this->concatStr(strInVal);
2157  return *this;
2158 }
2159 
2160 /**************************************************************************/
2165 /**************************************************************************/
2166 inline TString& TString::operator+= (const Float fInval)
2167 {
2168  TString strInVal(fInval);
2169  this->concatStr(strInVal);
2170  return *this;
2171 }
2172 
2173 #ifdef USE_STL_BINDINGS
2174 /***************************************************************************/
2178 /***************************************************************************/
2179 inline TString& TString::operator+= (const std::wstring& rInstr)
2180 {
2181  TString strIn(rInstr.c_str());
2182  this->concatStr(strIn);
2183  return *this;
2184 }
2185 
2186 /***************************************************************************/
2190 /***************************************************************************/
2191 inline TString& TString::operator+= (const std::string& rInstr)
2192 {
2193  TString strIn(rInstr.c_str());
2194  this->concatStr(strIn);
2195  return *this;
2196 }
2197 #endif
2198 
2199 /**************************************************************************/
2204 /**************************************************************************/
2205 inline wchar_t& TString::operator[](Int iIndex)
2206 {
2207  Int iCounter = getSize();
2208  if (iIndex < iCounter && iIndex >= 0 && m_pWBuffer != NULL)
2209  {
2210  return m_pWBuffer[iIndex]; //NOT POSSIBLE FOR ONE IN ONE OUT
2211  }
2212  else
2213  {
2214  m_wcEmpty = 0x0000;
2215  return m_wcEmpty; //NOT POSSIBLE FOR ONE IN ONE OUT
2216  }
2217 }
2218 
2219 /**************************************************************************/
2226 /**************************************************************************/
2227 inline bool TString::operator<(const TString& rInStr) const
2228 {
2229  return (this->compareTo(rInStr) < 0);
2230 }
2231 
2232 /**************************************************************************/
2239 /**************************************************************************/
2240 inline bool TString::operator<=(const TString& rInStr) const
2241 {
2242  return (this->compareTo(rInStr) <= 0);
2243 }
2244 
2245 /**************************************************************************/
2252 /**************************************************************************/
2253 inline bool TString::operator>(const TString& rInStr) const
2254 {
2255  return (this->compareTo(rInStr) > 0);
2256 }
2257 
2258 /**************************************************************************/
2265 /**************************************************************************/
2266 inline bool TString::operator>=(const TString& rInStr) const
2267 {
2268  return (this->compareTo(rInStr) >= 0);
2269 }
2270 
2271 
2272 //-----------------------------------------------------------------
2273 // GLOBAL OPERATORS
2274 
2275 /***************************************************************************/
2278 /***************************************************************************/
2279 inline TString operator+ (wchar_t* pIn, const TString& rIn2)
2280 {
2281  return (TString(pIn) + rIn2);
2282 }
2283 
2284 /***************************************************************************/
2287 /***************************************************************************/
2288 inline bool operator== (const IString& rInStr1, const wchar_t* pInStr2)
2289 {
2290  return (TString(pInStr2) == rInStr1);
2291 }
2292 
2293 /***************************************************************************/
2296 /***************************************************************************/
2297 inline bool operator== (const wchar_t* pInStr1, const IString& rInStr2)
2298 {
2299  return (TString(pInStr1) == rInStr2);
2300 }
2301 
2302 /***************************************************************************/
2305 /***************************************************************************/
2306 inline bool operator== (const IString& rInStr1, const char* pInStr2)
2307 {
2308  return (TString(pInStr2) == rInStr1);
2309 }
2310 
2311 /***************************************************************************/
2314 /***************************************************************************/
2315 inline bool operator== (const char* pInStr1, const IString& rInStr2)
2316 {
2317  return (TString(pInStr1) == rInStr2);
2318 }
2319 
2320 /***************************************************************************/
2323 /***************************************************************************/
2324 inline bool operator!=(const IString& rInStr1, const wchar_t* pInStr2)
2325 {
2326  return (TString(pInStr2) != rInStr1);
2327 }
2328 
2329 /***************************************************************************/
2332 /***************************************************************************/
2333 inline bool operator!=(const wchar_t* pInStr1, const IString& rInStr2)
2334 {
2335  return (TString(pInStr1) != rInStr2);
2336 }
2337 
2338 /***************************************************************************/
2341 /***************************************************************************/
2342 inline bool operator!=(const IString& rInStr1, const char* pInStr2)
2343 {
2344  return (TString(pInStr2) != rInStr1);
2345 }
2346 
2347 /***************************************************************************/
2350 /***************************************************************************/
2351 inline bool operator!=(const char* pInStr1, const IString& rInStr2)
2352 {
2353  return (TString(pInStr1) != rInStr2);
2354 }
2355 
2356 #ifdef USE_STL_BINDINGS
2357 /***************************************************************************/
2360 /***************************************************************************/
2361 inline void operator<<(std::string& rOutstr, const TString& rInstr)
2362 {
2363  rOutstr = rInstr.c_str(NULL);
2364 }
2365 
2366 /***************************************************************************/
2369 /***************************************************************************/
2370 inline void operator<<(std::wstring& rOutstr, const TString& rInstr)
2371 {
2372  rOutstr = rInstr.c_bstr();
2373 }
2374 #endif //USE_STL_BINDINGS
2375 
2376 
2378 
2379 #endif
#define END_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:96
TString operator+(wchar_t *pIn, const TString &rIn2)
Definition: String.h:2279
virtual void MQUALIFIER concatStr(const IString &rInstr)
Definition: String.h:1248
TString replace(const IString &rToRemove, const IString &rReplace, Int *pReplaces=NULL) const
Definition: String.cpp:1512
Definition: ByteArray.hpp:46
TString replaceFirst(const IString &rToRemove, const IString &rReplace) const
Definition: String.cpp:1413
#define zeusbase_class
Definition: PlatformDefines.hpp:165
static void detectHeader_internal(const IByteArray &rList, Int &riStartIndex, EStringEncoding &reEncoding)
Definition: String.cpp:1869
static TString format(const char *pcFormat,...)
Definition: String.h:1140
Definition: String.h:410
static TString transcodeFromUTF_8(const IByteArray &rList)
Definition: String.h:714
virtual Int MQUALIFIER getCount() const =0
TString terminated(const IString &rTermination) const
Definition: String.h:1063
virtual bool MQUALIFIER isFloat() const
Definition: String.h:1203
virtual bool MQUALIFIER toBool(bool bPredef=false, bool *pbError=NULL) const
Definition: String.cpp:685
static TString transcodeFromUTF_32(const IByteArray &rList)
Definition: String.h:755
virtual bool MQUALIFIER startsWith(const wchar_t *pString) const
Definition: String.h:1353
virtual bool MQUALIFIER startsWithStr(const IString &rString) const
Definition: String.cpp:1053
TString enquoted() const
Definition: String.h:1102
const wchar_t * getPtrOfFirstStr(const IString &rSubString) const
Definition: String.cpp:1660
static TString transcodeFromUTF_16(const IByteArray &rList)
Definition: String.h:735
TString()
Definition: String.cpp:80
virtual void MQUALIFIER assignStr(const IString &rInstr)
Definition: String.h:1257
bool operator>=(const TString &rInStr) const
Definition: String.h:2266
virtual Int MQUALIFIER getLastPosStr(const IString &rSubString) const
Definition: String.h:1310
virtual bool MQUALIFIER equalsStr(const IString &rInstr, bool bIgnoreCase=false) const
Definition: String.h:1239
virtual Int MQUALIFIER getPosOfStr(Int iStartIndex, const IString &rSubString) const
Definition: String.h:1380
TString trimRight() const
Definition: String.h:1051
TString remove(const IString &rToRemove, Int *pReplaces=NULL) const
Definition: String.h:930
virtual void MQUALIFIER clear()
Definition: String.h:1320
TString operator+(const TString &rInstr) const
Definition: String.h:1717
virtual Int MQUALIFIER getFirstPos(const wchar_t *pSubBuffer) const
Definition: String.h:1292
virtual Int MQUALIFIER getLastPos(const wchar_t *pSubBuffer) const
Definition: String.cpp:967
#define MQUALIFIER
Definition: LinuxPlatform.hpp:64
const wchar_t * getPtrOfStr(Int iStartIndex, const IString &rSubString) const
Definition: String.cpp:1640
static TString transcodeFromISO_8859_1(const IByteArray &rList)
Definition: String.h:703
bool operator==(const TString &rInstr) const
Definition: String.h:1573
virtual Int MQUALIFIER getPos(Int iStartIndex, const wchar_t *pSubBuffer) const
Definition: String.cpp:879
TString & operator+=(const TString &rInstr)
Definition: String.h:2030
unsigned long long Uint64
Definition: PlatformDefines.hpp:252
virtual bool MQUALIFIER contains(const wchar_t *pSubString) const
Definition: String.h:1362
Int getFirstCharPos(const wchar_t wcChar) const
Definition: String.cpp:1161
#define BEGIN_NAMESPACE_Zeus
Definition: PlatformDefines.hpp:95
TString getSubString(Int iStartIndex, Int iEndIndex=IntMax) const
Definition: String.cpp:1205
long Int32
Definition: PlatformDefines.hpp:237
virtual wchar_t MQUALIFIER getChar(Int iIndex) const
Definition: String.h:1267
const wchar_t * getPtrOfLastStr(const IString &rSubString) const
Definition: String.cpp:1680
virtual const T &MQUALIFIER getItemConst(Int iIndex) const =0
virtual Int MQUALIFIER getFirstPosStr(const IString &rSubString) const
Definition: String.h:1301
#define INIT_TSTRING
Definition: String.h:94
bool operator<=(const TString &rInStr) const
Definition: String.h:2240
virtual bool MQUALIFIER isBool() const
Definition: String.h:1227
TString enclosed(const IString &rEnclosure) const
Definition: String.h:1083
virtual bool MQUALIFIER isEmpty() const
Definition: String.h:1335
virtual void MQUALIFIER assign(const wchar_t *pInbuffer)
Definition: String.cpp:811
virtual bool MQUALIFIER equals(const wchar_t *pInbuffer, bool bIgnoreCase=false) const
Definition: String.cpp:719
virtual void MQUALIFIER concat(const wchar_t *pInbuffer)
Definition: String.cpp:755
Definition: String.h:113
#define BOOL_ERRORRETVAL(c)
Definition: RetvalDefines.hpp:111
TString trimLeft() const
Definition: String.h:1040
TString deleteRight(Int iCharCount) const
Definition: String.h:904
bool operator<(const TString &rInStr) const
Definition: String.h:2227
long long Int64
Definition: PlatformDefines.hpp:251
TString insert(Int iIndex, const IString &rStrToInsert) const
Definition: String.cpp:1363
Definition: String.h:411
EStringEncoding
Definition: String.h:408
Definition: String.h:413
TString & operator=(const TString &rInstr)
Definition: String.h:1390
unsigned long Uint32
Definition: PlatformDefines.hpp:241
static TByteArray transcodeToISO_8859_1(const IString &rValue, bool bNullTerminated=true)
Definition: String.h:783
bool operator==(const char *pInStr1, const IString &rInStr2)
Definition: String.h:2315
TString getRight(Int iCharCount) const
Definition: String.h:863
bool containsChar(const wchar_t wcChar) const
Definition: String.h:837
unsigned char Uint8
Definition: PlatformDefines.hpp:212
TString removeFirst(const IString &rToRemove) const
Definition: String.h:955
TString trim() const
Definition: String.h:1029
static TString formatV(const char *pcFormat, va_list Arg)
Definition: String.cpp:1770
virtual const wchar_t *MQUALIFIER c_bstr() const =0
virtual ~TString()
Definition: String.h:179
static TByteArray transcodeToUTF_32(const IString &rValue, bool bNullTerminated=true, bool bAddHeader=true)
Definition: String.h:825
virtual bool MQUALIFIER containsStr(const IString &rSubString) const
Definition: String.h:1371
virtual const wchar_t *MQUALIFIER c_bstr() const
Definition: String.h:1184
virtual Float MQUALIFIER toFloat(Float fPredef=0.0, bool *pbError=NULL) const
Definition: String.cpp:375
virtual bool MQUALIFIER isInt() const
Definition: String.h:1215
static TString transcode_internal(const IByteArray &rList, Int iStartIndex, EStringEncoding eEncoding)
Definition: String.cpp:1924
TString deleteLeft(Int iCharCount) const
Definition: String.h:876
Definition: String.h:412
static TString trimExt(const IString &rSource, const IString &rChars, bool bLeft=true, bool bRight=true)
Definition: String.cpp:2311
virtual Int MQUALIFIER getSize() const
Definition: String.h:1283
bool operator!=(const TString &rInstr) const
Definition: String.h:1886
wchar_t & operator[](Int iIndex)
Definition: String.h:2205
TString getLeft(Int iCharCount) const
Definition: String.h:850
static TByteArray transcodeToUTF_16(const IString &rValue, bool bNullTerminated=true, bool bAddHeader=true)
Definition: String.h:811
bool operator>(const TString &rInStr) const
Definition: String.h:2253
static TByteArray transcodeToUTF_8(const IString &rValue, bool bNullTerminated=true, bool bAddHeader=true)
Definition: String.h:797
bool operator!=(const char *pInStr1, const IString &rInStr2)
Definition: String.h:2351
virtual Int MQUALIFIER compareTo(const IString &rString) const
Definition: String.cpp:1064
static TString convertDouble(const Float &rfValue, Int iDigit=15)
Definition: String.cpp:2527
static TString transcode(const IByteArray &rList)
Definition: String.h:689
virtual bool MQUALIFIER endsWithStr(const IString &rString) const
Definition: String.cpp:1042
virtual bool MQUALIFIER endsWith(const wchar_t *pString) const
Definition: String.h:1344
bool operator<(const TypGUID &rGUID1, const TypGUID &rGUID2)
Definition: GUIDWrapper.h:290
virtual Int MQUALIFIER toInt(Int iPredef=0, bool *pbError=NULL) const
Definition: String.cpp:443
Definition: IString.hpp:48
virtual const char *MQUALIFIER c_str(bool *pError) const
Definition: String.h:1194


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Tue Sep 13 2016 22:30:50