aboutsummaryrefslogtreecommitdiff
path: root/src/fstring.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 */