aboutsummaryrefslogtreecommitdiff
path: root/src/string.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/string.h (renamed from src/fbasicstring.h)210
1 files changed, 119 insertions, 91 deletions
diff --git a/src/fbasicstring.h b/src/string.h
index 064ff16..22db827 100644
--- a/src/fbasicstring.h
+++ b/src/string.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (C) 2007-2010 Xagasoft, All rights reserved. 2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 * 3 *
4 * This file is part of the libbu++ library and is released under the 4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8#ifndef BU_F_BASIC_STRING_H 8#ifndef BU_STRING_H
9#define BU_F_BASIC_STRING_H 9#define BU_STRING_H
10 10
11#include <stdint.h> 11#include <stdint.h>
12#include <memory> 12#include <memory>
@@ -27,17 +27,15 @@ namespace Bu
27{ 27{
28 /** @cond DEVEL */ 28 /** @cond DEVEL */
29 template< typename chr > 29 template< typename chr >
30 struct FStringChunk 30 struct StringChunk
31 { 31 {
32 long nLength; 32 long nLength;
33 chr *pData; 33 chr *pData;
34 FStringChunk *pNext; 34 StringChunk *pNext;
35 }; 35 };
36 36
37#define cpy( dest, src, size ) Bu::memcpy( dest, src, size*sizeof(chr) )
38
39 template< typename chr, int nMinSize, typename chralloc, 37 template< typename chr, int nMinSize, typename chralloc,
40 typename chunkalloc> class FBasicString; 38 typename chunkalloc> class BasicString;
41 39
42 template<typename chr> 40 template<typename chr>
43 size_t strlen( const chr *pData ) 41 size_t strlen( const chr *pData )
@@ -76,24 +74,24 @@ namespace Bu
76 } 74 }
77 75
78 template<typename chr, int nMinSize, typename chralloc, typename chunkalloc> 76 template<typename chr, int nMinSize, typename chralloc, typename chunkalloc>
79 struct FStringCore 77 struct StringCore
80 { 78 {
81 friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>; 79 friend class BasicString<chr, nMinSize, chralloc, chunkalloc>;
82 friend class SharedCore< 80 friend class SharedCore<
83 FBasicString<chr, nMinSize, chralloc, chunkalloc>, 81 BasicString<chr, nMinSize, chralloc, chunkalloc>,
84 FStringCore<chr, nMinSize, chralloc, chunkalloc> 82 StringCore<chr, nMinSize, chralloc, chunkalloc>
85 >; 83 >;
86 private: 84 private:
87 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> MyType; 85 typedef struct StringCore<chr, nMinSize, chralloc, chunkalloc> MyType;
88 typedef struct FStringChunk<chr> Chunk; 86 typedef struct StringChunk<chr> Chunk;
89 FStringCore() : 87 StringCore() :
90 nLength( 0 ), 88 nLength( 0 ),
91 pFirst( NULL ), 89 pFirst( NULL ),
92 pLast( NULL ) 90 pLast( NULL )
93 { 91 {
94 } 92 }
95 93
96 FStringCore( const MyType &rSrc ) : 94 StringCore( const MyType &rSrc ) :
97 nLength( rSrc.nLength ), 95 nLength( rSrc.nLength ),
98 pFirst( NULL ), 96 pFirst( NULL ),
99 pLast( NULL ), 97 pLast( NULL ),
@@ -111,14 +109,14 @@ namespace Bu
111 int iPos = 0; 109 int iPos = 0;
112 while( pLink != NULL ) 110 while( pLink != NULL )
113 { 111 {
114 cpy( pFirst->pData+iPos, pLink->pData, pLink->nLength ); 112 memcpy( pFirst->pData+iPos, pLink->pData, pLink->nLength );
115 iPos += pLink->nLength; 113 iPos += pLink->nLength;
116 pLink = pLink->pNext; 114 pLink = pLink->pNext;
117 } 115 }
118 } 116 }
119 } 117 }
120 118
121 virtual ~FStringCore() 119 virtual ~StringCore()
122 { 120 {
123 clear(); 121 clear();
124 } 122 }
@@ -172,7 +170,7 @@ namespace Bu
172 pNew->pNext = pSrc->pNext; 170 pNew->pNext = pSrc->pNext;
173 pNew->nLength = pSrc->nLength; 171 pNew->nLength = pSrc->nLength;
174 pNew->pData = aChr.allocate( pSrc->nLength+1 ); 172 pNew->pData = aChr.allocate( pSrc->nLength+1 );
175 cpy( pNew->pData, pSrc->pData, pSrc->nLength ); 173 memcpy( pNew->pData, pSrc->pData, pSrc->nLength );
176 pNew->pData[pNew->nLength] = (chr)0; 174 pNew->pData[pNew->nLength] = (chr)0;
177 return pNew; 175 return pNew;
178 } 176 }
@@ -214,7 +212,7 @@ namespace Bu
214 * internal ref-counting means that if you pass strings around between 212 * internal ref-counting means that if you pass strings around between
215 * functions there's almost no overhead in time or memory since a reference 213 * functions there's almost no overhead in time or memory since a reference
216 * is created and no data is actually copied. This also means that you 214 * is created and no data is actually copied. This also means that you
217 * never need to put any FBasicString into a ref-counting container class. 215 * never need to put any BasicString into a ref-counting container class.
218 * 216 *
219 *@param chr (typename) Type of character (i.e. char) 217 *@param chr (typename) Type of character (i.e. char)
220 *@param nMinSize (int) Chunk size (default: 256) 218 *@param nMinSize (int) Chunk size (default: 256)
@@ -223,15 +221,15 @@ namespace Bu
223 */ 221 */
224 template< typename chr, int nMinSize=256, 222 template< typename chr, int nMinSize=256,
225 typename chralloc=std::allocator<chr>, 223 typename chralloc=std::allocator<chr>,
226 typename chunkalloc=std::allocator<struct FStringChunk<chr> > > 224 typename chunkalloc=std::allocator<struct StringChunk<chr> > >
227 class FBasicString : public SharedCore< 225 class BasicString : public SharedCore<
228 FBasicString<chr, nMinSize, chralloc, chunkalloc>, 226 BasicString<chr, nMinSize, chralloc, chunkalloc>,
229 FStringCore<chr, nMinSize, chralloc, chunkalloc> > 227 StringCore<chr, nMinSize, chralloc, chunkalloc> >
230 { 228 {
231 protected: 229 protected:
232 typedef struct FStringChunk<chr> Chunk; 230 typedef struct StringChunk<chr> Chunk;
233 typedef struct FBasicString<chr, nMinSize, chralloc, chunkalloc> MyType; 231 typedef struct BasicString<chr, nMinSize, chralloc, chunkalloc> MyType;
234 typedef struct FStringCore<chr, nMinSize, chralloc, chunkalloc> Core; 232 typedef struct StringCore<chr, nMinSize, chralloc, chunkalloc> Core;
235 233
236 using SharedCore<MyType, Core >::core; 234 using SharedCore<MyType, Core >::core;
237 using SharedCore<MyType, Core >::_hardCopy; 235 using SharedCore<MyType, Core >::_hardCopy;
@@ -240,7 +238,7 @@ namespace Bu
240 struct iterator; 238 struct iterator;
241 typedef struct const_iterator 239 typedef struct const_iterator
242 { 240 {
243 friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>; 241 friend class BasicString<chr, nMinSize, chralloc, chunkalloc>;
244 friend struct iterator; 242 friend struct iterator;
245 private: 243 private:
246 const_iterator( Chunk *pChunk, int iPos ) : 244 const_iterator( Chunk *pChunk, int iPos ) :
@@ -474,7 +472,7 @@ namespace Bu
474 472
475 typedef struct iterator 473 typedef struct iterator
476 { 474 {
477 friend class FBasicString<chr, nMinSize, chralloc, chunkalloc>; 475 friend class BasicString<chr, nMinSize, chralloc, chunkalloc>;
478 friend struct const_iterator; 476 friend struct const_iterator;
479 private: 477 private:
480 iterator( Chunk *pChunk, int iPos ) : 478 iterator( Chunk *pChunk, int iPos ) :
@@ -719,52 +717,52 @@ namespace Bu
719 } iterator; 717 } iterator;
720 718
721 public: 719 public:
722 FBasicString() 720 BasicString()
723 { 721 {
724 } 722 }
725 723
726 FBasicString( const chr *pData ) 724 BasicString( const chr *pData )
727 { 725 {
728 append( pData ); 726 append( pData );
729 } 727 }
730 728
731 FBasicString( const chr *pData, long nLength ) 729 BasicString( const chr *pData, long nLength )
732 { 730 {
733 append( pData, nLength ); 731 append( pData, nLength );
734 } 732 }
735 733
736 FBasicString( const MyType &rSrc ) : 734 BasicString( const MyType &rSrc ) :
737 SharedCore<MyType, Core>( rSrc ) 735 SharedCore<MyType, Core>( rSrc )
738 { 736 {
739 } 737 }
740 738
741 FBasicString( const MyType &rSrc, long nLength ) 739 BasicString( const MyType &rSrc, long nLength )
742 { 740 {
743 append( rSrc, nLength ); 741 append( rSrc, nLength );
744 } 742 }
745 743
746 FBasicString( const MyType &rSrc, long nStart, long nLength ) 744 BasicString( const MyType &rSrc, long nStart, long nLength )
747 { 745 {
748 append( rSrc, nStart, nLength ); 746 append( rSrc, nStart, nLength );
749 } 747 }
750 748
751 FBasicString( long nSize ) 749 BasicString( long nSize )
752 { 750 {
753 core->pFirst = core->pLast = core->newChunk( nSize ); 751 core->pFirst = core->pLast = core->newChunk( nSize );
754 core->nLength = nSize; 752 core->nLength = nSize;
755 } 753 }
756 754
757 FBasicString( const const_iterator &s ) 755 BasicString( const const_iterator &s )
758 { 756 {
759 append( s ); 757 append( s );
760 } 758 }
761 759
762 FBasicString( const const_iterator &s, const const_iterator &e ) 760 BasicString( const const_iterator &s, const const_iterator &e )
763 { 761 {
764 append( s, e ); 762 append( s, e );
765 } 763 }
766 764
767 virtual ~FBasicString() 765 virtual ~BasicString()
768 { 766 {
769 } 767 }
770 768
@@ -812,7 +810,7 @@ namespace Bu
812 int nAmnt = nMinSize - core->pLast->nLength; 810 int nAmnt = nMinSize - core->pLast->nLength;
813 if( nAmnt > nLen ) 811 if( nAmnt > nLen )
814 nAmnt = nLen; 812 nAmnt = nLen;
815 cpy( 813 memcpy(
816 core->pLast->pData+core->pLast->nLength, 814 core->pLast->pData+core->pLast->nLength,
817 pData, 815 pData,
818 nAmnt 816 nAmnt
@@ -826,7 +824,7 @@ namespace Bu
826 if( nLen > 0 ) 824 if( nLen > 0 )
827 { 825 {
828 Chunk *pNew = core->newChunk( nLen ); 826 Chunk *pNew = core->newChunk( nLen );
829 cpy( pNew->pData, pData, nLen ); 827 memcpy( pNew->pData, pData, nLen );
830 core->appendChunk( pNew ); 828 core->appendChunk( pNew );
831// core->nLength += nLen; 829// core->nLength += nLen;
832 } 830 }
@@ -852,8 +850,8 @@ namespace Bu
852 } 850 }
853 851
854 /** 852 /**
855 * Append another FString to this one. 853 * Append another String to this one.
856 *@param sData (MyType &) The FString to append. 854 *@param sData (MyType &) The String to append.
857 *@todo This function can be made much faster by not using getStr() 855 *@todo This function can be made much faster by not using getStr()
858 */ 856 */
859 void append( const MyType & sData ) 857 void append( const MyType & sData )
@@ -862,8 +860,8 @@ namespace Bu
862 } 860 }
863 861
864 /** 862 /**
865 * Append another FString to this one. 863 * Append another String to this one.
866 *@param sData (MyType &) The FString to append. 864 *@param sData (MyType &) The String to append.
867 *@param nLen How much data to append. 865 *@param nLen How much data to append.
868 *@todo This function can be made much faster by not using getStr() 866 *@todo This function can be made much faster by not using getStr()
869 */ 867 */
@@ -873,8 +871,8 @@ namespace Bu
873 } 871 }
874 872
875 /** 873 /**
876 * Append another FString to this one. 874 * Append another String to this one.
877 *@param sData (MyType &) The FString to append. 875 *@param sData (MyType &) The String to append.
878 *@param nStart Start position in sData to start copying from. 876 *@param nStart Start position in sData to start copying from.
879 *@param nLen How much data to append. 877 *@param nLen How much data to append.
880 *@todo This function can be made much faster by not using getStr() 878 *@todo This function can be made much faster by not using getStr()
@@ -887,9 +885,9 @@ namespace Bu
887 } 885 }
888 886
889 /** 887 /**
890 * Append data to this FString using the passed in iterator as a base. 888 * Append data to this String using the passed in iterator as a base.
891 * The iterator is const, it is not changed. 889 * The iterator is const, it is not changed.
892 *@param s Iterator from any compatible FBasicString to copy data from. 890 *@param s Iterator from any compatible BasicString to copy data from.
893 */ 891 */
894 void append( const const_iterator &s ) 892 void append( const const_iterator &s )
895 { 893 {
@@ -898,7 +896,7 @@ namespace Bu
898 Chunk *pSrc = s.pChunk; 896 Chunk *pSrc = s.pChunk;
899 897
900 Chunk *pNew = core->newChunk( pSrc->nLength-s.iPos ); 898 Chunk *pNew = core->newChunk( pSrc->nLength-s.iPos );
901 cpy( pNew->pData, pSrc->pData+s.iPos, pSrc->nLength-s.iPos ); 899 memcpy( pNew->pData, pSrc->pData+s.iPos, pSrc->nLength-s.iPos );
902 900
903 _hardCopy(); 901 _hardCopy();
904 core->appendChunk( pNew ); 902 core->appendChunk( pNew );
@@ -910,9 +908,9 @@ namespace Bu
910 } 908 }
911 909
912 /** 910 /**
913 * Append data to this FString using the passed in iterator as a base. 911 * Append data to this String using the passed in iterator as a base.
914 * The iterator is const, it is not changed. 912 * The iterator is const, it is not changed.
915 *@param s Iterator from any compatible FBasicString to copy data from. 913 *@param s Iterator from any compatible BasicString to copy data from.
916 */ 914 */
917 void append( const iterator &s ) // I get complaints without this one 915 void append( const iterator &s ) // I get complaints without this one
918 { 916 {
@@ -920,11 +918,11 @@ namespace Bu
920 } 918 }
921 919
922 /** 920 /**
923 * Append data to this FString using the passed in iterator as a base, 921 * Append data to this String using the passed in iterator as a base,
924 * and copy data until the ending iterator is reached. The character 922 * and copy data until the ending iterator is reached. The character
925 * at the ending iterator is not copied. 923 * at the ending iterator is not copied.
926 * The iterators are const, they are not changed. 924 * The iterators are const, they are not changed.
927 *@param s Iterator from any compatible FBasicString to copy data from. 925 *@param s Iterator from any compatible BasicString to copy data from.
928 *@param e Iterator to stop copying at. 926 *@param e Iterator to stop copying at.
929 */ 927 */
930 void append( const const_iterator &s, const const_iterator &e ) 928 void append( const const_iterator &s, const const_iterator &e )
@@ -941,7 +939,7 @@ namespace Bu
941 { 939 {
942 // Simple case, they're the same chunk 940 // Simple case, they're the same chunk
943 Chunk *pNew = core->newChunk( e.iPos-s.iPos ); 941 Chunk *pNew = core->newChunk( e.iPos-s.iPos );
944 cpy( pNew->pData, s.pChunk->pData+s.iPos, e.iPos-s.iPos ); 942 memcpy( pNew->pData, s.pChunk->pData+s.iPos, e.iPos-s.iPos );
945 core->appendChunk( pNew ); 943 core->appendChunk( pNew );
946 } 944 }
947 else 945 else
@@ -949,7 +947,7 @@ namespace Bu
949 // A little trickier, scan the blocks... 947 // A little trickier, scan the blocks...
950 Chunk *pSrc = s.pChunk; 948 Chunk *pSrc = s.pChunk;
951 Chunk *pNew = core->newChunk( pSrc->nLength-s.iPos ); 949 Chunk *pNew = core->newChunk( pSrc->nLength-s.iPos );
952 cpy( pNew->pData, pSrc->pData+s.iPos, pSrc->nLength-s.iPos ); 950 memcpy( pNew->pData, pSrc->pData+s.iPos, pSrc->nLength-s.iPos );
953 core->appendChunk( pNew ); 951 core->appendChunk( pNew );
954 952
955 while( (pSrc = pSrc->pNext) != e.pChunk ) 953 while( (pSrc = pSrc->pNext) != e.pChunk )
@@ -958,14 +956,14 @@ namespace Bu
958 } 956 }
959 957
960 pNew = core->newChunk( e.iPos ); 958 pNew = core->newChunk( e.iPos );
961 cpy( pNew->pData, pSrc->pData, e.iPos ); 959 memcpy( pNew->pData, pSrc->pData, e.iPos );
962 core->appendChunk( pNew ); 960 core->appendChunk( pNew );
963 } 961 }
964 } 962 }
965 963
966 /** 964 /**
967 * Prepend another FString to this one. 965 * Prepend another String to this one.
968 *@param sData (MyType &) The FString to prepend. 966 *@param sData (MyType &) The String to prepend.
969 *@todo This function can be made much faster by not using getStr() 967 *@todo This function can be made much faster by not using getStr()
970 */ 968 */
971 void prepend( const MyType & sData ) 969 void prepend( const MyType & sData )
@@ -987,7 +985,7 @@ namespace Bu
987 for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { } 985 for( nLen = 0; pData[nLen] != (chr)0; nLen++ ) { }
988 986
989 Chunk *pNew = core->newChunk( nLen ); 987 Chunk *pNew = core->newChunk( nLen );
990 cpy( pNew->pData, pData, nLen ); 988 memcpy( pNew->pData, pData, nLen );
991 989
992 core->prependChunk( pNew ); 990 core->prependChunk( pNew );
993 } 991 }
@@ -1001,7 +999,7 @@ namespace Bu
1001 { 999 {
1002 Chunk *pNew = core->newChunk( nLen ); 1000 Chunk *pNew = core->newChunk( nLen );
1003 1001
1004 cpy( pNew->pData, pData, nLen ); 1002 memcpy( pNew->pData, pData, nLen );
1005 1003
1006 _hardCopy(); 1004 _hardCopy();
1007 core->prependChunk( pNew ); 1005 core->prependChunk( pNew );
@@ -1037,9 +1035,9 @@ namespace Bu
1037 Chunk *p1 = core->newChunk( nPos ); 1035 Chunk *p1 = core->newChunk( nPos );
1038 Chunk *p2 = core->newChunk( nLen ); 1036 Chunk *p2 = core->newChunk( nLen );
1039 Chunk *p3 = core->newChunk( core->nLength-nPos ); 1037 Chunk *p3 = core->newChunk( core->nLength-nPos );
1040 cpy( p1->pData, core->pFirst->pData, nPos ); 1038 memcpy( p1->pData, core->pFirst->pData, nPos );
1041 cpy( p2->pData, pData, nLen ); 1039 memcpy( p2->pData, pData, nLen );
1042 cpy( p3->pData, core->pFirst->pData+nPos, core->nLength-nPos ); 1040 memcpy( p3->pData, core->pFirst->pData+nPos, core->nLength-nPos );
1043 core->clear(); 1041 core->clear();
1044 core->appendChunk( p1 ); 1042 core->appendChunk( p1 );
1045 core->appendChunk( p2 ); 1043 core->appendChunk( p2 );
@@ -1063,8 +1061,8 @@ namespace Bu
1063 _hardCopy(); 1061 _hardCopy();
1064 Chunk *p1 = core->newChunk( nPos ); 1062 Chunk *p1 = core->newChunk( nPos );
1065 Chunk *p3 = core->newChunk( core->nLength-nPos ); 1063 Chunk *p3 = core->newChunk( core->nLength-nPos );
1066 cpy( p1->pData, core->pFirst->pData, nPos ); 1064 memcpy( p1->pData, core->pFirst->pData, nPos );
1067 cpy( p3->pData, core->pFirst->pData+nPos, core->nLength-nPos ); 1065 memcpy( p3->pData, core->pFirst->pData+nPos, core->nLength-nPos );
1068 core->clear(); 1066 core->clear();
1069 core->appendChunk( p1 ); 1067 core->appendChunk( p1 );
1070 for( Chunk *pChnk = str.core->pFirst; pChnk; 1068 for( Chunk *pChnk = str.core->pFirst; pChnk;
@@ -1148,7 +1146,7 @@ namespace Bu
1148 long nNewLen = (nNewSize<core->nLength)?(nNewSize):(core->nLength); 1146 long nNewLen = (nNewSize<core->nLength)?(nNewSize):(core->nLength);
1149 if( core->nLength > 0 ) 1147 if( core->nLength > 0 )
1150 { 1148 {
1151 cpy( pNew->pData, core->pFirst->pData, nNewLen ); 1149 memcpy( pNew->pData, core->pFirst->pData, nNewLen );
1152 core->aChr.deallocate( core->pFirst->pData, core->pFirst->nLength+1 ); 1150 core->aChr.deallocate( core->pFirst->pData, core->pFirst->nLength+1 );
1153 core->aChunk.deallocate( core->pFirst, 1 ); 1151 core->aChunk.deallocate( core->pFirst, 1 );
1154 } 1152 }
@@ -1282,8 +1280,8 @@ namespace Bu
1282 } 1280 }
1283 1281
1284 /** 1282 /**
1285 * Plus equals operator for FString. 1283 * Plus equals operator for String.
1286 *@param pData (const chr *) The data to append to your FString. 1284 *@param pData (const chr *) The data to append to your String.
1287 */ 1285 */
1288 MyType &operator+=( const chr *pData ) 1286 MyType &operator+=( const chr *pData )
1289 { 1287 {
@@ -1293,8 +1291,8 @@ namespace Bu
1293 } 1291 }
1294 1292
1295 /** 1293 /**
1296 * Plus equals operator for FString. 1294 * Plus equals operator for String.
1297 *@param rSrc (const MyType &) The FString to append to your FString. 1295 *@param rSrc (const MyType &) The String to append to your String.
1298 */ 1296 */
1299 MyType &operator+=( const MyType &rSrc ) 1297 MyType &operator+=( const MyType &rSrc )
1300 { 1298 {
@@ -1311,8 +1309,8 @@ namespace Bu
1311 } 1309 }
1312 1310
1313 /** 1311 /**
1314 * Plus equals operator for FString. 1312 * Plus equals operator for String.
1315 *@param cData (const chr) The character to append to your FString. 1313 *@param cData (const chr) The character to append to your String.
1316 */ 1314 */
1317 MyType &operator+=( const chr cData ) 1315 MyType &operator+=( const chr cData )
1318 { 1316 {
@@ -1335,7 +1333,7 @@ namespace Bu
1335 /** 1333 /**
1336 * Assignment operator. 1334 * Assignment operator.
1337 *@param pData (const chr *) The character array to append to your 1335 *@param pData (const chr *) The character array to append to your
1338 * FString. 1336 * String.
1339 */ 1337 */
1340 MyType &operator=( const chr *pData ) 1338 MyType &operator=( const chr *pData )
1341 { 1339 {
@@ -1366,8 +1364,8 @@ namespace Bu
1366 } 1364 }
1367 1365
1368 /** 1366 /**
1369 * Reset your FString to this character array. 1367 * Reset your String to this character array.
1370 *@param pData (const chr *) The character array to set your FString to. 1368 *@param pData (const chr *) The character array to set your String to.
1371 */ 1369 */
1372 void set( const chr *pData ) 1370 void set( const chr *pData )
1373 { 1371 {
@@ -1376,8 +1374,8 @@ namespace Bu
1376 } 1374 }
1377 1375
1378 /** 1376 /**
1379 * Reset your FString to this character array. 1377 * Reset your String to this character array.
1380 *@param pData (const chr *) The character array to set your FString to. 1378 *@param pData (const chr *) The character array to set your String to.
1381 *@param nSize (long) The length of the inputted character array. 1379 *@param nSize (long) The length of the inputted character array.
1382 */ 1380 */
1383 void set( const chr *pData, long nSize ) 1381 void set( const chr *pData, long nSize )
@@ -1467,7 +1465,7 @@ namespace Bu
1467 1465
1468 /** 1466 /**
1469 * Assignment operator. 1467 * Assignment operator.
1470 *@param rSrc (const MyType &) The FString to set your FString to. 1468 *@param rSrc (const MyType &) The String to set your String to.
1471 */ 1469 */
1472 /* MyType &operator=( const MyType &rSrc ) 1470 /* MyType &operator=( const MyType &rSrc )
1473 { 1471 {
@@ -1478,7 +1476,7 @@ namespace Bu
1478 1476
1479 /** 1477 /**
1480 * Equals comparison operator. 1478 * Equals comparison operator.
1481 *@param pData (const chr *) The character array to compare your FString 1479 *@param pData (const chr *) The character array to compare your String
1482 * to. 1480 * to.
1483 */ 1481 */
1484 bool operator==( const chr *pData ) const 1482 bool operator==( const chr *pData ) const
@@ -1508,7 +1506,7 @@ namespace Bu
1508 1506
1509 /** 1507 /**
1510 * Equals comparison operator. 1508 * Equals comparison operator.
1511 *@param pData (const MyType &) The FString to compare your FString to. 1509 *@param pData (const MyType &) The String to compare your String to.
1512 */ 1510 */
1513 bool operator==( const MyType &pData ) const 1511 bool operator==( const MyType &pData ) const
1514 { 1512 {
@@ -1538,7 +1536,7 @@ namespace Bu
1538 1536
1539 /** 1537 /**
1540 * Not equals comparison operator. 1538 * Not equals comparison operator.
1541 *@param pData (const chr *) The character array to compare your FString 1539 *@param pData (const chr *) The character array to compare your String
1542 * to. 1540 * to.
1543 */ 1541 */
1544 bool operator!=(const chr *pData ) const 1542 bool operator!=(const chr *pData ) const
@@ -1548,7 +1546,7 @@ namespace Bu
1548 1546
1549 /** 1547 /**
1550 * Not equals comparison operator. 1548 * Not equals comparison operator.
1551 *@param pData (const MyType &) The FString to compare your FString to. 1549 *@param pData (const MyType &) The String to compare your String to.
1552 */ 1550 */
1553 bool operator!=(const MyType &pData ) const 1551 bool operator!=(const MyType &pData ) const
1554 { 1552 {
@@ -1939,7 +1937,7 @@ namespace Bu
1939 long nNewLen = core->nLength - nAmnt; 1937 long nNewLen = core->nLength - nAmnt;
1940 flatten(); 1938 flatten();
1941 Chunk *pNew = core->newChunk( nNewLen ); 1939 Chunk *pNew = core->newChunk( nNewLen );
1942 cpy( pNew->pData, core->pFirst->pData+nAmnt, nNewLen ); 1940 memcpy( pNew->pData, core->pFirst->pData+nAmnt, nNewLen );
1943 _hardCopy(); 1941 _hardCopy();
1944 core->clear(); 1942 core->clear();
1945 core->appendChunk( pNew ); 1943 core->appendChunk( pNew );
@@ -2051,7 +2049,7 @@ namespace Bu
2051 Chunk *i = core->pFirst; 2049 Chunk *i = core->pFirst;
2052 for(;;) 2050 for(;;)
2053 { 2051 {
2054 cpy( pos, i->pData, i->nLength ); 2052 memcpy( pos, i->pData, i->nLength );
2055 pos += i->nLength; 2053 pos += i->nLength;
2056 i = i->pNext; 2054 i = i->pNext;
2057 if( i == NULL ) 2055 if( i == NULL )
@@ -2069,15 +2067,15 @@ namespace Bu
2069 } 2067 }
2070 }; 2068 };
2071 2069
2072 template<class T> FBasicString<T> operator+( const T *pLeft, const FBasicString<T> &rRight ) 2070 template<class T> BasicString<T> operator+( const T *pLeft, const BasicString<T> &rRight )
2073 { 2071 {
2074 Bu::FBasicString<T> ret( pLeft ); 2072 Bu::BasicString<T> ret( pLeft );
2075 ret.append( rRight ); 2073 ret.append( rRight );
2076 return ret; 2074 return ret;
2077 } 2075 }
2078 2076
2079 template<class chr, int b, class c, class d> 2077 template<class chr, int b, class c, class d>
2080 ArchiveBase &operator<<( ArchiveBase &ar, const FBasicString<chr, b, c, d> &s ) 2078 ArchiveBase &operator<<( ArchiveBase &ar, const BasicString<chr, b, c, d> &s )
2081 { 2079 {
2082 long n = s.getSize(); 2080 long n = s.getSize();
2083 ar << n; 2081 ar << n;
@@ -2086,7 +2084,7 @@ namespace Bu
2086 } 2084 }
2087 2085
2088 template<class chr, int b, class c, class d> 2086 template<class chr, int b, class c, class d>
2089 ArchiveBase &operator>>( ArchiveBase &ar, FBasicString<chr, b, c, d> &s ) 2087 ArchiveBase &operator>>( ArchiveBase &ar, BasicString<chr, b, c, d> &s )
2090 { 2088 {
2091 long n; 2089 long n;
2092 ar >> n; 2090 ar >> n;
@@ -2094,8 +2092,38 @@ namespace Bu
2094 ar.read( s.getStr(), n ); 2092 ar.read( s.getStr(), n );
2095 return ar; 2093 return ar;
2096 } 2094 }
2097}
2098 2095
2099#undef cpy 2096 typedef BasicString<char> String;
2097
2098 template<typename T>
2099 uint32_t __calcHashCode( const T &k );
2100
2101 template<typename T>
2102 bool __cmpHashKeys( const T &a, const T &b );
2103
2104 template<> uint32_t __calcHashCode<String>( const String &k );
2105 template<> bool __cmpHashKeys<String>(
2106 const String &a, const String &b );
2107
2108 template<typename t> void __tracer_format( const t &v );
2109 template<> void __tracer_format<String>( const String &v );
2110
2111 bool &operator<<( bool &dst, const String &sIn );
2112 uint8_t &operator<<( uint8_t &dst, const String &sIn );
2113 int8_t &operator<<( int8_t &dst, const String &sIn );
2114 char &operator<<( char &dst, const String &sIn );
2115 uint16_t &operator<<( uint16_t &dst, const String &sIn );
2116 int16_t &operator<<( int16_t &dst, const String &sIn );
2117 uint32_t &operator<<( uint32_t &dst, const String &sIn );
2118 int32_t &operator<<( int32_t &dst, const String &sIn );
2119 uint64_t &operator<<( uint64_t &dst, const String &sIn );
2120 int64_t &operator<<( int64_t &dst, const String &sIn );
2121 float &operator<<( float &dst, const String &sIn );
2122 double &operator<<( double &dst, const String &sIn );
2123 long double &operator<<( long double &dst, const String &sIn );
2124 Bu::String &operator<<( Bu::String &dst, const String &sIn );
2125
2126 typedef Bu::List<String> StringList;
2127};
2100 2128
2101#endif 2129#endif