aboutsummaryrefslogtreecommitdiff
path: root/src/fstring.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-11-23 23:47:37 +0000
committerMike Buland <eichlan@xagasoft.com>2007-11-23 23:47:37 +0000
commitc9574d3f77081fb4a654d42c298d6ebf34abca51 (patch)
tree0410f4d63923984eb3fe2daac10bae9145e45032 /src/fstring.h
parentcd215f0da23e16c3f1a7200f2b9f67f23c9b4be7 (diff)
downloadlibbu++-c9574d3f77081fb4a654d42c298d6ebf34abca51.tar.gz
libbu++-c9574d3f77081fb4a654d42c298d6ebf34abca51.tar.bz2
libbu++-c9574d3f77081fb4a654d42c298d6ebf34abca51.tar.xz
libbu++-c9574d3f77081fb4a654d42c298d6ebf34abca51.zip
Bu::FString now has insert and remove functions, yay!
Diffstat (limited to 'src/fstring.h')
-rw-r--r--src/fstring.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/fstring.h b/src/fstring.h
index 8cccd5c..8b512e2 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -226,6 +226,45 @@ namespace Bu
226 prependChunk( pNew ); 226 prependChunk( pNew );
227 } 227 }
228 228
229 void insert( long nPos, const chr *pData, long nLen )
230 {
231 if( nLen <= 0 )
232 return;
233 flatten();
234 if( nPos <= 0 )
235 {
236 prepend( pData, nLen );
237 }
238 else if( nPos >= nLength )
239 {
240 append( pData, nLen );
241 }
242 else
243 {
244 Chunk *p1 = newChunk( nPos );
245 Chunk *p2 = newChunk( nLen );
246 Chunk *p3 = newChunk( nLength-nPos );
247 cpy( p1->pData, pFirst->pData, nPos );
248 cpy( p2->pData, pData, nLen );
249 cpy( p3->pData, pFirst->pData+nPos, nLength-nPos );
250 clear();
251 appendChunk( p1 );
252 appendChunk( p2 );
253 appendChunk( p3 );
254 }
255 }
256
257 void remove( long nPos, long nLen )
258 {
259 if( nLen <= 0 || nPos < 0 || nPos >= nLength )
260 return;
261 if( nLen >= nLength-nPos )
262 nLen = nLength-nPos-1;
263 flatten();
264 cpy( pFirst->pData+nPos, pFirst->pData+nPos+nLen, nLen+1 );
265 nLength -= nPos;
266 }
267
229 /** 268 /**
230 *@todo void prepend( const chr &cData ) 269 *@todo void prepend( const chr &cData )
231 */ 270 */