00001
00293 #ifndef INC_MI32_MISTRING_H
00294 #define INC_MI32_MISTRING_H
00295
00296 #ifndef INC_MI32_CHARENCODING_H
00297 #include <mi32/charencoding.h>
00298 #endif
00299
00300 #ifdef MISYSTEMDLL
00301 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00302 #else
00303 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00304 #endif
00305
00306
00307 #ifndef GENERATING_DOXYGEN_OUTPUT
00308 class MISTRINGLIST;
00309 class STRUTF8;
00310 class UCREGEXP;
00311 #endif // GENERATING_DOXYGEN_OUTPUT
00312
00313
00315 enum STR_OP {
00316 STR_Clear = 0,
00317 STR_BoolL = 1,
00318 STR_BoolM = 2,
00319 STR_BoolU = 3,
00320 STR_FillA = 4,
00321 STR_FillB = 5,
00322 STR_FillD = 6,
00323 STR_Sep000 = 7,
00324 STR_SepNone = 8,
00325 STR_Strip0 = 9,
00326 STR_FillSubs = 10,
00327 STR_FltE = 11,
00328 STR_FltF = 12,
00329 STR_FltG = 13,
00330 STR_FltM = 60,
00331 STR_Bin = 14,
00332 STR_Dec = 15,
00333 STR_Hex = 16,
00334 STR_FillSp = 17,
00335 STR_Fill0 = 18,
00336 STR_PrecA = 19,
00337 STR_Prec0 = 20,
00338 STR_Prec1 = 21,
00339 STR_Prec2 = 22,
00340 STR_Prec3 = 23,
00341 STR_Prec4 = 24,
00342 STR_Prec5 = 25,
00343 STR_Prec6 = 26,
00344 STR_Prec7 = 27,
00345 STR_Prec8 = 28,
00346 STR_Prec9 = 29,
00347 STR_Prec10 = 30,
00348 STR_Prec11 = 31,
00349 STR_Prec12 = 32,
00350 STR_Prec13 = 33,
00351 STR_Prec14 = 34,
00352 STR_Prec15 = 35,
00353 STR_Prec16 = 36,
00354 STR_Width0 = 40,
00355 STR_Width1 = 41,
00356 STR_Width2 = 42,
00357 STR_Width3 = 43,
00358 STR_Width4 = 44,
00359 STR_Width5 = 45,
00360 STR_Width6 = 46,
00361 STR_Width7 = 47,
00362 STR_Width8 = 48,
00363 STR_Width9 = 49,
00364 STR_Width10 = 50,
00365 STR_Width11 = 51,
00366 STR_Width12 = 52,
00367 STR_Width13 = 53,
00368 STR_Width14 = 54,
00369 STR_Width15 = 55
00370 };
00371
00372
00390 class CLASSLIBEXPORT MISTRING {
00391 public:
00392
00393 enum ENCODING {
00394 ENCODING_URI = 0,
00395 ENCODING_XML = 1,
00396 ENCODING_HTML = 2
00397 };
00398
00399 enum FLOATFMT {
00400 FLOATFMT_General = 0,
00401 FLOATFMT_Fixed = 1,
00402 FLOATFMT_Scientific = 2,
00403 FLOATFMT_MaxPrecision = 3
00404 };
00405
00406 enum LINETERM {
00407 LINETERM_LF = 0,
00408 LINETERM_CR = 1,
00409 LINETERM_CRLF = 2
00410 };
00411
00413 MISTRING (
00414 );
00415
00417 MISTRING (
00418 const MISTRING& rhs
00419 );
00420
00422 MISTRING (
00423 const MIUNICODE *ustr
00424 );
00425
00427 explicit MISTRING (
00428 const char *str
00429 );
00430
00432 MISTRING (
00433 const STRUTF8& rhs
00434 );
00435
00436 #ifndef NODLLLINKAGE
00438 MISTRING (
00439 TEXTID textid
00440 );
00441 #endif
00442
00443 #if 0 // Systems where wchar_t is not same as UINT16(MIUNICODE)
00444 #ifndef GENERATING_DOXYGEN_OUTPUT
00446 explicit MISTRING (
00447 const wchar_t *str
00448 );
00449 #endif // GENERATING_DOXYGEN_OUTPUT
00450 #endif
00451
00453 MISTRING (
00454 const void *str,
00455 CHAR_ENCODING encoding
00456 );
00457
00459 explicit MISTRING (
00460 int value
00461 );
00462
00464 explicit MISTRING (
00465 long value
00466 );
00467
00468 #ifndef LONGS_ARE_64_BIT
00470 explicit MISTRING (
00471 INT64 value
00472 );
00473 #endif
00474
00476 explicit MISTRING (
00477 unsigned int value
00478 );
00479
00481 explicit MISTRING (
00482 unsigned long value
00483 );
00484
00485 #ifndef LONGS_ARE_64_BIT
00487 explicit MISTRING (
00488 UINT64 value
00489 );
00490 #endif
00491
00493 explicit MISTRING (
00494 double value
00495 );
00496
00497 ~MISTRING (
00498 );
00499
00501 MISTRING& operator= (
00502 const MISTRING& rhs
00503 );
00504
00506 MISTRING& operator= (
00507 const STRUTF8& rhs
00508 );
00509
00510 #ifndef NODLLLINKAGE
00512 MISTRING& operator= (
00513 TEXTID textid
00514 );
00515 #endif
00516
00518 MISTRING& operator= (
00519 const MIUNICODE* rhs
00520 );
00521
00523 MISTRING& operator= (
00524 const char* rhs
00525 );
00526
00527 #if 0
00528 #ifndef GENERATING_DOXYGEN_OUTPUT
00530 MISTRING& operator= (
00531 const wchar_t* rhs
00532 );
00533 #endif // GENERATING_DOXYGEN_OUTPUT
00534 #endif
00535
00537 MISTRING& operator+= (
00538 const MISTRING& rhs
00539 );
00540
00542 MISTRING& operator+= (
00543 const MIUNICODE* rhs
00544 );
00545
00547 MISTRING& operator+= (
00548 const char* rhs
00549 );
00550
00551 #if 0 // Systems where wchar_t is not same as UINT16(MIUNICODE)
00552 #ifndef GENERATING_DOXYGEN_OUTPUT
00554 MISTRING& operator+= (
00555 const wchar_t* rhs
00556 );
00557 #endif // GENERATING_DOXYGEN_OUTPUT
00558 #endif
00559
00561 MISTRING& operator+= (
00562 MIUNICODE c
00563 );
00564
00566 MISTRING& operator<< (STR_OP op);
00567
00569 MISTRING& operator<< (bool b);
00570
00572 MISTRING& operator<< (char c);
00573
00575 MISTRING& operator<< (signed char n);
00576
00578 MISTRING& operator<< (unsigned char n);
00579
00581 MISTRING& operator<< (short n);
00582
00584 MISTRING& operator<< (int n);
00585
00587 MISTRING& operator<< (long n);
00588
00589 #ifndef LONGS_ARE_64_BIT
00591 MISTRING& operator<< (INT64 n);
00592 #endif
00593
00596 MISTRING& operator<< (unsigned short n);
00597
00599 MISTRING& operator<< (unsigned int n);
00600
00602 MISTRING& operator<< (unsigned long n);
00603
00604 #ifndef LONGS_ARE_64_BIT
00606 MISTRING& operator<< (UINT64 n);
00607 #endif
00608
00610 MISTRING& operator<< (float f);
00611
00613 MISTRING& operator<< (double f);
00614
00616 MISTRING& operator<< (const char *s);
00617
00619 MISTRING& operator<< (const MIUNICODE *s);
00620
00622 MISTRING& operator<< (const STRUTF8& s);
00623
00625 MISTRING& operator<< (const MISTRING& s);
00626
00627 #ifndef NODLLLINKAGE
00629 MISTRING& operator<< (TEXTID textid);
00630 #endif
00631
00633 const MIUNICODE& operator[] (
00634 int idx
00635 ) const;
00636
00640 operator const MIUNICODE* (
00641 ) const;
00642
00644 void Append (
00645 const MISTRING& str,
00646 int start = 0,
00647 int end = INT32_MAX
00648 );
00649
00651 void Assign (
00652 const MISTRING& str,
00653 int start = 0,
00654 int end = INT32_MAX
00655 );
00656
00658 void Assign (
00659 const MIUNICODE *str,
00660 int start = 0,
00661 int end = INT32_MAX
00662 );
00663
00665 void Assign (
00666 const char *str,
00667 int len
00668 );
00669
00671 void Assign (
00672 const char *str,
00673 CHAR_ENCODING encoding
00674 ) { Assign(static_cast<const void*>(str),encoding); }
00675
00677 void Assign (
00678 const void *str,
00679 CHAR_ENCODING encoding
00680 );
00681
00684 void AssignFromSizeAbbr (
00685 INT64 size
00686 );
00687
00690 bool CheckLineTermination (
00691 LINETERM lineterm
00692 ) const;
00693
00695 void Clear (
00696 );
00697
00700 int Compare (
00701 const MISTRING& str
00702 ) const;
00703
00706 int Compare (
00707 const MISTRING& str,
00708 int len
00709 ) const;
00710
00713 int Compare (
00714 int SrcStart,
00715 const MISTRING& str,
00716 int OtherStart,
00717 int len
00718 ) const;
00719
00723 int Compare (
00724 const char* str
00725 ) const;
00726
00730 int Compare (
00731 const char* str,
00732 int len
00733 ) const;
00734
00738 int Compare (
00739 int SrcStart,
00740 const char* str,
00741 int OtherStart,
00742 int len
00743 ) const;
00744
00749 int Compare (
00750 const STRUTF8& str
00751 ) const;
00752
00757 int Compare (
00758 const STRUTF8& str,
00759 int len
00760 ) const;
00761
00766 int Compare (
00767 int SrcStart,
00768 const STRUTF8& str,
00769 int OtherStart,
00770 int len
00771 ) const;
00772
00776 int CompareNatural (
00777 const MISTRING& str
00778 ) const;
00779
00782 int CompareNoCase (
00783 const MISTRING& str
00784 ) const;
00785
00788 int CompareNoCase (
00789 const MISTRING& str,
00790 int len
00791 ) const;
00792
00795 int CompareNoCase (
00796 int SrcStart,
00797 const MISTRING& str,
00798 int OtherStart,
00799 int len
00800 ) const;
00801
00805 int CompareNoCase (
00806 const char* str
00807 ) const;
00808
00812 int CompareNoCase (
00813 const char* str,
00814 int len
00815 ) const;
00816
00820 int CompareNoCase (
00821 int SrcStart,
00822 const char* str,
00823 int OtherStart,
00824 int len
00825 ) const;
00826
00831 int CompareNoCase (
00832 const STRUTF8& str
00833 ) const;
00834
00839 int CompareNoCase (
00840 const STRUTF8& str,
00841 int len
00842 ) const;
00843
00848 int CompareNoCase (
00849 int SrcStart,
00850 const STRUTF8& str,
00851 int OtherStart,
00852 int len
00853 ) const;
00854
00859 MISTRING& ConvertFrom (
00860 ENCODING Encoding
00861 );
00862
00868 MISTRING& ConvertTo (
00869 ENCODING Encoding
00870 );
00871
00874 double ConvertToDouble (
00875 ) const;
00876
00879 int FindAndReplace (
00880 const MISTRING& search,
00881 const MISTRING& replace,
00882 bool all,
00883 int start = 0
00884 );
00885
00888 int FindAndReplace (
00889 const char *search,
00890 const MISTRING& replace,
00891 bool all,
00892 int start = 0
00893 );
00894
00897 int FindAndReplace (
00898 const char *search,
00899 const char *replace,
00900 bool all,
00901 int start = 0
00902 );
00903
00906 int FindNextAfter (
00907 const MISTRING& str,
00908 int start = 0
00909 ) const;
00910
00913 int FindNextAfter (
00914 const char *str,
00915 int start = 0
00916 ) const;
00917
00920 int FindNextInSet (
00921 const MISTRING& chars,
00922 int start = 0
00923 ) const;
00924
00927 int FindNextNotInSet (
00928 const MISTRING& chars,
00929 int start = 0
00930 ) const;
00931
00934 int FindNextOf (
00935 MIUNICODE c,
00936 int start = 0
00937 ) const;
00938
00941 int FindNextOf (
00942 const MISTRING& str,
00943 int start = 0
00944 ) const;
00945
00948 int FindNextOf (
00949 const char *str,
00950 int start = 0
00951 ) const;
00952
00955 int FindPrevInSet (
00956 const MISTRING& chars,
00957 int start = INT32_MAX
00958 ) const;
00959
00962 int FindPrevNotInSet (
00963 const MISTRING& chars,
00964 int start = INT32_MAX
00965 ) const;
00966
00969 int FindPrevOf (
00970 MIUNICODE c,
00971 int start = INT32_MAX
00972 ) const;
00973
00976 void FmtEnableSubstitution (
00977 bool enable = true
00978 );
00979
00981 void FmtSetBase (
00982 int base
00983 );
00984
00986 void FmtSetFill (
00987 MIUNICODE fill
00988 );
00989
00991 void FmtSetFloat (
00992 FLOATFMT floatmode
00993 );
00994
00996 void FmtSetPrecision (
00997 int precision
00998 );
00999
01002 void FmtSetSign (
01003 bool sign
01004 );
01005
01008 void FmtSetThousandSeparator (
01009 char c
01010 );
01011
01015 void FmtSetWidth (
01016 int width
01017 );
01018
01021 void *GetEncoded (
01022 CHAR_ENCODING encoding
01023 ) const;
01024
01026 static const MISTRING& GetEmpty (
01027 );
01028
01031 int GetLength (
01032 ) const;
01033
01036 const MIUNICODE *GetReference (
01037 ) const;
01038
01041 MIUNICODE *GetString (
01042 ) const;
01043
01046 MISTRING GetSubString (
01047 int start
01048 ) const;
01049
01052 MISTRING GetSubString (
01053 int start,
01054 int end
01055 ) const;
01056
01059 bool IniRead (
01060 INIHANDLE handle,
01061 const char *group,
01062 const char *field
01063 );
01064
01067 bool IniReadML (
01068 INIHANDLE handle,
01069 const char *group,
01070 const char *field
01071 );
01072
01074 void IniWrite (
01075 INIHANDLE handle,
01076 const char *group,
01077 const char *field
01078 ) const;
01079
01081 void IniWriteML (
01082 INIHANDLE handle,
01083 const char *group,
01084 const char *field
01085 ) const;
01086
01089 bool IsEmpty (
01090 ) const;
01091
01092 #ifdef MISYSTEMDLL
01093 #ifndef GENERATING_DOXYGEN_OUTPUT
01094
01095
01096
01102 bool IsLike (
01103 const MISTRING& pattern,
01104 bool bIgnoreCase
01105 ) const;
01106 #endif
01107 #endif
01108
01115 bool IsLike (
01116 const MISTRING& pattern,
01117 bool bIgnoreCase = false,
01118 MIUNICODE WildCard = '%',
01119 MIUNICODE SingleMatchChar = '_',
01120 MIUNICODE EscapeChar = '\\'
01121 ) const;
01122
01123
01125 void Insert (
01126 int start,
01127 const MISTRING& str,
01128 int strstart = 0,
01129 int strend = INT32_MAX
01130 );
01131
01132
01134 void Join (
01135 const MISTRINGLIST& list,
01136 const MIUNICODE* sep
01137 );
01138
01142 void Join (
01143 const MISTRINGLIST& list,
01144 const char* sep = ""
01145 );
01146
01149 void MakeExclusive (
01150 );
01151
01153 void Pad (
01154 MIUNICODE c,
01155 int numchars
01156 );
01157
01159 void PadToLength (
01160 MIUNICODE c,
01161 int length
01162 );
01163
01165 void Remove (
01166 int start,
01167 int end
01168 );
01169
01172 void Replace (
01173 int index,
01174 MIUNICODE c
01175 );
01176
01178 void Replace (
01179 int start,
01180 int end,
01181 const MISTRING& str,
01182 int strstart = 0,
01183 int strend = INT32_MAX
01184 );
01185
01187 void Replace (
01188 int start,
01189 int end,
01190 const char *str
01191 );
01192
01194 ERRVALUE Reserve (
01195 int numchars
01196 );
01197
01213 bool Search (
01214 const MIUNICODE* str,
01215 UINT32& MatchStart,
01216 UINT32& MatchEnd,
01217 bool bIgnoreCase = false,
01218 UINT32 Start = 0
01219 ) const;
01220
01232 bool Search (
01233 const UCREGEXP& regex,
01234 UINT32& MatchStart,
01235 UINT32& MatchEnd,
01236 UINT32 Start = 0
01237 ) const;
01238
01242 bool SetLineTermination (
01243 LINETERM lineterm
01244 );
01245
01247 void SetLowerCase (
01248 int start = 0
01249 );
01250
01252 void SetUpperCase (
01253 int start = 0
01254 );
01255
01263 int Split (
01264 MIUNICODE ch,
01265 MISTRINGLIST& list,
01266 int maxitems = 0
01267 ) const;
01268
01276 int Split (
01277 const MIUNICODE *regexp,
01278 MISTRINGLIST& list,
01279 int maxitems = 0
01280 ) const;
01281
01284 void Terminate (
01285 MIUNICODE c
01286 );
01287
01289 void Truncate (
01290 int length
01291 );
01292
01294 void WordWrap (
01295 int MaxLineLength
01296 );
01297
01298 #ifndef GENERATING_DOXYGEN_OUTPUT
01299 class PRIV;
01300 #endif // GENERATING_DOXYGEN_OUTPUT
01301
01302 private:
01303 #ifndef GENERATING_DOXYGEN_OUTPUT
01304 static const MIUNICODE s_zero;
01305 static MIUNICODE s_dummy;
01306
01307 #if defined(DEBUG) || defined(_DEBUG)
01308 const MIUNICODE *m_string;
01309 #endif
01310 PRIV *m_pPriv;
01311
01312 void GetExclusive ();
01313
01314 friend class MISTRING::PRIV;
01315 #endif // GENERATING_DOXYGEN_OUTPUT
01316 };
01317
01318
01320 inline MISTRING operator+ (
01321 const MISTRING& lhs,
01322 const MISTRING& rhs
01323 ) {
01324 MISTRING result(lhs);
01325 result += rhs;
01326 return (result);
01327 }
01328
01330 inline bool operator== (
01331 const MISTRING& lhs,
01332 const MISTRING& rhs
01333 ) {
01334 return (lhs.Compare(rhs) == 0);
01335 }
01336
01338 inline bool operator!= (
01339 const MISTRING& lhs,
01340 const MISTRING& rhs
01341 ) {
01342 return (lhs.Compare(rhs) != 0);
01343 }
01344
01346 inline bool operator< (
01347 const MISTRING& lhs,
01348 const MISTRING& rhs
01349 ) {
01350 return (lhs.Compare(rhs) < 0);
01351 }
01352
01354 inline bool operator<= (
01355 const MISTRING& lhs,
01356 const MISTRING& rhs
01357 ) {
01358 return (lhs.Compare(rhs) <= 0);
01359 }
01360
01362 inline bool operator> (
01363 const MISTRING& lhs,
01364 const MISTRING& rhs
01365 ) {
01366 return (lhs.Compare(rhs) > 0);
01367 }
01368
01370 inline bool operator>= (
01371 const MISTRING& lhs,
01372 const MISTRING& rhs
01373 ) {
01374 return (lhs.Compare(rhs) >= 0);
01375 }
01376
01377
01378
01379
01380 #ifndef GENERATING_DOXYGEN_OUTPUT
01381
01382 struct STR_FILL {
01383 MIUNICODE m_fill;
01384 STR_FILL (MIUNICODE fill) : m_fill(fill) { }
01385 };
01386
01387 inline MISTRING& operator<< (
01388 MISTRING& lhs,
01389 const STR_FILL& rhs
01390 ) { lhs.FmtSetFill(rhs.m_fill); return (lhs); }
01391
01392 struct STR_PAD {
01393 MIUNICODE m_c;
01394 int m_n;
01395 STR_PAD (MIUNICODE c, int n) : m_c(c), m_n(n) { }
01396 };
01397
01398 inline MISTRING& operator<< (
01399 MISTRING& lhs,
01400 const STR_PAD& rhs
01401 ) { lhs.Pad(rhs.m_c,rhs.m_n); return (lhs); }
01402
01403 struct STR_PREC {
01404 int m_precision;
01405 STR_PREC (int precision) : m_precision(precision) { }
01406 };
01407
01408 inline MISTRING& operator<< (
01409 MISTRING& lhs,
01410 const STR_PREC& rhs
01411 ) { lhs.FmtSetPrecision(rhs.m_precision); return (lhs); }
01412
01413 struct STR_WIDTH {
01414 int m_width;
01415 STR_WIDTH (int width) : m_width(width) { }
01416 };
01417
01418 inline MISTRING& operator<< (
01419 MISTRING& lhs,
01420 const STR_WIDTH& rhs
01421 ) { lhs.FmtSetWidth(rhs.m_width); return (lhs); }
01422
01423 #endif // GENERATING_DOXYGEN_OUTPUT
01424
01427 inline STR_FILL STR_Fill (
01428 MIUNICODE fill
01429 ) { return (STR_FILL(fill)); }
01430
01433 inline STR_PAD STR_Pad (
01434 MIUNICODE c,
01435 int numchars
01436 ) { return (STR_PAD(c,numchars)); }
01437
01440 inline STR_PREC STR_Prec (
01441 int precision
01442 ) { return (STR_PREC(precision)); }
01443
01446 inline STR_WIDTH STR_Width (
01447 int width
01448 ) { return (STR_WIDTH(width)); }
01449
01450 #undef CLASSLIBEXPORT
01451
01452 #endif // INC_MI32_MISTRING_H
01453