diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-07-18 07:17:10 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-07-18 07:17:10 +0000 |
commit | 162525457320b5dba9a4e736759f840757635231 (patch) | |
tree | b00464b34a924f41622bebef4fa3b72750744bd6 /src/fstring.h | |
parent | d7ea32daa44c9e0cc4ac00a69168b4e1d182082b (diff) | |
download | libbu++-162525457320b5dba9a4e736759f840757635231.tar.gz libbu++-162525457320b5dba9a4e736759f840757635231.tar.bz2 libbu++-162525457320b5dba9a4e736759f840757635231.tar.xz libbu++-162525457320b5dba9a4e736759f840757635231.zip |
Incorporated a patch contributed by Brandon CS Sanders that allows libbu++ to
compile under OSX. So far, no problems with anything else, it looks like build
and nango both build without problems, libbu++ is truly becoming a full cross-
platform toolkit.
Diffstat (limited to 'src/fstring.h')
-rw-r--r-- | src/fstring.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/fstring.h b/src/fstring.h index 72ac99d..4dee537 100644 --- a/src/fstring.h +++ b/src/fstring.h | |||
@@ -25,11 +25,11 @@ namespace Bu | |||
25 | * generation in mind. Like the standard string class you can specify what | 25 | * generation in mind. Like the standard string class you can specify what |
26 | * datatype to use for each character. Unlike the standard string class, | 26 | * datatype to use for each character. Unlike the standard string class, |
27 | * collection of appended and prepended terms is done lazily, making long | 27 | * collection of appended and prepended terms is done lazily, making long |
28 | * operations that involve many appends very inexpensive. In addition internal | 28 | * operations that involve many appends very inexpensive. In addition |
29 | * ref-counting means that if you pass strings around between functions there's | 29 | * internal ref-counting means that if you pass strings around between |
30 | * almost no overhead in time or memory since a reference is created and no | 30 | * functions there's almost no overhead in time or memory since a reference |
31 | * data is actually copied. This also means that you never need to put any | 31 | * is created and no data is actually copied. This also means that you |
32 | * FBasicString into a ref-counting container class. | 32 | * never need to put any FBasicString into a ref-counting container class. |
33 | * | 33 | * |
34 | *@param chr (typename) Type of character (i.e. char) | 34 | *@param chr (typename) Type of character (i.e. char) |
35 | *@param nMinSize (int) Chunk size (default: 256) | 35 | *@param nMinSize (int) Chunk size (default: 256) |
@@ -126,7 +126,7 @@ namespace Bu | |||
126 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); | 126 | for( nLen = 0; pData[nLen] != (chr)0; nLen++ ); |
127 | if( nLen == 0 ) | 127 | if( nLen == 0 ) |
128 | return; | 128 | return; |
129 | 129 | ||
130 | Chunk *pNew = newChunk( nLen ); | 130 | Chunk *pNew = newChunk( nLen ); |
131 | cpy( pNew->pData, pData, nLen ); | 131 | cpy( pNew->pData, pData, nLen ); |
132 | 132 | ||
@@ -156,7 +156,16 @@ namespace Bu | |||
156 | */ | 156 | */ |
157 | void append( const chr &cData ) | 157 | void append( const chr &cData ) |
158 | { | 158 | { |
159 | append( &cData, 1 ); | 159 | if( pLast && pLast->nLength < nMinSize ) |
160 | { | ||
161 | pLast->pData[pLast->nLength] = cData; | ||
162 | ++pLast->nLength; ++nLength; | ||
163 | // pLast->pData[pLast->nLength] = (chr)0; | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | append( &cData, 1 ); | ||
168 | } | ||
160 | } | 169 | } |
161 | 170 | ||
162 | /** | 171 | /** |
@@ -323,11 +332,21 @@ namespace Bu | |||
323 | * Plus equals operator for FString. | 332 | * Plus equals operator for FString. |
324 | *@param pData (const chr) The character to append to your FString. | 333 | *@param pData (const chr) The character to append to your FString. |
325 | */ | 334 | */ |
326 | MyType &operator +=( const chr pData ) | 335 | MyType &operator +=( const chr cData ) |
327 | { | 336 | { |
328 | append( &pData, 1 ); | 337 | if( pLast && pLast->nLength < nMinSize ) |
338 | { | ||
339 | pLast->pData[pLast->nLength] = cData; | ||
340 | ++pLast->nLength; ++nLength; | ||
341 | // pLast->pData[pLast->nLength] = (chr)0; | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | append( &cData, 1 ); | ||
346 | } | ||
347 | //append( pData ); | ||
329 | 348 | ||
330 | return (*this); | 349 | //return (*this); |
331 | } | 350 | } |
332 | 351 | ||
333 | /** | 352 | /** |
@@ -714,7 +733,7 @@ namespace Bu | |||
714 | Chunk *pNew = aChunk.allocate( 1 ); | 733 | Chunk *pNew = aChunk.allocate( 1 ); |
715 | pNew->pNext = NULL; | 734 | pNew->pNext = NULL; |
716 | pNew->nLength = nLen; | 735 | pNew->nLength = nLen; |
717 | pNew->pData = aChr.allocate( nLen+1 ); | 736 | pNew->pData = aChr.allocate( (nLen<nMinSize)?(nMinSize):(nLen)+1 ); |
718 | pNew->pData[nLen] = (chr)0; | 737 | pNew->pData[nLen] = (chr)0; |
719 | return pNew; | 738 | return pNew; |
720 | } | 739 | } |