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/utfstring.h | |
| 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 'src/unstable/utfstring.h')
| -rw-r--r-- | src/unstable/utfstring.h | 29 |
1 files changed, 19 insertions, 10 deletions
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; |
