aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-06-04 08:11:36 +0000
committerMike Buland <eichlan@xagasoft.com>2012-06-04 08:11:36 +0000
commit026cd6f71a15edd1a242c59d5cb9f8271a108506 (patch)
treedc2d2ee77b94fa83e8312a2c3bb0d4531cf635e2 /src
parent8ff104489cf8eb6322bec90ebc8d66fedae665c9 (diff)
downloadlibbu++-026cd6f71a15edd1a242c59d5cb9f8271a108506.tar.gz
libbu++-026cd6f71a15edd1a242c59d5cb9f8271a108506.tar.bz2
libbu++-026cd6f71a15edd1a242c59d5cb9f8271a108506.tar.xz
libbu++-026cd6f71a15edd1a242c59d5cb9f8271a108506.zip
UtfString supports get and append now, but it still needs a lot of work.
Diffstat (limited to 'src')
-rw-r--r--src/stable/variant.cpp15
-rw-r--r--src/unstable/utfstring.cpp15
-rw-r--r--src/unstable/utfstring.h2
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
54Bu::String Bu::Variant::toString() const 54Bu::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
62bool Bu::Variant::isSet() const 69bool 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"
14using Bu::sio; 15using Bu::sio;
15 16
16Bu::UtfString::UtfString() 17Bu::UtfString::UtfString()
@@ -86,6 +87,13 @@ void Bu::UtfString::append( UtfChar ch )
86 } 87 }
87} 88}
88 89
90void Bu::UtfString::append( const UtfString &rSrc )
91{
92 aData.append( rSrc.aData );
93 iRawLen += rSrc.iRawLen;
94 iCharLen += rSrc.iCharLen;
95}
96
89void Bu::UtfString::setUtf8( const Bu::String &sInput ) 97void 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
479Bu::String Bu::UtfString::get( Encoding eEnc )
480{
481 Bu::MemBuf mb;
482 write( mb, eEnc );
483 return mb.getString();
484}
485
471void Bu::UtfString::debug() 486void 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