diff options
Diffstat (limited to '')
| -rw-r--r-- | src/stable/variant.cpp | 15 | ||||
| -rw-r--r-- | src/unstable/utfstring.cpp | 15 | ||||
| -rw-r--r-- | src/unstable/utfstring.h | 2 |
3 files changed, 28 insertions, 4 deletions
diff --git a/src/stable/variant.cpp b/src/stable/variant.cpp index 5100e9c..674ae04 100644 --- a/src/stable/variant.cpp +++ b/src/stable/variant.cpp | |||
| @@ -53,10 +53,17 @@ Bu::Variant::~Variant() | |||
| 53 | 53 | ||
| 54 | Bu::String Bu::Variant::toString() const | 54 | Bu::String Bu::Variant::toString() const |
| 55 | { | 55 | { |
| 56 | Bu::MemBuf mb; | 56 | if( getType() == typeid( Bu::String ) ) |
| 57 | Bu::Formatter f( mb ); | 57 | { |
| 58 | f << *this; | 58 | return get<Bu::String>(); |
| 59 | return mb.getString(); | 59 | } |
| 60 | else | ||
| 61 | { | ||
| 62 | Bu::MemBuf mb; | ||
| 63 | Bu::Formatter f( mb ); | ||
| 64 | f << *this; | ||
| 65 | return mb.getString(); | ||
| 66 | } | ||
| 60 | } | 67 | } |
| 61 | 68 | ||
| 62 | bool Bu::Variant::isSet() const | 69 | bool Bu::Variant::isSet() const |
diff --git a/src/unstable/utfstring.cpp b/src/unstable/utfstring.cpp index a5d6605..1c6813c 100644 --- a/src/unstable/utfstring.cpp +++ b/src/unstable/utfstring.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "bu/stream.h" | 11 | #include "bu/stream.h" |
| 12 | #include "bu/config.h" | 12 | #include "bu/config.h" |
| 13 | #include "bu/sio.h" | 13 | #include "bu/sio.h" |
| 14 | #include "bu/membuf.h" | ||
| 14 | using Bu::sio; | 15 | using Bu::sio; |
| 15 | 16 | ||
| 16 | Bu::UtfString::UtfString() | 17 | Bu::UtfString::UtfString() |
| @@ -86,6 +87,13 @@ void Bu::UtfString::append( UtfChar ch ) | |||
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 90 | void Bu::UtfString::append( const UtfString &rSrc ) | ||
| 91 | { | ||
| 92 | aData.append( rSrc.aData ); | ||
| 93 | iRawLen += rSrc.iRawLen; | ||
| 94 | iCharLen += rSrc.iCharLen; | ||
| 95 | } | ||
| 96 | |||
| 89 | void Bu::UtfString::setUtf8( const Bu::String &sInput ) | 97 | void Bu::UtfString::setUtf8( const Bu::String &sInput ) |
| 90 | { | 98 | { |
| 91 | static uint8_t lmask[8] = { | 99 | static uint8_t lmask[8] = { |
| @@ -468,6 +476,13 @@ Bu::UtfChar Bu::UtfString::nextChar( int &iIndex ) | |||
| 468 | } | 476 | } |
| 469 | } | 477 | } |
| 470 | 478 | ||
| 479 | Bu::String Bu::UtfString::get( Encoding eEnc ) | ||
| 480 | { | ||
| 481 | Bu::MemBuf mb; | ||
| 482 | write( mb, eEnc ); | ||
| 483 | return mb.getString(); | ||
| 484 | } | ||
| 485 | |||
| 471 | void Bu::UtfString::debug() | 486 | void Bu::UtfString::debug() |
| 472 | { | 487 | { |
| 473 | sio << "Raw Utf16: "; | 488 | sio << "Raw Utf16: "; |
diff --git a/src/unstable/utfstring.h b/src/unstable/utfstring.h index 02b015b..af233e8 100644 --- a/src/unstable/utfstring.h +++ b/src/unstable/utfstring.h | |||
| @@ -107,6 +107,8 @@ namespace Bu | |||
| 107 | */ | 107 | */ |
| 108 | void append( UtfChar ch ); | 108 | void append( UtfChar ch ); |
| 109 | 109 | ||
| 110 | void append( const UtfString &rSrc ); | ||
| 111 | |||
| 110 | /** | 112 | /** |
| 111 | * Set the value of the entire string based on the given input and | 113 | * Set the value of the entire string based on the given input and |
| 112 | * encoding. The default encoding is Utf8, which is compatible with | 114 | * encoding. The default encoding is Utf8, which is compatible with |
