diff options
Diffstat (limited to 'src/unstable/text.cpp')
| -rw-r--r-- | src/unstable/text.cpp | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/src/unstable/text.cpp b/src/unstable/text.cpp index 9e5670d..be4c10f 100644 --- a/src/unstable/text.cpp +++ b/src/unstable/text.cpp | |||
| @@ -6,22 +6,35 @@ | |||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include "bu/text.h" | 8 | #include "bu/text.h" |
| 9 | #include "bu/textbuilder.h" | ||
| 10 | |||
| 11 | #include "bu/exceptionbase.h" | ||
| 12 | |||
| 9 | #include <string.h> | 13 | #include <string.h> |
| 10 | 14 | ||
| 11 | Bu::Text::Text() : | 15 | Bu::Text::Text() : |
| 12 | pData( NULL ), | 16 | pData( NULL ), |
| 13 | iSize( 0 ), | 17 | bIsBmpOnly( true ), |
| 14 | iCodePoints( 0 ) | 18 | iSize( 0 ) |
| 15 | { | 19 | { |
| 16 | } | 20 | } |
| 17 | 21 | ||
| 18 | Bu::Text::Text( const Text &rSrc ) : | 22 | Bu::Text::Text( const Text &rSrc ) : |
| 19 | pData( NULL ), | 23 | pData( NULL ), |
| 20 | iSize( rSrc.iSize ), | 24 | bIsBmpOnly( rSrc.bIsBmpOnly ), |
| 21 | iCodePoints( rSrc.iCodePoints ) | 25 | iSize( rSrc.iSize ) |
| 26 | { | ||
| 27 | pData = new CodePoint[iSize]; | ||
| 28 | memcpy( pData, rSrc.pData, sizeof(CodePoint)*iSize ); | ||
| 29 | } | ||
| 30 | |||
| 31 | Bu::Text::Text( const TextBuilder &rSrc ) : | ||
| 32 | pData( NULL ), | ||
| 33 | bIsBmpOnly( true ), | ||
| 34 | iSize( rSrc.getSize() ) | ||
| 22 | { | 35 | { |
| 23 | pData = new uint16_t[iSize]; | 36 | pData = new CodePoint[iSize]; |
| 24 | memcpy( pData, rSrc.pData, sizeof(uint16_t)*iSize ); | 37 | |
| 25 | } | 38 | } |
| 26 | 39 | ||
| 27 | Bu::Text::~Text() | 40 | Bu::Text::~Text() |
| @@ -30,4 +43,35 @@ Bu::Text::~Text() | |||
| 30 | pData = NULL; | 43 | pData = NULL; |
| 31 | } | 44 | } |
| 32 | 45 | ||
| 46 | bool Bu::Text::isEmpty() const | ||
| 47 | { | ||
| 48 | return (iSize == 0); | ||
| 49 | } | ||
| 50 | |||
| 51 | bool Bu::Text::isBmpOnly() const | ||
| 52 | { | ||
| 53 | return bIsBmpOnly; | ||
| 54 | } | ||
| 55 | |||
| 56 | int32_t Bu::Text::getSize() const | ||
| 57 | { | ||
| 58 | return iSize; | ||
| 59 | } | ||
| 60 | |||
| 61 | int32_t Bu::Text::getSizeInBytes() const | ||
| 62 | { | ||
| 63 | return iSize*sizeof(CodePoint); | ||
| 64 | } | ||
| 65 | |||
| 66 | Bu::CodePoint Bu::Text::operator[]( int32_t iIndex ) const | ||
| 67 | { | ||
| 68 | if( iIndex < 0 || iIndex >= iSize ) | ||
| 69 | throw Bu::ExceptionBase("Index out of range."); | ||
| 70 | return pData[iIndex]; | ||
| 71 | } | ||
| 72 | |||
| 73 | Bu::CodePoint *Bu::Text::getData() const | ||
| 74 | { | ||
| 75 | return pData; | ||
| 76 | } | ||
| 33 | 77 | ||
