From 59be1eca587eb3da14c2e924a186396f321f5a58 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 6 Feb 2020 11:58:11 -0800 Subject: Closer on the TextBuilder. Codecs are next. --- src/unstable/textbuilder.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/unstable/textbuilder.cpp') 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 ) Chunk *pCur = pFirst; while( pCur && iLength ) { - int32_t iChunkLun = pCur->iLength; + int32_t iChunkLen = pCur->iLength; + if( iChunkLen > iLength ) + iChunkLen = iLength; + memcpy( pDest, pCur->pData, iChunkLen*sizeof(CodePoint) ); + pDest += iChunkLen; + iLength -= iChunkLen; + + pCur = pCur->pNext; } } @@ -225,6 +232,7 @@ Bu::TextBuilder::TextBuilder() Bu::TextBuilder::TextBuilder( const Text &rSrc ) { + core->append( rSrc.getData(), rSrc.getSize() ); } Bu::TextBuilder::TextBuilder( const TextBuilder &rSrc ) : @@ -245,26 +253,31 @@ void Bu::TextBuilder::set( const Text &rSrc ) void Bu::TextBuilder::append( const Text &rSrc ) { _hardCopy(); + core->append( rSrc.getData(), rSrc.getSize() ); } void Bu::TextBuilder::append( const CodePoint *pSrc, int32_t iLength ) { _hardCopy(); + core->append( pSrc, iLength ); } void Bu::TextBuilder::prepend( const Text &rSrc ) { _hardCopy(); + core->prepend( rSrc.getData(), rSrc.getSize() ); } -void Bu::TextBuilder::insert( const Text &rSrc ) +void Bu::TextBuilder::insert( int32_t iBefore, const Text &rSrc ) { _hardCopy(); + core->insert( iBefore, rSrc.getData(), rSrc.getSize() ); } void Bu::TextBuilder::clear() { _hardCopy(); + core->clear(); } int32_t Bu::TextBuilder::getSize() const @@ -295,7 +308,7 @@ Bu::TextBuilder &Bu::TextBuilder::operator=( const Text &rSrc ) Bu::TextBuilder &Bu::TextBuilder::operator==( const Text &rSrc ) { - set( pSrc ); + return *this; } -- cgit v1.2.3