diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2023-04-24 09:16:32 -0700 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2023-04-24 09:16:32 -0700 |
commit | e1115a28535663cfe404791ede5bb7ca70399053 (patch) | |
tree | b9d273abd126e410fb59d39d9c99072149a14c5c /src/unstable | |
parent | 44409ec7257cb20ff091079eb55dc7a8d4049cf9 (diff) | |
download | libbu++-e1115a28535663cfe404791ede5bb7ca70399053.tar.gz libbu++-e1115a28535663cfe404791ede5bb7ca70399053.tar.bz2 libbu++-e1115a28535663cfe404791ede5bb7ca70399053.tar.xz libbu++-e1115a28535663cfe404791ede5bb7ca70399053.zip |
Additions to blob/utfstring for json.
Diffstat (limited to '')
-rw-r--r-- | src/unstable/blob.cpp | 47 | ||||
-rw-r--r-- | src/unstable/blob.h | 10 | ||||
-rw-r--r-- | src/unstable/settingsdrivertaf.cpp | 6 | ||||
-rw-r--r-- | src/unstable/utfstring.cpp | 55 | ||||
-rw-r--r-- | src/unstable/utfstring.h | 29 |
5 files changed, 107 insertions, 40 deletions
diff --git a/src/unstable/blob.cpp b/src/unstable/blob.cpp index e72e265..23987f3 100644 --- a/src/unstable/blob.cpp +++ b/src/unstable/blob.cpp | |||
@@ -499,6 +499,26 @@ Bu::Blob::iterator &Bu::Blob::iterator::operator--() | |||
499 | return *this; | 499 | return *this; |
500 | } | 500 | } |
501 | 501 | ||
502 | Bu::Blob::iterator &Bu::Blob::iterator::operator+=( int32_t iDelta ) | ||
503 | { | ||
504 | if( bForward ) | ||
505 | iIndex += iDelta; | ||
506 | else | ||
507 | iIndex -= iDelta; | ||
508 | |||
509 | return *this; | ||
510 | } | ||
511 | |||
512 | Bu::Blob::iterator &Bu::Blob::iterator::operator-=( int32_t iDelta ) | ||
513 | { | ||
514 | if( bForward ) | ||
515 | iIndex -= iDelta; | ||
516 | else | ||
517 | iIndex += iDelta; | ||
518 | |||
519 | return *this; | ||
520 | } | ||
521 | |||
502 | Bu::Blob::iterator Bu::Blob::iterator::operator+( int32_t iDelta ) const | 522 | Bu::Blob::iterator Bu::Blob::iterator::operator+( int32_t iDelta ) const |
503 | { | 523 | { |
504 | return iterator( pBlob, iIndex + iDelta, bForward ); | 524 | return iterator( pBlob, iIndex + iDelta, bForward ); |
@@ -541,7 +561,8 @@ bool Bu::Blob::iterator::operator!=( const Bu::Blob::const_iterator &rRhs ) | |||
541 | return pBlob != rRhs.pBlob || iIndex != rRhs.iIndex; | 561 | return pBlob != rRhs.pBlob || iIndex != rRhs.iIndex; |
542 | } | 562 | } |
543 | 563 | ||
544 | Bu::Blob::iterator &Bu::Blob::iterator::operator=( Bu::Blob::iterator &rRhs ) | 564 | Bu::Blob::iterator &Bu::Blob::iterator::operator=( |
565 | const Bu::Blob::iterator &rRhs ) | ||
545 | { | 566 | { |
546 | pBlob = rRhs.pBlob; | 567 | pBlob = rRhs.pBlob; |
547 | iIndex = rRhs.iIndex; | 568 | iIndex = rRhs.iIndex; |
@@ -651,6 +672,26 @@ Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator--() | |||
651 | return *this; | 672 | return *this; |
652 | } | 673 | } |
653 | 674 | ||
675 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator+=( int32_t iDelta ) | ||
676 | { | ||
677 | if( bForward ) | ||
678 | iIndex += iDelta; | ||
679 | else | ||
680 | iIndex -= iDelta; | ||
681 | |||
682 | return *this; | ||
683 | } | ||
684 | |||
685 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator-=( int32_t iDelta ) | ||
686 | { | ||
687 | if( bForward ) | ||
688 | iIndex -= iDelta; | ||
689 | else | ||
690 | iIndex += iDelta; | ||
691 | |||
692 | return *this; | ||
693 | } | ||
694 | |||
654 | Bu::Blob::const_iterator Bu::Blob::const_iterator::operator+( int32_t iDelta ) | 695 | Bu::Blob::const_iterator Bu::Blob::const_iterator::operator+( int32_t iDelta ) |
655 | const | 696 | const |
656 | { | 697 | { |
@@ -698,7 +739,7 @@ bool Bu::Blob::const_iterator::operator!=( | |||
698 | } | 739 | } |
699 | 740 | ||
700 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator=( | 741 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator=( |
701 | Bu::Blob::iterator &rRhs ) | 742 | const Bu::Blob::iterator &rRhs ) |
702 | { | 743 | { |
703 | pBlob = rRhs.pBlob; | 744 | pBlob = rRhs.pBlob; |
704 | iIndex = rRhs.iIndex; | 745 | iIndex = rRhs.iIndex; |
@@ -708,7 +749,7 @@ Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator=( | |||
708 | } | 749 | } |
709 | 750 | ||
710 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator=( | 751 | Bu::Blob::const_iterator &Bu::Blob::const_iterator::operator=( |
711 | Bu::Blob::const_iterator &rRhs ) | 752 | const Bu::Blob::const_iterator &rRhs ) |
712 | { | 753 | { |
713 | pBlob = rRhs.pBlob; | 754 | pBlob = rRhs.pBlob; |
714 | iIndex = rRhs.iIndex; | 755 | iIndex = rRhs.iIndex; |
diff --git a/src/unstable/blob.h b/src/unstable/blob.h index d6c40e3..bda29d6 100644 --- a/src/unstable/blob.h +++ b/src/unstable/blob.h | |||
@@ -100,6 +100,8 @@ namespace Bu | |||
100 | iterator &operator++(); | 100 | iterator &operator++(); |
101 | iterator &operator--( int32_t ); | 101 | iterator &operator--( int32_t ); |
102 | iterator &operator--(); | 102 | iterator &operator--(); |
103 | iterator &operator+=( int32_t iDelta ); | ||
104 | iterator &operator-=( int32_t iDelta ); | ||
103 | iterator operator+( int32_t iDelta ) const; | 105 | iterator operator+( int32_t iDelta ) const; |
104 | iterator operator-( int32_t iDelta ) const; | 106 | iterator operator-( int32_t iDelta ) const; |
105 | bool operator==( const iterator &rRhs ); | 107 | bool operator==( const iterator &rRhs ); |
@@ -107,7 +109,7 @@ namespace Bu | |||
107 | bool operator!=( const iterator &rRhs ); | 109 | bool operator!=( const iterator &rRhs ); |
108 | bool operator!=( const const_iterator &rRhs ); | 110 | bool operator!=( const const_iterator &rRhs ); |
109 | 111 | ||
110 | iterator &operator=( iterator &rRhs ); | 112 | iterator &operator=( const iterator &rRhs ); |
111 | 113 | ||
112 | private: | 114 | private: |
113 | Blob *pBlob; | 115 | Blob *pBlob; |
@@ -136,6 +138,8 @@ namespace Bu | |||
136 | const_iterator &operator++(); | 138 | const_iterator &operator++(); |
137 | const_iterator &operator--( int32_t ); | 139 | const_iterator &operator--( int32_t ); |
138 | const_iterator &operator--(); | 140 | const_iterator &operator--(); |
141 | const_iterator &operator+=( int32_t iDelta ); | ||
142 | const_iterator &operator-=( int32_t iDelta ); | ||
139 | const_iterator operator+( int32_t iDelta ) const; | 143 | const_iterator operator+( int32_t iDelta ) const; |
140 | const_iterator operator-( int32_t iDelta ) const; | 144 | const_iterator operator-( int32_t iDelta ) const; |
141 | bool operator==( const iterator &rRhs ); | 145 | bool operator==( const iterator &rRhs ); |
@@ -143,8 +147,8 @@ namespace Bu | |||
143 | bool operator!=( const iterator &rRhs ); | 147 | bool operator!=( const iterator &rRhs ); |
144 | bool operator!=( const const_iterator &rRhs ); | 148 | bool operator!=( const const_iterator &rRhs ); |
145 | 149 | ||
146 | const_iterator &operator=( iterator &rRhs ); | 150 | const_iterator &operator=( const iterator &rRhs ); |
147 | const_iterator &operator=( const_iterator &rRhs ); | 151 | const_iterator &operator=( const const_iterator &rRhs ); |
148 | 152 | ||
149 | private: | 153 | private: |
150 | const Blob *pBlob; | 154 | const Blob *pBlob; |
diff --git a/src/unstable/settingsdrivertaf.cpp b/src/unstable/settingsdrivertaf.cpp index 3fd61b3..d99d0ba 100644 --- a/src/unstable/settingsdrivertaf.cpp +++ b/src/unstable/settingsdrivertaf.cpp | |||
@@ -48,7 +48,7 @@ void Bu::SettingsDriverTaf::init( const Bu::UtfString &sCompany, | |||
48 | void Bu::SettingsDriverTaf::set( const Bu::UtfString &sKey, | 48 | void Bu::SettingsDriverTaf::set( const Bu::UtfString &sKey, |
49 | const Bu::UtfString &sValue ) | 49 | const Bu::UtfString &sValue ) |
50 | { | 50 | { |
51 | Bu::StringList lPath = sKey.get().split('/'); | 51 | Bu::StringList lPath = Bu::String(sKey.get()).split('/'); |
52 | Bu::StringList::iterator i = lPath.begin(); | 52 | Bu::StringList::iterator i = lPath.begin(); |
53 | Bu::StringList::iterator in; | 53 | Bu::StringList::iterator in; |
54 | Bu::TafGroup *pGrp = pRoot; | 54 | Bu::TafGroup *pGrp = pRoot; |
@@ -74,7 +74,7 @@ void Bu::SettingsDriverTaf::set( const Bu::UtfString &sKey, | |||
74 | Bu::UtfString Bu::SettingsDriverTaf::get( const Bu::UtfString &sKey, | 74 | Bu::UtfString Bu::SettingsDriverTaf::get( const Bu::UtfString &sKey, |
75 | const Bu::UtfString &sValue ) | 75 | const Bu::UtfString &sValue ) |
76 | { | 76 | { |
77 | Bu::StringList lPath = sKey.get().split('/'); | 77 | Bu::StringList lPath = Bu::String(sKey.get()).split('/'); |
78 | Bu::StringList::iterator i = lPath.begin(); | 78 | Bu::StringList::iterator i = lPath.begin(); |
79 | Bu::StringList::iterator in; | 79 | Bu::StringList::iterator in; |
80 | Bu::TafGroup *pGrp = pRoot; | 80 | Bu::TafGroup *pGrp = pRoot; |
@@ -98,5 +98,7 @@ Bu::UtfString Bu::SettingsDriverTaf::get( const Bu::UtfString &sKey, | |||
98 | } | 98 | } |
99 | i = in; | 99 | i = in; |
100 | } | 100 | } |
101 | |||
102 | return Bu::UtfString(); | ||
101 | } | 103 | } |
102 | 104 | ||
diff --git a/src/unstable/utfstring.cpp b/src/unstable/utfstring.cpp index 21b3f82..6217f80 100644 --- a/src/unstable/utfstring.cpp +++ b/src/unstable/utfstring.cpp | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "bu/utfstring.h" | 8 | #include "bu/utfstring.h" |
9 | 9 | ||
10 | #include "bu/string.h" | 10 | #include "bu/string.h" |
11 | #include "bu/blob.h" | ||
11 | #include "bu/stream.h" | 12 | #include "bu/stream.h" |
12 | #include "bu/config.h" | 13 | #include "bu/config.h" |
13 | #include "bu/sio.h" | 14 | #include "bu/sio.h" |
@@ -36,11 +37,16 @@ Bu::UtfString::UtfString( const Bu::String &sInput, Encoding eEnc ) | |||
36 | set( sInput, eEnc ); | 37 | set( sInput, eEnc ); |
37 | } | 38 | } |
38 | 39 | ||
39 | Bu::UtfString::UtfString( const char *sInput, Encoding eEnc ) | 40 | Bu::UtfString::UtfString( const Bu::Blob &sInput, Encoding eEnc ) |
40 | { | 41 | { |
41 | set( sInput, eEnc ); | 42 | set( sInput, eEnc ); |
42 | } | 43 | } |
43 | 44 | ||
45 | Bu::UtfString::UtfString( const char *sInput, Encoding eEnc ) | ||
46 | { | ||
47 | set( Bu::Blob(sInput), eEnc ); | ||
48 | } | ||
49 | |||
44 | Bu::UtfString::~UtfString() | 50 | Bu::UtfString::~UtfString() |
45 | { | 51 | { |
46 | } | 52 | } |
@@ -57,6 +63,11 @@ Bu::UtfString::const_iterator Bu::UtfString::begin() const | |||
57 | 63 | ||
58 | void Bu::UtfString::set( const Bu::String &sInput, Encoding eEnc ) | 64 | void Bu::UtfString::set( const Bu::String &sInput, Encoding eEnc ) |
59 | { | 65 | { |
66 | set( sInput, eEnc ); | ||
67 | } | ||
68 | |||
69 | void Bu::UtfString::set( const Bu::Blob &sInput, Encoding eEnc ) | ||
70 | { | ||
60 | switch( eEnc ) | 71 | switch( eEnc ) |
61 | { | 72 | { |
62 | case Utf8: | 73 | case Utf8: |
@@ -122,9 +133,9 @@ void Bu::UtfString::append( const UtfString &rSrc ) | |||
122 | iCharLen += rSrc.iCharLen; | 133 | iCharLen += rSrc.iCharLen; |
123 | } | 134 | } |
124 | 135 | ||
125 | void Bu::UtfString::setUtf8( const Bu::String &sInput ) | 136 | void Bu::UtfString::setUtf8( const Bu::Blob &sInput ) |
126 | { | 137 | { |
127 | for( Bu::String::const_iterator i = sInput.begin(); i; i++ ) | 138 | for( Bu::Blob::const_iterator i = sInput.begin(); i; i++ ) |
128 | { | 139 | { |
129 | if( ((int)(uint8_t)*i)&0x80 ) | 140 | if( ((int)(uint8_t)*i)&0x80 ) |
130 | { | 141 | { |
@@ -145,9 +156,9 @@ void Bu::UtfString::setUtf8( const Bu::String &sInput ) | |||
145 | } | 156 | } |
146 | } | 157 | } |
147 | 158 | ||
148 | void Bu::UtfString::setUtf16( const Bu::String &sInput ) | 159 | void Bu::UtfString::setUtf16( const Bu::Blob &sInput ) |
149 | { | 160 | { |
150 | // Bu::String::const_iterator i = sInput.begin(); | 161 | // Bu::Blob::const_iterator i = sInput.begin(); |
151 | if( (uint8_t)*sInput.begin() == 0xFF && | 162 | if( (uint8_t)*sInput.begin() == 0xFF && |
152 | (uint8_t)*(sInput.begin()+1) == 0xFE ) | 163 | (uint8_t)*(sInput.begin()+1) == 0xFE ) |
153 | { | 164 | { |
@@ -157,9 +168,9 @@ void Bu::UtfString::setUtf16( const Bu::String &sInput ) | |||
157 | setUtf16be( sInput ); | 168 | setUtf16be( sInput ); |
158 | } | 169 | } |
159 | 170 | ||
160 | void Bu::UtfString::setUtf16be( const Bu::String &sInput ) | 171 | void Bu::UtfString::setUtf16be( const Bu::Blob &sInput ) |
161 | { | 172 | { |
162 | Bu::String::const_iterator i = sInput.begin(); | 173 | Bu::Blob::const_iterator i = sInput.begin(); |
163 | if( (uint8_t)*sInput.begin() == 0xFE && | 174 | if( (uint8_t)*sInput.begin() == 0xFE && |
164 | (uint8_t)*(sInput.begin()+1) == 0xFF ) | 175 | (uint8_t)*(sInput.begin()+1) == 0xFF ) |
165 | 176 | ||
@@ -184,9 +195,9 @@ void Bu::UtfString::setUtf16be( const Bu::String &sInput ) | |||
184 | } | 195 | } |
185 | } | 196 | } |
186 | 197 | ||
187 | void Bu::UtfString::setUtf16le( const Bu::String &sInput ) | 198 | void Bu::UtfString::setUtf16le( const Bu::Blob &sInput ) |
188 | { | 199 | { |
189 | Bu::String::const_iterator i = sInput.begin(); | 200 | Bu::Blob::const_iterator i = sInput.begin(); |
190 | if( (uint8_t)*sInput.begin() == 0xFF && | 201 | if( (uint8_t)*sInput.begin() == 0xFF && |
191 | (uint8_t)*(sInput.begin()+1) == 0xFE ) | 202 | (uint8_t)*(sInput.begin()+1) == 0xFE ) |
192 | { | 203 | { |
@@ -210,9 +221,9 @@ void Bu::UtfString::setUtf16le( const Bu::String &sInput ) | |||
210 | } | 221 | } |
211 | } | 222 | } |
212 | 223 | ||
213 | void Bu::UtfString::setUtf32( const Bu::String &sInput ) | 224 | void Bu::UtfString::setUtf32( const Bu::Blob &sInput ) |
214 | { | 225 | { |
215 | Bu::String::const_iterator i = sInput.begin(); | 226 | Bu::Blob::const_iterator i = sInput.begin(); |
216 | if( (uint8_t)*i == 0x00 && | 227 | if( (uint8_t)*i == 0x00 && |
217 | (uint8_t)*(++i) == 0x00 && | 228 | (uint8_t)*(++i) == 0x00 && |
218 | (uint8_t)*(++i) == 0xFF && | 229 | (uint8_t)*(++i) == 0xFF && |
@@ -224,9 +235,9 @@ void Bu::UtfString::setUtf32( const Bu::String &sInput ) | |||
224 | setUtf32be( sInput ); | 235 | setUtf32be( sInput ); |
225 | } | 236 | } |
226 | 237 | ||
227 | void Bu::UtfString::setUtf32be( const Bu::String &sInput ) | 238 | void Bu::UtfString::setUtf32be( const Bu::Blob &sInput ) |
228 | { | 239 | { |
229 | Bu::String::const_iterator i = sInput.begin(); | 240 | Bu::Blob::const_iterator i = sInput.begin(); |
230 | if( (uint8_t)*i == 0x00 && | 241 | if( (uint8_t)*i == 0x00 && |
231 | (uint8_t)*(++i) == 0x00 && | 242 | (uint8_t)*(++i) == 0x00 && |
232 | (uint8_t)*(++i) == 0xFE && | 243 | (uint8_t)*(++i) == 0xFE && |
@@ -250,9 +261,9 @@ void Bu::UtfString::setUtf32be( const Bu::String &sInput ) | |||
250 | } | 261 | } |
251 | } | 262 | } |
252 | 263 | ||
253 | void Bu::UtfString::setUtf32le( const Bu::String &sInput ) | 264 | void Bu::UtfString::setUtf32le( const Bu::Blob &sInput ) |
254 | { | 265 | { |
255 | Bu::String::const_iterator i = sInput.begin(); | 266 | Bu::Blob::const_iterator i = sInput.begin(); |
256 | if( (uint8_t)*i == 0x00 && | 267 | if( (uint8_t)*i == 0x00 && |
257 | (uint8_t)*(++i) == 0x00 && | 268 | (uint8_t)*(++i) == 0x00 && |
258 | (uint8_t)*(++i) == 0xFF && | 269 | (uint8_t)*(++i) == 0xFF && |
@@ -443,12 +454,12 @@ int Bu::UtfString::writePoint( Bu::Stream &sOut, const Bu::UtfChar &c, | |||
443 | 454 | ||
444 | int32_t Bu::UtfString::toInt32( int iRadix ) const | 455 | int32_t Bu::UtfString::toInt32( int iRadix ) const |
445 | { | 456 | { |
446 | return strtol( get().getStr(), NULL, iRadix ); | 457 | return strtol( get().getData(), NULL, iRadix ); |
447 | } | 458 | } |
448 | 459 | ||
449 | int64_t Bu::UtfString::toInt64( int iRadix ) const | 460 | int64_t Bu::UtfString::toInt64( int iRadix ) const |
450 | { | 461 | { |
451 | return strtoll( get().getStr(), NULL, iRadix ); | 462 | return strtoll( get().getData(), NULL, iRadix ); |
452 | } | 463 | } |
453 | 464 | ||
454 | void Bu::UtfString::writeUtf8( Bu::Stream &sOut ) const | 465 | void Bu::UtfString::writeUtf8( Bu::Stream &sOut ) const |
@@ -626,7 +637,7 @@ bool Bu::UtfString::operator==( const Bu::UtfString &rhs ) const | |||
626 | return aData == rhs.aData; | 637 | return aData == rhs.aData; |
627 | } | 638 | } |
628 | 639 | ||
629 | bool Bu::UtfString::operator==( const Bu::String &rhs ) const | 640 | bool Bu::UtfString::operator==( const Bu::Blob &rhs ) const |
630 | { | 641 | { |
631 | // Nieve comparison | 642 | // Nieve comparison |
632 | if( aData.getSize() != rhs.getSize() ) | 643 | if( aData.getSize() != rhs.getSize() ) |
@@ -718,11 +729,11 @@ bool Bu::UtfString::operator>=( const Bu::UtfString &rhs ) const | |||
718 | return false; | 729 | return false; |
719 | } | 730 | } |
720 | 731 | ||
721 | Bu::String Bu::UtfString::get( Encoding eEnc ) const | 732 | Bu::Blob Bu::UtfString::get( Encoding eEnc ) const |
722 | { | 733 | { |
723 | Bu::MemBuf mb; | 734 | Bu::MemBuf mb; |
724 | write( mb, eEnc ); | 735 | write( mb, eEnc ); |
725 | return mb.getString(); | 736 | return Bu::Blob( mb.getString().getStr(), mb.getString().getSize() ); |
726 | } | 737 | } |
727 | 738 | ||
728 | void Bu::UtfString::debug() const | 739 | void Bu::UtfString::debug() const |
@@ -745,9 +756,9 @@ void Bu::UtfString::debug() const | |||
745 | sio << sio.nl; | 756 | sio << sio.nl; |
746 | } | 757 | } |
747 | /* | 758 | /* |
748 | void Bu::UtfString::debugUtf8( const Bu::String &sUtf8 ) | 759 | void Bu::UtfString::debugUtf8( const Bu::Blob &sUtf8 ) |
749 | { | 760 | { |
750 | for( Bu::String::const_iterator i = sUtf8.begin(); i; i++ ) | 761 | for( Bu::Blob::const_iterator i = sUtf8.begin(); i; i++ ) |
751 | { | 762 | { |
752 | if( i != sUtf8.begin() ) | 763 | if( i != sUtf8.begin() ) |
753 | sio << ", "; | 764 | sio << ", "; |
diff --git a/src/unstable/utfstring.h b/src/unstable/utfstring.h index 5a72948..3c64a75 100644 --- a/src/unstable/utfstring.h +++ b/src/unstable/utfstring.h | |||
@@ -72,6 +72,7 @@ namespace Bu | |||
72 | 72 | ||
73 | UtfString(); | 73 | UtfString(); |
74 | UtfString( const Bu::String &sInput, Encoding eEnc=Utf8 ); | 74 | UtfString( const Bu::String &sInput, Encoding eEnc=Utf8 ); |
75 | UtfString( const Bu::Blob &sInput, Encoding eEnc=Utf8 ); | ||
75 | UtfString( const char *sInput, Encoding eEnc=Utf8 ); | 76 | UtfString( const char *sInput, Encoding eEnc=Utf8 ); |
76 | virtual ~UtfString(); | 77 | virtual ~UtfString(); |
77 | 78 | ||
@@ -182,6 +183,14 @@ namespace Bu | |||
182 | * string literals in code. | 183 | * string literals in code. |
183 | */ | 184 | */ |
184 | void set( const Bu::String &sInput, Encoding eEnc=Utf8 ); | 185 | void set( const Bu::String &sInput, Encoding eEnc=Utf8 ); |
186 | |||
187 | /** | ||
188 | * Set the value of the entire string based on the given input and | ||
189 | * encoding. The default encoding is Utf8, which is compatible with | ||
190 | * 7-bit ascii, so it's a great choice for setting UtfStrings from | ||
191 | * string literals in code. | ||
192 | */ | ||
193 | void set( const Bu::Blob &bInput, Encoding eEnc=Utf8 ); | ||
185 | 194 | ||
186 | /** | 195 | /** |
187 | * This encodes the UtfString in the given encoding and outputs it to | 196 | * This encodes the UtfString in the given encoding and outputs it to |
@@ -204,10 +213,10 @@ namespace Bu | |||
204 | 213 | ||
205 | /** | 214 | /** |
206 | * This encodes the UtfString in the given encoding and returns it as | 215 | * This encodes the UtfString in the given encoding and returns it as |
207 | * a binary Bu::String. Like write, this also includes the proper BOM | 216 | * a binary Bu::Blob. Like write, this also includes the proper BOM |
208 | * at the begining. | 217 | * at the begining. |
209 | */ | 218 | */ |
210 | Bu::String get( Encoding eEnc=Utf8 ) const; | 219 | Bu::Blob get( Encoding eEnc=Utf8 ) const; |
211 | 220 | ||
212 | void debug() const; | 221 | void debug() const; |
213 | 222 | ||
@@ -228,7 +237,7 @@ namespace Bu | |||
228 | UtfChar nextChar( int &iIndex ) const; | 237 | UtfChar nextChar( int &iIndex ) const; |
229 | 238 | ||
230 | bool operator==( const Bu::UtfString &rhs ) const; | 239 | bool operator==( const Bu::UtfString &rhs ) const; |
231 | bool operator==( const Bu::String &rhs ) const; | 240 | bool operator==( const Bu::Blob &rhs ) const; |
232 | bool operator==( const char *rhs ) const; | 241 | bool operator==( const char *rhs ) const; |
233 | UtfString &operator+=( const Bu::UtfString &rhs ); | 242 | UtfString &operator+=( const Bu::UtfString &rhs ); |
234 | UtfString &operator+=( const UtfChar &rhs ); | 243 | UtfString &operator+=( const UtfChar &rhs ); |
@@ -241,13 +250,13 @@ namespace Bu | |||
241 | private: | 250 | private: |
242 | void append16( uint16_t i ) { aData.append( i ); } | 251 | void append16( uint16_t i ) { aData.append( i ); } |
243 | 252 | ||
244 | void setUtf8( const Bu::String &sInput ); | 253 | void setUtf8( const Bu::Blob &sInput ); |
245 | void setUtf16( const Bu::String &sInput ); | 254 | void setUtf16( const Bu::Blob &sInput ); |
246 | void setUtf16be( const Bu::String &sInput ); | 255 | void setUtf16be( const Bu::Blob &sInput ); |
247 | void setUtf16le( const Bu::String &sInput ); | 256 | void setUtf16le( const Bu::Blob &sInput ); |
248 | void setUtf32( const Bu::String &sInput ); | 257 | void setUtf32( const Bu::Blob &sInput ); |
249 | void setUtf32be( const Bu::String &sInput ); | 258 | void setUtf32be( const Bu::Blob &sInput ); |
250 | void setUtf32le( const Bu::String &sInput ); | 259 | void setUtf32le( const Bu::Blob &sInput ); |
251 | 260 | ||
252 | void writeUtf8( Bu::Stream &sOut ) const; | 261 | void writeUtf8( Bu::Stream &sOut ) const; |
253 | void writeUtf16be( Bu::Stream &sOut ) const; | 262 | void writeUtf16be( Bu::Stream &sOut ) const; |