00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016
00017 #if !defined(ON_STRING_INC_)
00018 #define ON_STRING_INC_
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 ON_DECL
00047 void ON_Sort(
00048 ON::sort_algorithm method,
00049 int* index,
00050 const void* base,
00051 size_t count,
00052 size_t sizeof_element,
00053 int (*compare)(const void*,const void*)
00054 );
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 ON_DECL
00086 void ON_Sort(
00087 ON::sort_algorithm method,
00088 int* index,
00089 const void* base,
00090 size_t count,
00091 size_t sizeof_element,
00092 int (*compare)(const void*,const void*,void*),
00093 void* context
00094 );
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 ON_DECL
00128 void ON_hsort(
00129 void* base,
00130 size_t count,
00131 size_t sizeof_element,
00132 int (*compare)(const void*,const void*)
00133 );
00134
00135 ON_DECL
00136 void ON_qsort(
00137 void* base,
00138 size_t count,
00139 size_t sizeof_element,
00140 int (*compare)(const void*,const void*)
00141 );
00142
00143 ON_DECL
00144 void ON_hsort(
00145 void* base,
00146 size_t count,
00147 size_t sizeof_element,
00148 int (*compare)(void*,const void*,const void*),
00149 void* context
00150 );
00151
00152 ON_DECL
00153 void ON_qsort(
00154 void* base,
00155 size_t count,
00156 size_t sizeof_element,
00157 int (*compare)(void*,const void*,const void*),
00158 void* context
00159 );
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 ON_DECL
00177 void ON_SortDoubleArray(
00178 ON::sort_algorithm sort_algorithm,
00179 double* a,
00180 size_t nel
00181 );
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 ON_DECL
00198 void ON_SortIntArray(
00199 ON::sort_algorithm sort_algorithm,
00200 int* a,
00201 size_t nel
00202 );
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 ON_DECL
00219 void ON_SortUnsignedIntArray(
00220 ON::sort_algorithm sort_algorithm,
00221 unsigned int* a,
00222 size_t nel
00223 );
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 ON_DECL
00240 void ON_SortStringArray(
00241 ON::sort_algorithm sort_algorithm,
00242 char** a,
00243 size_t nel
00244 );
00245
00246 ON_DECL
00247 const int* ON_BinarySearchIntArray(
00248 int key,
00249 const int* base,
00250 size_t nel
00251 );
00252
00253 ON_DECL
00254 const unsigned int* ON_BinarySearchUnsignedIntArray(
00255 unsigned int key,
00256 const unsigned int* base,
00257 size_t nel
00258 );
00259
00260 ON_DECL
00261 const double* ON_BinarySearchDoubleArray(
00262 double key,
00263 const double* base,
00264 size_t nel
00265 );
00266
00267
00268
00269
00270
00271
00272
00273 class ON_CLASS ON_CheckSum
00274 {
00275 public:
00276 ON_CheckSum();
00277 ~ON_CheckSum();
00278
00279 static const ON_CheckSum UnsetCheckSum;
00280
00281
00282 void Zero();
00283
00284
00285
00286
00287
00288 bool IsSet() const;
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 bool SetBufferCheckSum(
00306 size_t size,
00307 const void* buffer,
00308 time_t time
00309 );
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319 bool SetFileCheckSum(
00320 FILE* fp
00321 );
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331 bool SetFileCheckSum(
00332 const wchar_t* filename
00333 );
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 bool CheckBuffer(
00345 size_t size,
00346 const void* buffer
00347 ) const;
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 bool CheckFile(
00360 FILE* fp,
00361 bool bSkipTimeCheck = false
00362 ) const;
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 bool CheckFile(
00375 const wchar_t* filename,
00376 bool bSkipTimeCheck = false
00377 ) const;
00378
00379 bool Write(class ON_BinaryArchive&) const;
00380 bool Read(class ON_BinaryArchive&);
00381
00382 void Dump(class ON_TextLog&) const;
00383
00384 public:
00385 size_t m_size;
00386 time_t m_time;
00387 ON__UINT32 m_crc[8];
00388 };
00389
00391
00392
00393
00394
00395
00396
00397 class ON_String;
00398 class ON_wString;
00399
00404
00405 class ON_CLASS ON_String
00406 {
00407 public:
00408
00409
00410 ON_String();
00411 ON_String( const ON_String& );
00412
00413 ON_String( const char* );
00414 ON_String( const char*, int );
00415 ON_String( char, int = 1 );
00416
00417 ON_String( const unsigned char* );
00418 ON_String( const unsigned char*, int );
00419 ON_String( unsigned char, int = 1 );
00420
00421
00422 ON_String( const wchar_t* src );
00423 ON_String( const wchar_t* src, int length );
00424 ON_String( const ON_wString& src );
00425
00426 #if defined(ON_OS_WINDOWS)
00427
00428 bool LoadResourceString( HINSTANCE, UINT);
00429
00430 #endif
00431
00432 void Create();
00433 void Destroy();
00434 void EmergencyDestroy();
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 void EnableReferenceCounting( bool bEnable );
00448
00449
00450
00451
00452
00453 bool IsReferenceCounted() const;
00454
00455
00456
00457
00458 int Length() const;
00459 bool IsEmpty() const;
00460 void Empty();
00461
00462 char& operator[](int);
00463 char operator[](int) const;
00464 char GetAt(int) const;
00465 void SetAt(int, char);
00466 void SetAt(int, unsigned char);
00467 operator const char*() const;
00468
00469
00470 ON_String& operator=(const ON_String&);
00471 ON_String& operator=(char);
00472 ON_String& operator=(const char*);
00473 ON_String& operator=(unsigned char);
00474 ON_String& operator=(const unsigned char*);
00475 ON_String& operator=(const wchar_t* src);
00476 ON_String& operator=(const ON_wString& src);
00477
00478
00479 ON_String operator+(const ON_String&) const;
00480 ON_String operator+(char) const;
00481 ON_String operator+(unsigned char) const;
00482 ON_String operator+(const char*) const;
00483 ON_String operator+(const unsigned char*) const;
00484
00485
00486 bool operator==(const ON_String&) const;
00487 bool operator==(const char*)const ;
00488 bool operator!=(const ON_String&)const ;
00489 bool operator!=(const char*)const ;
00490 bool operator<(const ON_String&)const ;
00491 bool operator<(const char*)const ;
00492 bool operator>(const ON_String&)const ;
00493 bool operator>(const char*)const ;
00494 bool operator<=(const ON_String&)const ;
00495 bool operator<=(const char*)const ;
00496 bool operator>=(const ON_String&)const ;
00497 bool operator>=(const char*)const ;
00498
00499
00500 void Append( const char*, int );
00501 void Append( const unsigned char*, int );
00502 const ON_String& operator+=(const ON_String&);
00503 const ON_String& operator+=(char);
00504 const ON_String& operator+=(unsigned char);
00505 const ON_String& operator+=(const char*);
00506 const ON_String& operator+=(const unsigned char*);
00507
00508
00509
00510
00511
00512 int Compare( const char* ) const;
00513 int Compare( const unsigned char* ) const;
00514
00515 int CompareNoCase( const char* ) const;
00516 int CompareNoCase( const unsigned char* ) const;
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528 bool WildCardMatch( const char* ) const;
00529 bool WildCardMatch( const unsigned char* ) const;
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 bool WildCardMatchNoCase( const char* ) const;
00542 bool WildCardMatchNoCase( const unsigned char* ) const;
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 int Replace( const char* token1, const char* token2 );
00554 int Replace( const unsigned char* token1, const unsigned char* token2 );
00555 int Replace( char token1, char token2 );
00556 int Replace( unsigned char token1, unsigned char token2 );
00557
00558
00559
00560 ON_String Mid(
00561 int,
00562 int
00563 ) const;
00564 ON_String Mid(
00565 int
00566 ) const;
00567 ON_String Left(
00568 int
00569 ) const;
00570 ON_String Right(
00571 int
00572 ) const;
00573
00574
00575 void MakeUpper();
00576 void MakeLower();
00577 void MakeReverse();
00578 void TrimLeft(const char* = NULL);
00579 void TrimRight(const char* = NULL);
00580 void TrimLeftAndRight(const char* = NULL);
00581
00582
00583 int Remove( const char chRemove);
00584
00585
00586
00587 int Find(char) const;
00588 int Find(unsigned char) const;
00589 int ReverseFind(char) const;
00590 int ReverseFind(unsigned char) const;
00591
00592
00593 int Find(const char*) const;
00594 int Find(const unsigned char*) const;
00595
00596
00597 void ON_MSC_CDECL Format( const char*, ...);
00598 void ON_MSC_CDECL Format( const unsigned char*, ...);
00599
00600
00601 void ReserveArray(size_t);
00602
00603 void ShrinkArray();
00604 void SetLength(size_t);
00605 char* Array();
00606 const char* Array() const;
00607
00608
00609
00610
00611
00612
00613 unsigned int SizeOf() const;
00614
00615 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660 static void SplitPath(
00661 const char* path,
00662 ON_String* drive,
00663 ON_String* dir,
00664 ON_String* fname,
00665 ON_String* ext
00666 );
00667
00668
00669 public:
00670 ~ON_String();
00671
00672 protected:
00673 char* m_s;
00674
00675
00676
00677 struct ON_aStringHeader* Header() const;
00678 void CreateArray(int);
00679 void CopyArray();
00680 void CopyToArray( const ON_String& );
00681 void CopyToArray( int, const char* );
00682 void CopyToArray( int, const unsigned char* );
00683 void CopyToArray( int, const wchar_t* );
00684 void AppendToArray( const ON_String& );
00685 void AppendToArray( int, const char* );
00686 void AppendToArray( int, const unsigned char* );
00687 static int Length(const char*);
00688 static int Length(const unsigned char*);
00689 };
00690
00691
00696
00697
00698
00699
00700 class ON_CLASS ON_wString
00701 {
00702 public:
00703
00704
00705 ON_wString();
00706 ON_wString( const ON_wString& );
00707
00708 ON_wString( const ON_String& src );
00709
00710 ON_wString( const char* src );
00711 ON_wString( const char* src, int );
00712 ON_wString( char, int = 1 );
00713
00714 ON_wString( const unsigned char* src);
00715 ON_wString( const unsigned char*src, int );
00716 ON_wString( unsigned char, int = 1 );
00717
00718 ON_wString( const wchar_t* );
00719 ON_wString( const wchar_t*, int );
00720 ON_wString( wchar_t, int = 1 );
00721
00722 #if defined(ON_OS_WINDOWS)
00723
00724 bool LoadResourceString(HINSTANCE, UINT);
00725
00726 #endif
00727
00728 void Create();
00729 void Destroy();
00730 void EmergencyDestroy();
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 void EnableReferenceCounting( bool bEnable );
00744
00745
00746
00747
00748
00749 bool IsReferenceCounted() const;
00750
00751
00752
00753 int Length() const;
00754 bool IsEmpty() const;
00755 void Empty();
00756
00757 wchar_t& operator[](int);
00758 wchar_t operator[](int) const;
00759 wchar_t GetAt(int) const;
00760 void SetAt(int, char);
00761 void SetAt(int, unsigned char);
00762 void SetAt(int, wchar_t);
00763 operator const wchar_t*() const;
00764
00765
00766 const ON_wString& operator=(const ON_wString&);
00767 const ON_wString& operator=(const ON_String& src);
00768 const ON_wString& operator=(char);
00769 const ON_wString& operator=(const char* src);
00770 const ON_wString& operator=(unsigned char);
00771 const ON_wString& operator=(const unsigned char* src);
00772 const ON_wString& operator=(wchar_t);
00773 const ON_wString& operator=(const wchar_t*);
00774
00775
00776 void Append( const char* sUTF8, int );
00777 void Append( const unsigned char* sUTF8, int );
00778 void Append( const wchar_t*, int );
00779 const ON_wString& operator+=(const ON_wString&);
00780 const ON_wString& operator+=(const ON_String& sUTF8);
00781 const ON_wString& operator+=(char);
00782 const ON_wString& operator+=(unsigned char);
00783 const ON_wString& operator+=(wchar_t);
00784 const ON_wString& operator+=(const char* sUTF8);
00785 const ON_wString& operator+=(const unsigned char* sUTF8);
00786 const ON_wString& operator+=(const wchar_t*);
00787
00788
00789 ON_wString operator+(const ON_wString&) const;
00790 ON_wString operator+(const ON_String& sUTF8) const;
00791 ON_wString operator+(char) const;
00792 ON_wString operator+(unsigned char) const;
00793 ON_wString operator+(wchar_t) const;
00794 ON_wString operator+(const char* sUTF8) const;
00795 ON_wString operator+(const unsigned char* sUTF8) const;
00796 ON_wString operator+(const wchar_t*) const;
00797
00798
00799 bool operator==(const ON_wString&) const;
00800 bool operator==(const wchar_t*) const;
00801 bool operator!=(const ON_wString&) const;
00802 bool operator!=(const wchar_t*) const;
00803 bool operator<(const ON_wString&) const;
00804 bool operator<(const wchar_t*) const;
00805 bool operator>(const ON_wString&) const;
00806 bool operator>(const wchar_t*) const;
00807 bool operator<=(const ON_wString&) const;
00808 bool operator<=(const wchar_t*) const;
00809 bool operator>=(const ON_wString&) const;
00810 bool operator>=(const wchar_t*) const;
00811
00812
00813
00814
00815
00816 int Compare( const char* sUTF8 ) const;
00817 int Compare( const unsigned char* sUTF8 ) const;
00818 int Compare( const wchar_t* ) const;
00819
00820 int CompareNoCase( const char* sUTF8) const;
00821 int CompareNoCase( const unsigned char* sUTF8) const;
00822 int CompareNoCase( const wchar_t* ) const;
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834 bool WildCardMatch( const wchar_t* ) const;
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 bool WildCardMatchNoCase( const wchar_t* ) const;
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857 int Replace( const wchar_t* token1, const wchar_t* token2 );
00858 int Replace( wchar_t token1, wchar_t token2 );
00859
00860
00861
00862
00863
00864
00865
00866 void UrlEncode();
00867
00868
00869
00870
00871
00872
00873
00874 bool UrlDecode();
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 int ReplaceWhiteSpace( wchar_t token, const wchar_t* whitespace = 0 );
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905 int RemoveWhiteSpace( const wchar_t* whitespace = 0 );
00906
00907
00908 ON_wString Mid(
00909 int,
00910 int
00911 ) const;
00912 ON_wString Mid(
00913 int
00914 ) const;
00915 ON_wString Left(
00916 int
00917 ) const;
00918 ON_wString Right(
00919 int
00920 ) const;
00921
00922
00923 void MakeUpper();
00924 void MakeLower();
00925 void MakeReverse();
00926 void TrimLeft(const wchar_t* = NULL);
00927 void TrimRight(const wchar_t* = NULL);
00928 void TrimLeftAndRight(const wchar_t* = NULL);
00929
00930
00931
00932
00933
00934 int Remove( wchar_t c);
00935
00936
00937
00938 int Find(char) const;
00939 int Find(unsigned char) const;
00940 int Find(wchar_t) const;
00941 int ReverseFind(char) const;
00942 int ReverseFind(unsigned char) const;
00943 int ReverseFind(wchar_t) const;
00944
00945
00946 int Find(const char*) const;
00947 int Find(const unsigned char*) const;
00948 int Find(const wchar_t*) const;
00949
00950
00951
00952 void ON_MSC_CDECL Format( const char*, ...);
00953 void ON_MSC_CDECL Format( const unsigned char*, ...);
00954 void ON_MSC_CDECL Format( const wchar_t*, ...);
00955
00956
00957 void ReserveArray(size_t);
00958
00959 void ShrinkArray();
00960 void SetLength(size_t);
00961 wchar_t* Array();
00962 const wchar_t* Array() const;
00963
00964
00965
00966
00967
00968
00969 unsigned int SizeOf() const;
00970
00971
00972
00973
00974
00975 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
00976
00977
00978
00979
00980
00981
00982 ON__UINT32 DataCRCLower(ON__UINT32 current_remainder) const;
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 static void SplitPath(
01029 const char* path,
01030 ON_wString* drive,
01031 ON_wString* dir,
01032 ON_wString* fname,
01033 ON_wString* ext
01034 );
01035
01036 static void SplitPath(
01037 const wchar_t* path,
01038 ON_wString* drive,
01039 ON_wString* dir,
01040 ON_wString* fname,
01041 ON_wString* ext
01042 );
01043
01044 public:
01045 ~ON_wString();
01046
01047 protected:
01048 wchar_t* m_s;
01049
01050
01051
01052 struct ON_wStringHeader* Header() const;
01053 void CreateArray(int);
01054 void CopyArray();
01055 void CopyToArray( const ON_wString& );
01056 void CopyToArray( int, const char* );
01057 void CopyToArray( int, const unsigned char* );
01058 void CopyToArray( int, const wchar_t* );
01059 void AppendToArray( const ON_wString& );
01060 void AppendToArray( int, const char* );
01061 void AppendToArray( int, const unsigned char* );
01062 void AppendToArray( int, const wchar_t* );
01063 static int Length(const char*);
01064 static int Length(const unsigned char*);
01065 static int Length(const wchar_t*);
01066 };
01067
01068 class ON_CLASS ON_UnitSystem
01069 {
01070 public:
01071 ON_UnitSystem();
01072 ~ON_UnitSystem();
01073
01074 ON_UnitSystem(ON::unit_system);
01075 ON_UnitSystem& operator=(ON::unit_system);
01076
01077 bool operator==(const ON_UnitSystem&);
01078 bool operator!=(const ON_UnitSystem&);
01079
01080 bool IsValid() const;
01081
01082 void Default();
01083
01084 bool Read( class ON_BinaryArchive& );
01085 bool Write( class ON_BinaryArchive& ) const;
01086 void Dump( class ON_TextLog& ) const;
01087
01088 ON::unit_system m_unit_system;
01089
01090
01091 double m_custom_unit_scale;
01092 ON_wString m_custom_unit_name;
01093
01094
01095
01096
01097
01098
01099
01100
01101 };
01102
01103
01104 #endif