aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2020-02-06 11:58:11 -0800
committerMike Buland <eichlan@xagasoft.com>2020-02-06 11:58:11 -0800
commit59be1eca587eb3da14c2e924a186396f321f5a58 (patch)
treefba9cfc643833946211ccf219c66bc50320491a5 /src
parent18648763146dace4e53692c40f074b75486a9638 (diff)
downloadlibbu++-59be1eca587eb3da14c2e924a186396f321f5a58.tar.gz
libbu++-59be1eca587eb3da14c2e924a186396f321f5a58.tar.bz2
libbu++-59be1eca587eb3da14c2e924a186396f321f5a58.tar.xz
libbu++-59be1eca587eb3da14c2e924a186396f321f5a58.zip
Closer on the TextBuilder.
Codecs are next.
Diffstat (limited to 'src')
-rw-r--r--src/unstable/textbuilder.cpp19
-rw-r--r--src/unstable/textbuilder.h2
2 files changed, 17 insertions, 4 deletions
diff --git a/src/unstable/textbuilder.cpp b/src/unstable/textbuilder.cpp
index 26b46f5..acd3501 100644
--- a/src/unstable/textbuilder.cpp
+++ b/src/unstable/textbuilder.cpp
@@ -196,8 +196,15 @@ void Bu::TextBuilderCore::copyTo( void *pDestRaw, int32_t iLength )
196 Chunk *pCur = pFirst; 196 Chunk *pCur = pFirst;
197 while( pCur && iLength ) 197 while( pCur && iLength )
198 { 198 {
199 int32_t iChunkLun = pCur->iLength; 199 int32_t iChunkLen = pCur->iLength;
200 if( iChunkLen > iLength )
201 iChunkLen = iLength;
200 202
203 memcpy( pDest, pCur->pData, iChunkLen*sizeof(CodePoint) );
204 pDest += iChunkLen;
205 iLength -= iChunkLen;
206
207 pCur = pCur->pNext;
201 } 208 }
202} 209}
203 210
@@ -225,6 +232,7 @@ Bu::TextBuilder::TextBuilder()
225 232
226Bu::TextBuilder::TextBuilder( const Text &rSrc ) 233Bu::TextBuilder::TextBuilder( const Text &rSrc )
227{ 234{
235 core->append( rSrc.getData(), rSrc.getSize() );
228} 236}
229 237
230Bu::TextBuilder::TextBuilder( const TextBuilder &rSrc ) : 238Bu::TextBuilder::TextBuilder( const TextBuilder &rSrc ) :
@@ -245,26 +253,31 @@ void Bu::TextBuilder::set( const Text &rSrc )
245void Bu::TextBuilder::append( const Text &rSrc ) 253void Bu::TextBuilder::append( const Text &rSrc )
246{ 254{
247 _hardCopy(); 255 _hardCopy();
256 core->append( rSrc.getData(), rSrc.getSize() );
248} 257}
249 258
250void Bu::TextBuilder::append( const CodePoint *pSrc, int32_t iLength ) 259void Bu::TextBuilder::append( const CodePoint *pSrc, int32_t iLength )
251{ 260{
252 _hardCopy(); 261 _hardCopy();
262 core->append( pSrc, iLength );
253} 263}
254 264
255void Bu::TextBuilder::prepend( const Text &rSrc ) 265void Bu::TextBuilder::prepend( const Text &rSrc )
256{ 266{
257 _hardCopy(); 267 _hardCopy();
268 core->prepend( rSrc.getData(), rSrc.getSize() );
258} 269}
259 270
260void Bu::TextBuilder::insert( const Text &rSrc ) 271void Bu::TextBuilder::insert( int32_t iBefore, const Text &rSrc )
261{ 272{
262 _hardCopy(); 273 _hardCopy();
274 core->insert( iBefore, rSrc.getData(), rSrc.getSize() );
263} 275}
264 276
265void Bu::TextBuilder::clear() 277void Bu::TextBuilder::clear()
266{ 278{
267 _hardCopy(); 279 _hardCopy();
280 core->clear();
268} 281}
269 282
270int32_t Bu::TextBuilder::getSize() const 283int32_t Bu::TextBuilder::getSize() const
@@ -295,7 +308,7 @@ Bu::TextBuilder &Bu::TextBuilder::operator=( const Text &rSrc )
295 308
296Bu::TextBuilder &Bu::TextBuilder::operator==( const Text &rSrc ) 309Bu::TextBuilder &Bu::TextBuilder::operator==( const Text &rSrc )
297{ 310{
298 set( pSrc ); 311
299 return *this; 312 return *this;
300} 313}
301 314
diff --git a/src/unstable/textbuilder.h b/src/unstable/textbuilder.h
index f0dee8c..8c49f2a 100644
--- a/src/unstable/textbuilder.h
+++ b/src/unstable/textbuilder.h
@@ -70,7 +70,7 @@ namespace Bu
70 void append( const Text &rSrc ); 70 void append( const Text &rSrc );
71 void append( const CodePoint *pSrc, int32_t iLength ); 71 void append( const CodePoint *pSrc, int32_t iLength );
72 void prepend( const Text &rSrc ); 72 void prepend( const Text &rSrc );
73 void insert( const Text &rSrc ); 73 void insert( int32_t iBefore, const Text &rSrc );
74 void clear(); 74 void clear();
75 75
76 int32_t getSize() const; 76 int32_t getSize() const;