aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/utfstring.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2019-05-13 19:47:19 -0700
committerMike Buland <eichlan@xagasoft.com>2019-05-13 19:47:19 -0700
commitd605d6c3c04c1e26121f9b1c5c1d2dbcc5f7bc37 (patch)
tree0cd21d420fc67ae757ec2475610c4624fd714363 /src/unstable/utfstring.h
parent62753c815b5ec34ebfae37a3c89187a01cc17160 (diff)
downloadlibbu++-d605d6c3c04c1e26121f9b1c5c1d2dbcc5f7bc37.tar.gz
libbu++-d605d6c3c04c1e26121f9b1c5c1d2dbcc5f7bc37.tar.bz2
libbu++-d605d6c3c04c1e26121f9b1c5c1d2dbcc5f7bc37.tar.xz
libbu++-d605d6c3c04c1e26121f9b1c5c1d2dbcc5f7bc37.zip
UtfString & Json overhaul.
UtfString supports a load of new stuff, and Json uses UtfString exclusively now.
Diffstat (limited to '')
-rw-r--r--src/unstable/utfstring.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/unstable/utfstring.h b/src/unstable/utfstring.h
index 5085ec0..285b680 100644
--- a/src/unstable/utfstring.h
+++ b/src/unstable/utfstring.h
@@ -191,6 +191,18 @@ namespace Bu
191 void write( Bu::Stream &sOut, Encoding eEnc=Utf8 ) const; 191 void write( Bu::Stream &sOut, Encoding eEnc=Utf8 ) const;
192 192
193 /** 193 /**
194 * Reads as many bytes from the given stream, starting at the current
195 * position, as required to read a single UtfChar (code point).
196 */
197 static int readPoint( Bu::Stream &sIn, UtfChar &c,
198 Encoding sEnc=Utf8 );
199 static int writePoint( Bu::Stream &sOut, const UtfChar &c,
200 Encoding sEnc=Utf8 );
201
202 int32_t toInt32( int iRadix=10 ) const;
203 int64_t toInt64( int iRadix=10 ) const;
204
205 /**
194 * This encodes the UtfString in the given encoding and returns it as 206 * This encodes the UtfString in the given encoding and returns it as
195 * a binary Bu::String. Like write, this also includes the proper BOM 207 * a binary Bu::String. Like write, this also includes the proper BOM
196 * at the begining. 208 * at the begining.
@@ -216,9 +228,16 @@ namespace Bu
216 UtfChar nextChar( int &iIndex ) const; 228 UtfChar nextChar( int &iIndex ) const;
217 229
218 bool operator==( const Bu::UtfString &rhs ) const; 230 bool operator==( const Bu::UtfString &rhs ) const;
231 bool operator==( const Bu::String &rhs ) const;
232 bool operator==( const char *rhs ) const;
219 UtfString &operator+=( const Bu::UtfString &rhs ); 233 UtfString &operator+=( const Bu::UtfString &rhs );
220 UtfString &operator+=( const UtfChar &rhs ); 234 UtfString &operator+=( const UtfChar &rhs );
221 235
236 bool operator<( const Bu::UtfString &rhs ) const;
237 bool operator<=( const Bu::UtfString &rhs ) const;
238 bool operator>( const Bu::UtfString &rhs ) const;
239 bool operator>=( const Bu::UtfString &rhs ) const;
240
222 private: 241 private:
223 void append16( uint16_t i ) { aData.append( i ); } 242 void append16( uint16_t i ) { aData.append( i ); }
224 243
@@ -237,6 +256,7 @@ namespace Bu
237 void writeUtf32le( Bu::Stream &sOut ) const; 256 void writeUtf32le( Bu::Stream &sOut ) const;
238 257
239 private: 258 private:
259 static uint8_t utf8_lmask[8];
240 Bu::Array<uint16_t> aData; 260 Bu::Array<uint16_t> aData;
241 int iRawLen; 261 int iRawLen;
242 int iCharLen; 262 int iCharLen;
@@ -254,6 +274,9 @@ namespace Bu
254 template<> uint32_t __calcHashCode<UtfString>( const UtfString &k ); 274 template<> uint32_t __calcHashCode<UtfString>( const UtfString &k );
255 template<> bool __cmpHashKeys<UtfString>( 275 template<> bool __cmpHashKeys<UtfString>(
256 const UtfString &a, const UtfString &b ); 276 const UtfString &a, const UtfString &b );
277
278 class Formatter;
279 Bu::Formatter operator<<( Bu::Formatter &f, const Bu::UtfString &s );
257}; 280};
258 281
259#endif 282#endif