diff options
Diffstat (limited to 'src/stable/formatter.cpp')
-rw-r--r-- | src/stable/formatter.cpp | 516 |
1 files changed, 258 insertions, 258 deletions
diff --git a/src/stable/formatter.cpp b/src/stable/formatter.cpp index a04f7a6..9a42c99 100644 --- a/src/stable/formatter.cpp +++ b/src/stable/formatter.cpp | |||
@@ -12,54 +12,54 @@ | |||
12 | 12 | ||
13 | template<> float Bu::tlog( float x ) | 13 | template<> float Bu::tlog( float x ) |
14 | { | 14 | { |
15 | return logf( x ); | 15 | return logf( x ); |
16 | } | 16 | } |
17 | 17 | ||
18 | template<> double Bu::tlog( double x ) | 18 | template<> double Bu::tlog( double x ) |
19 | { | 19 | { |
20 | return log( x ); | 20 | return log( x ); |
21 | } | 21 | } |
22 | 22 | ||
23 | template<> long double Bu::tlog( long double x ) | 23 | template<> long double Bu::tlog( long double x ) |
24 | { | 24 | { |
25 | return logl( x ); | 25 | return logl( x ); |
26 | } | 26 | } |
27 | 27 | ||
28 | template<> float Bu::tfloor( float x ) | 28 | template<> float Bu::tfloor( float x ) |
29 | { | 29 | { |
30 | return floorf( x ); | 30 | return floorf( x ); |
31 | } | 31 | } |
32 | 32 | ||
33 | template<> double Bu::tfloor( double x ) | 33 | template<> double Bu::tfloor( double x ) |
34 | { | 34 | { |
35 | return floor( x ); | 35 | return floor( x ); |
36 | } | 36 | } |
37 | 37 | ||
38 | template<> long double Bu::tfloor( long double x ) | 38 | template<> long double Bu::tfloor( long double x ) |
39 | { | 39 | { |
40 | return floorl( x ); | 40 | return floorl( x ); |
41 | } | 41 | } |
42 | 42 | ||
43 | template<> float Bu::tpow( float x, float y ) | 43 | template<> float Bu::tpow( float x, float y ) |
44 | { | 44 | { |
45 | return powf( x, y ); | 45 | return powf( x, y ); |
46 | } | 46 | } |
47 | 47 | ||
48 | template<> double Bu::tpow( double x, double y ) | 48 | template<> double Bu::tpow( double x, double y ) |
49 | { | 49 | { |
50 | return pow( x, y ); | 50 | return pow( x, y ); |
51 | } | 51 | } |
52 | 52 | ||
53 | template<> long double Bu::tpow( long double x, long double y ) | 53 | template<> long double Bu::tpow( long double x, long double y ) |
54 | { | 54 | { |
55 | return powl( x, y ); | 55 | return powl( x, y ); |
56 | } | 56 | } |
57 | 57 | ||
58 | Bu::Formatter::Formatter( Stream &rStream ) : | 58 | Bu::Formatter::Formatter( Stream &rStream ) : |
59 | rStream( rStream ), | 59 | rStream( rStream ), |
60 | bTempFmt( false ), | 60 | bTempFmt( false ), |
61 | uIndent( 0 ), | 61 | uIndent( 0 ), |
62 | cIndent( '\t' ) | 62 | cIndent( '\t' ) |
63 | { | 63 | { |
64 | } | 64 | } |
65 | 65 | ||
@@ -69,491 +69,491 @@ Bu::Formatter::~Formatter() | |||
69 | 69 | ||
70 | void Bu::Formatter::write( const Bu::String &sStr ) | 70 | void Bu::Formatter::write( const Bu::String &sStr ) |
71 | { | 71 | { |
72 | rStream.write( sStr ); | 72 | rStream.write( sStr ); |
73 | } | 73 | } |
74 | 74 | ||
75 | void Bu::Formatter::write( const void *sStr, int iLen ) | 75 | void Bu::Formatter::write( const void *sStr, int iLen ) |
76 | { | 76 | { |
77 | rStream.write( sStr, iLen ); | 77 | rStream.write( sStr, iLen ); |
78 | } | 78 | } |
79 | 79 | ||
80 | void Bu::Formatter::writeAligned( const Bu::String &sStr ) | 80 | void Bu::Formatter::writeAligned( const Bu::String &sStr ) |
81 | { | 81 | { |
82 | int iLen = sStr.getSize(); | 82 | int iLen = sStr.getSize(); |
83 | if( iLen > fLast.uMinWidth ) | 83 | if( iLen > fLast.uMinWidth ) |
84 | { | 84 | { |
85 | write( sStr ); | 85 | write( sStr ); |
86 | } | 86 | } |
87 | else | 87 | else |
88 | { | 88 | { |
89 | int iRem = fLast.uMinWidth - iLen; | 89 | int iRem = fLast.uMinWidth - iLen; |
90 | switch( fLast.uAlign ) | 90 | switch( fLast.uAlign ) |
91 | { | 91 | { |
92 | case Fmt::Right: | 92 | case Fmt::Right: |
93 | for( int k = 0; k < iRem; k++ ) | 93 | for( int k = 0; k < iRem; k++ ) |
94 | write( &fLast.cFillChar, 1 ); | 94 | write( &fLast.cFillChar, 1 ); |
95 | write( sStr ); | 95 | write( sStr ); |
96 | break; | 96 | break; |
97 | 97 | ||
98 | case Fmt::Center: | 98 | case Fmt::Center: |
99 | { | 99 | { |
100 | int iHlf = iRem/2; | 100 | int iHlf = iRem/2; |
101 | for( int k = 0; k < iHlf; k++ ) | 101 | for( int k = 0; k < iHlf; k++ ) |
102 | write( &fLast.cFillChar, 1 ); | 102 | write( &fLast.cFillChar, 1 ); |
103 | write( sStr ); | 103 | write( sStr ); |
104 | iHlf = iRem-iHlf;; | 104 | iHlf = iRem-iHlf;; |
105 | for( int k = 0; k < iHlf; k++ ) | 105 | for( int k = 0; k < iHlf; k++ ) |
106 | write( &fLast.cFillChar, 1 ); | 106 | write( &fLast.cFillChar, 1 ); |
107 | } | 107 | } |
108 | break; | 108 | break; |
109 | 109 | ||
110 | case Fmt::Left: | 110 | case Fmt::Left: |
111 | write( sStr ); | 111 | write( sStr ); |
112 | for( int k = 0; k < iRem; k++ ) | 112 | for( int k = 0; k < iRem; k++ ) |
113 | write( &fLast.cFillChar, 1 ); | 113 | write( &fLast.cFillChar, 1 ); |
114 | break; | 114 | break; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | usedFormat(); | 118 | usedFormat(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void Bu::Formatter::writeAligned( const char *sStr, int iLen ) | 121 | void Bu::Formatter::writeAligned( const char *sStr, int iLen ) |
122 | { | 122 | { |
123 | if( iLen > fLast.uMinWidth ) | 123 | if( iLen > fLast.uMinWidth ) |
124 | { | 124 | { |
125 | write( sStr, iLen ); | 125 | write( sStr, iLen ); |
126 | } | 126 | } |
127 | else | 127 | else |
128 | { | 128 | { |
129 | int iRem = fLast.uMinWidth - iLen; | 129 | int iRem = fLast.uMinWidth - iLen; |
130 | switch( fLast.uAlign ) | 130 | switch( fLast.uAlign ) |
131 | { | 131 | { |
132 | case Fmt::Right: | 132 | case Fmt::Right: |
133 | for( int k = 0; k < iRem; k++ ) | 133 | for( int k = 0; k < iRem; k++ ) |
134 | write( &fLast.cFillChar, 1 ); | 134 | write( &fLast.cFillChar, 1 ); |
135 | write( sStr, iLen ); | 135 | write( sStr, iLen ); |
136 | break; | 136 | break; |
137 | 137 | ||
138 | case Fmt::Center: | 138 | case Fmt::Center: |
139 | { | 139 | { |
140 | int iHlf = iRem/2; | 140 | int iHlf = iRem/2; |
141 | for( int k = 0; k < iHlf; k++ ) | 141 | for( int k = 0; k < iHlf; k++ ) |
142 | write( &fLast.cFillChar, 1 ); | 142 | write( &fLast.cFillChar, 1 ); |
143 | write( sStr, iLen ); | 143 | write( sStr, iLen ); |
144 | iHlf = iRem-iHlf;; | 144 | iHlf = iRem-iHlf;; |
145 | for( int k = 0; k < iHlf; k++ ) | 145 | for( int k = 0; k < iHlf; k++ ) |
146 | write( &fLast.cFillChar, 1 ); | 146 | write( &fLast.cFillChar, 1 ); |
147 | } | 147 | } |
148 | break; | 148 | break; |
149 | 149 | ||
150 | case Fmt::Left: | 150 | case Fmt::Left: |
151 | write( sStr, iLen ); | 151 | write( sStr, iLen ); |
152 | for( int k = 0; k < iRem; k++ ) | 152 | for( int k = 0; k < iRem; k++ ) |
153 | write( &fLast.cFillChar, 1 ); | 153 | write( &fLast.cFillChar, 1 ); |
154 | break; | 154 | break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | usedFormat(); | 158 | usedFormat(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void Bu::Formatter::read( void *sStr, int iLen ) | 161 | void Bu::Formatter::read( void *sStr, int iLen ) |
162 | { | 162 | { |
163 | rStream.read( sStr, iLen ); | 163 | rStream.read( sStr, iLen ); |
164 | } | 164 | } |
165 | 165 | ||
166 | Bu::String Bu::Formatter::readToken() | 166 | Bu::String Bu::Formatter::readToken() |
167 | { | 167 | { |
168 | Bu::String sRet; | 168 | Bu::String sRet; |
169 | if( fLast.bTokenize ) | 169 | if( fLast.bTokenize ) |
170 | { | 170 | { |
171 | for(;;) | 171 | for(;;) |
172 | { | 172 | { |
173 | char buf; | 173 | char buf; |
174 | int iRead = rStream.read( &buf, 1 ); | 174 | int iRead = rStream.read( &buf, 1 ); |
175 | if( iRead == 0 ) | 175 | if( iRead == 0 ) |
176 | return sRet; | 176 | return sRet; |
177 | if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) | 177 | if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) |
178 | continue; | 178 | continue; |
179 | else | 179 | else |
180 | { | 180 | { |
181 | sRet += buf; | 181 | sRet += buf; |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | for(;;) | 185 | for(;;) |
186 | { | 186 | { |
187 | char buf; | 187 | char buf; |
188 | int iRead = rStream.read( &buf, 1 ); | 188 | int iRead = rStream.read( &buf, 1 ); |
189 | if( iRead == 0 ) | 189 | if( iRead == 0 ) |
190 | return sRet; | 190 | return sRet; |
191 | if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) | 191 | if( buf == ' ' || buf == '\t' || buf == '\n' || buf == '\r' ) |
192 | return sRet; | 192 | return sRet; |
193 | else | 193 | else |
194 | sRet += buf; | 194 | sRet += buf; |
195 | } | 195 | } |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | for(;;) | 199 | for(;;) |
200 | { | 200 | { |
201 | char buf; | 201 | char buf; |
202 | int iRead = rStream.read( &buf, 1 ); | 202 | int iRead = rStream.read( &buf, 1 ); |
203 | if( iRead == 0 ) | 203 | if( iRead == 0 ) |
204 | return sRet; | 204 | return sRet; |
205 | else | 205 | else |
206 | sRet += buf; | 206 | sRet += buf; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | void Bu::Formatter::incIndent() | 211 | void Bu::Formatter::incIndent() |
212 | { | 212 | { |
213 | if( uIndent < 0xFFU ) | 213 | if( uIndent < 0xFFU ) |
214 | uIndent++; | 214 | uIndent++; |
215 | } | 215 | } |
216 | 216 | ||
217 | void Bu::Formatter::decIndent() | 217 | void Bu::Formatter::decIndent() |
218 | { | 218 | { |
219 | if( uIndent > 0 ) | 219 | if( uIndent > 0 ) |
220 | uIndent--; | 220 | uIndent--; |
221 | } | 221 | } |
222 | 222 | ||
223 | void Bu::Formatter::setIndent( uint8_t uLevel ) | 223 | void Bu::Formatter::setIndent( uint8_t uLevel ) |
224 | { | 224 | { |
225 | uIndent = uLevel; | 225 | uIndent = uLevel; |
226 | } | 226 | } |
227 | 227 | ||
228 | void Bu::Formatter::clearIndent() | 228 | void Bu::Formatter::clearIndent() |
229 | { | 229 | { |
230 | uIndent = 0; | 230 | uIndent = 0; |
231 | } | 231 | } |
232 | 232 | ||
233 | void Bu::Formatter::setIndentChar( char cIndent ) | 233 | void Bu::Formatter::setIndentChar( char cIndent ) |
234 | { | 234 | { |
235 | this->cIndent = cIndent; | 235 | this->cIndent = cIndent; |
236 | } | 236 | } |
237 | 237 | ||
238 | void Bu::Formatter::doFlush() | 238 | void Bu::Formatter::doFlush() |
239 | { | 239 | { |
240 | rStream.flush(); | 240 | rStream.flush(); |
241 | } | 241 | } |
242 | 242 | ||
243 | Bu::Fmt &Bu::Fmt::width( unsigned int uWidth ) | 243 | Bu::Fmt &Bu::Fmt::width( unsigned int uWidth ) |
244 | { | 244 | { |
245 | this->uMinWidth = uWidth; | 245 | this->uMinWidth = uWidth; |
246 | return *this; | 246 | return *this; |
247 | } | 247 | } |
248 | 248 | ||
249 | Bu::Fmt &Bu::Fmt::fill( char cFill ) | 249 | Bu::Fmt &Bu::Fmt::fill( char cFill ) |
250 | { | 250 | { |
251 | this->cFillChar = (unsigned char)cFill; | 251 | this->cFillChar = (unsigned char)cFill; |
252 | return *this; | 252 | return *this; |
253 | } | 253 | } |
254 | 254 | ||
255 | Bu::Fmt &Bu::Fmt::radix( unsigned int uRadix ) | 255 | Bu::Fmt &Bu::Fmt::radix( unsigned int uRadix ) |
256 | { | 256 | { |
257 | this->uRadix = uRadix; | 257 | this->uRadix = uRadix; |
258 | return *this; | 258 | return *this; |
259 | } | 259 | } |
260 | 260 | ||
261 | Bu::Fmt &Bu::Fmt::align( Alignment eAlign ) | 261 | Bu::Fmt &Bu::Fmt::align( Alignment eAlign ) |
262 | { | 262 | { |
263 | this->uAlign = eAlign; | 263 | this->uAlign = eAlign; |
264 | return *this; | 264 | return *this; |
265 | } | 265 | } |
266 | 266 | ||
267 | Bu::Fmt &Bu::Fmt::left() | 267 | Bu::Fmt &Bu::Fmt::left() |
268 | { | 268 | { |
269 | this->uAlign = Fmt::Left; | 269 | this->uAlign = Fmt::Left; |
270 | return *this; | 270 | return *this; |
271 | } | 271 | } |
272 | 272 | ||
273 | Bu::Fmt &Bu::Fmt::center() | 273 | Bu::Fmt &Bu::Fmt::center() |
274 | { | 274 | { |
275 | this->uAlign = Fmt::Center; | 275 | this->uAlign = Fmt::Center; |
276 | return *this; | 276 | return *this; |
277 | } | 277 | } |
278 | 278 | ||
279 | Bu::Fmt &Bu::Fmt::right() | 279 | Bu::Fmt &Bu::Fmt::right() |
280 | { | 280 | { |
281 | this->uAlign = Fmt::Right; | 281 | this->uAlign = Fmt::Right; |
282 | return *this; | 282 | return *this; |
283 | } | 283 | } |
284 | 284 | ||
285 | Bu::Fmt &Bu::Fmt::plus( bool bPlus ) | 285 | Bu::Fmt &Bu::Fmt::plus( bool bPlus ) |
286 | { | 286 | { |
287 | this->bPlus = bPlus; | 287 | this->bPlus = bPlus; |
288 | return *this; | 288 | return *this; |
289 | } | 289 | } |
290 | 290 | ||
291 | Bu::Fmt &Bu::Fmt::caps( bool bCaps ) | 291 | Bu::Fmt &Bu::Fmt::caps( bool bCaps ) |
292 | { | 292 | { |
293 | this->bCaps = bCaps; | 293 | this->bCaps = bCaps; |
294 | return *this; | 294 | return *this; |
295 | } | 295 | } |
296 | 296 | ||
297 | Bu::Fmt &Bu::Fmt::upper() | 297 | Bu::Fmt &Bu::Fmt::upper() |
298 | { | 298 | { |
299 | this->bCaps = true; | 299 | this->bCaps = true; |
300 | return *this; | 300 | return *this; |
301 | } | 301 | } |
302 | 302 | ||
303 | Bu::Fmt &Bu::Fmt::lower() | 303 | Bu::Fmt &Bu::Fmt::lower() |
304 | { | 304 | { |
305 | this->bCaps = false; | 305 | this->bCaps = false; |
306 | return *this; | 306 | return *this; |
307 | } | 307 | } |
308 | 308 | ||
309 | Bu::Fmt &Bu::Fmt::tokenize( bool bTokenize ) | 309 | Bu::Fmt &Bu::Fmt::tokenize( bool bTokenize ) |
310 | { | 310 | { |
311 | this->bTokenize = bTokenize; | 311 | this->bTokenize = bTokenize; |
312 | return *this; | 312 | return *this; |
313 | } | 313 | } |
314 | 314 | ||
315 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Fmt &fmt ) | 315 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::Fmt &fmt ) |
316 | { | 316 | { |
317 | f.setTempFormat( fmt ); | 317 | f.setTempFormat( fmt ); |
318 | return f; | 318 | return f; |
319 | } | 319 | } |
320 | 320 | ||
321 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, Bu::Formatter::Special s ) | 321 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, Bu::Formatter::Special s ) |
322 | { | 322 | { |
323 | switch( s ) | 323 | switch( s ) |
324 | { | 324 | { |
325 | case Formatter::nl: | 325 | case Formatter::nl: |
326 | { | 326 | { |
327 | #ifdef WIN32 | 327 | #ifdef WIN32 |
328 | f.write("\r\n", 2 ); | 328 | f.write("\r\n", 2 ); |
329 | #else | 329 | #else |
330 | f.write("\n", 1 ); | 330 | f.write("\n", 1 ); |
331 | #endif | 331 | #endif |
332 | char ci = f.getIndentChar(); | 332 | char ci = f.getIndentChar(); |
333 | for( int j = 0; j < f.getIndent(); j++ ) | 333 | for( int j = 0; j < f.getIndent(); j++ ) |
334 | f.write( &ci, 1 ); | 334 | f.write( &ci, 1 ); |
335 | f.doFlush(); | 335 | f.doFlush(); |
336 | } | 336 | } |
337 | break; | 337 | break; |
338 | 338 | ||
339 | case Formatter::flush: | 339 | case Formatter::flush: |
340 | f.doFlush(); | 340 | f.doFlush(); |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | return f; | 343 | return f; |
344 | } | 344 | } |
345 | 345 | ||
346 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const char *sStr ) | 346 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const char *sStr ) |
347 | { | 347 | { |
348 | f.writeAligned( sStr, strlen( sStr ) ); | 348 | f.writeAligned( sStr, strlen( sStr ) ); |
349 | return f; | 349 | return f; |
350 | } | 350 | } |
351 | 351 | ||
352 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, char *sStr ) | 352 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, char *sStr ) |
353 | { | 353 | { |
354 | f.writeAligned( sStr, strlen( sStr ) ); | 354 | f.writeAligned( sStr, strlen( sStr ) ); |
355 | return f; | 355 | return f; |
356 | } | 356 | } |
357 | 357 | ||
358 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::String &sStr ) | 358 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::String &sStr ) |
359 | { | 359 | { |
360 | f.writeAligned( sStr ); | 360 | f.writeAligned( sStr ); |
361 | return f; | 361 | return f; |
362 | } | 362 | } |
363 | 363 | ||
364 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed char c ) | 364 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed char c ) |
365 | { | 365 | { |
366 | f.ifmt<signed char>( c ); | 366 | f.ifmt<signed char>( c ); |
367 | //f.write( (char *)&c, 1 ); | 367 | //f.write( (char *)&c, 1 ); |
368 | return f; | 368 | return f; |
369 | } | 369 | } |
370 | 370 | ||
371 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, char c ) | 371 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, char c ) |
372 | { | 372 | { |
373 | f.write( (char *)&c, 1 ); | 373 | f.write( (char *)&c, 1 ); |
374 | return f; | 374 | return f; |
375 | } | 375 | } |
376 | 376 | ||
377 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned char c ) | 377 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned char c ) |
378 | { | 378 | { |
379 | f.ufmt<unsigned char>( c ); | 379 | f.ufmt<unsigned char>( c ); |
380 | //f.write( (char *)&c, 1 ); | 380 | //f.write( (char *)&c, 1 ); |
381 | return f; | 381 | return f; |
382 | } | 382 | } |
383 | 383 | ||
384 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed short i ) | 384 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed short i ) |
385 | { | 385 | { |
386 | f.ifmt<signed short>( i ); | 386 | f.ifmt<signed short>( i ); |
387 | return f; | 387 | return f; |
388 | } | 388 | } |
389 | 389 | ||
390 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned short i ) | 390 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned short i ) |
391 | { | 391 | { |
392 | f.ufmt<unsigned short>( i ); | 392 | f.ufmt<unsigned short>( i ); |
393 | return f; | 393 | return f; |
394 | } | 394 | } |
395 | 395 | ||
396 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed int i ) | 396 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed int i ) |
397 | { | 397 | { |
398 | f.ifmt<signed int>( i ); | 398 | f.ifmt<signed int>( i ); |
399 | return f; | 399 | return f; |
400 | } | 400 | } |
401 | 401 | ||
402 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned int i ) | 402 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned int i ) |
403 | { | 403 | { |
404 | f.ufmt<unsigned int>( i ); | 404 | f.ufmt<unsigned int>( i ); |
405 | return f; | 405 | return f; |
406 | } | 406 | } |
407 | 407 | ||
408 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed long i ) | 408 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed long i ) |
409 | { | 409 | { |
410 | f.ifmt<signed long>( i ); | 410 | f.ifmt<signed long>( i ); |
411 | return f; | 411 | return f; |
412 | } | 412 | } |
413 | 413 | ||
414 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned long i ) | 414 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned long i ) |
415 | { | 415 | { |
416 | f.ufmt<unsigned long>( i ); | 416 | f.ufmt<unsigned long>( i ); |
417 | return f; | 417 | return f; |
418 | } | 418 | } |
419 | 419 | ||
420 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed long long i ) | 420 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, signed long long i ) |
421 | { | 421 | { |
422 | f.ifmt<signed long long>( i ); | 422 | f.ifmt<signed long long>( i ); |
423 | return f; | 423 | return f; |
424 | } | 424 | } |
425 | 425 | ||
426 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned long long i ) | 426 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, unsigned long long i ) |
427 | { | 427 | { |
428 | f.ufmt<unsigned long long>( i ); | 428 | f.ufmt<unsigned long long>( i ); |
429 | return f; | 429 | return f; |
430 | } | 430 | } |
431 | 431 | ||
432 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, float flt ) | 432 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, float flt ) |
433 | { | 433 | { |
434 | f.ffmt<float>( flt ); | 434 | f.ffmt<float>( flt ); |
435 | return f; | 435 | return f; |
436 | } | 436 | } |
437 | 437 | ||
438 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, double flt ) | 438 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, double flt ) |
439 | { | 439 | { |
440 | f.ffmt<double>( flt ); | 440 | f.ffmt<double>( flt ); |
441 | return f; | 441 | return f; |
442 | } | 442 | } |
443 | 443 | ||
444 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, long double flt ) | 444 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, long double flt ) |
445 | { | 445 | { |
446 | f.ffmt<long double>( flt ); | 446 | f.ffmt<long double>( flt ); |
447 | return f; | 447 | return f; |
448 | } | 448 | } |
449 | 449 | ||
450 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, bool b ) | 450 | Bu::Formatter &Bu::operator<<( Bu::Formatter &f, bool b ) |
451 | { | 451 | { |
452 | f.writeAligned( b?("true"):("false") ); | 452 | f.writeAligned( b?("true"):("false") ); |
453 | return f; | 453 | return f; |
454 | } | 454 | } |
455 | 455 | ||
456 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, Bu::String &sStr ) | 456 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, Bu::String &sStr ) |
457 | { | 457 | { |
458 | sStr = f.readToken(); | 458 | sStr = f.readToken(); |
459 | return f; | 459 | return f; |
460 | } | 460 | } |
461 | 461 | ||
462 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed char &c ) | 462 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed char &c ) |
463 | { | 463 | { |
464 | f.read( &c, 1 ); | 464 | f.read( &c, 1 ); |
465 | return f; | 465 | return f; |
466 | } | 466 | } |
467 | 467 | ||
468 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, char &c ) | 468 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, char &c ) |
469 | { | 469 | { |
470 | f.read( &c, 1 ); | 470 | f.read( &c, 1 ); |
471 | return f; | 471 | return f; |
472 | } | 472 | } |
473 | 473 | ||
474 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned char &c ) | 474 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned char &c ) |
475 | { | 475 | { |
476 | f.read( &c, 1 ); | 476 | f.read( &c, 1 ); |
477 | return f; | 477 | return f; |
478 | } | 478 | } |
479 | 479 | ||
480 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed short &i ) | 480 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed short &i ) |
481 | { | 481 | { |
482 | f.iparse( i, f.readToken() ); | 482 | f.iparse( i, f.readToken() ); |
483 | return f; | 483 | return f; |
484 | } | 484 | } |
485 | 485 | ||
486 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned short &i ) | 486 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned short &i ) |
487 | { | 487 | { |
488 | f.uparse( i, f.readToken() ); | 488 | f.uparse( i, f.readToken() ); |
489 | return f; | 489 | return f; |
490 | } | 490 | } |
491 | 491 | ||
492 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed int &i ) | 492 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed int &i ) |
493 | { | 493 | { |
494 | f.iparse( i, f.readToken() ); | 494 | f.iparse( i, f.readToken() ); |
495 | return f; | 495 | return f; |
496 | } | 496 | } |
497 | 497 | ||
498 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned int &i ) | 498 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned int &i ) |
499 | { | 499 | { |
500 | f.uparse( i, f.readToken() ); | 500 | f.uparse( i, f.readToken() ); |
501 | return f; | 501 | return f; |
502 | } | 502 | } |
503 | 503 | ||
504 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed long &i ) | 504 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed long &i ) |
505 | { | 505 | { |
506 | f.iparse( i, f.readToken() ); | 506 | f.iparse( i, f.readToken() ); |
507 | return f; | 507 | return f; |
508 | } | 508 | } |
509 | 509 | ||
510 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned long &i ) | 510 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned long &i ) |
511 | { | 511 | { |
512 | f.uparse( i, f.readToken() ); | 512 | f.uparse( i, f.readToken() ); |
513 | return f; | 513 | return f; |
514 | } | 514 | } |
515 | 515 | ||
516 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed long long &i ) | 516 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, signed long long &i ) |
517 | { | 517 | { |
518 | f.iparse( i, f.readToken() ); | 518 | f.iparse( i, f.readToken() ); |
519 | return f; | 519 | return f; |
520 | } | 520 | } |
521 | 521 | ||
522 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned long long &i ) | 522 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, unsigned long long &i ) |
523 | { | 523 | { |
524 | f.uparse( i, f.readToken() ); | 524 | f.uparse( i, f.readToken() ); |
525 | return f; | 525 | return f; |
526 | } | 526 | } |
527 | 527 | ||
528 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, float &flt ) | 528 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, float &flt ) |
529 | { | 529 | { |
530 | f.fparse( flt, f.readToken() ); | 530 | f.fparse( flt, f.readToken() ); |
531 | return f; | 531 | return f; |
532 | } | 532 | } |
533 | 533 | ||
534 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, double &flt ) | 534 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, double &flt ) |
535 | { | 535 | { |
536 | f.fparse( flt, f.readToken() ); | 536 | f.fparse( flt, f.readToken() ); |
537 | return f; | 537 | return f; |
538 | } | 538 | } |
539 | 539 | ||
540 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, long double &flt ) | 540 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, long double &flt ) |
541 | { | 541 | { |
542 | f.fparse( flt, f.readToken() ); | 542 | f.fparse( flt, f.readToken() ); |
543 | return f; | 543 | return f; |
544 | } | 544 | } |
545 | 545 | ||
546 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, bool &b ) | 546 | Bu::Formatter &Bu::operator>>( Bu::Formatter &f, bool &b ) |
547 | { | 547 | { |
548 | Bu::String sStr = f.readToken(); | 548 | Bu::String sStr = f.readToken(); |
549 | if( !sStr.isSet() ) | 549 | if( !sStr.isSet() ) |
550 | return f; | 550 | return f; |
551 | char c = *sStr.begin(); | 551 | char c = *sStr.begin(); |
552 | if( c == 'y' || c == 'Y' || c == 't' || c == 'T' ) | 552 | if( c == 'y' || c == 'Y' || c == 't' || c == 'T' ) |
553 | b = true; | 553 | b = true; |
554 | else if( c == 'n' || c == 'N' || c == 'f' || c == 'F' ) | 554 | else if( c == 'n' || c == 'N' || c == 'f' || c == 'F' ) |
555 | b = false; | 555 | b = false; |
556 | 556 | ||
557 | return f; | 557 | return f; |
558 | } | 558 | } |
559 | 559 | ||