12 #ifndef ECL_FORMATTERS_NUMBER_HPP_ 13 #define ECL_FORMATTERS_NUMBER_HPP_ 44 namespace interfaces {
56 template <
typename Number >
169 template <
typename OutputStream>
void pad(
int n, OutputStream &ostream)
const;
170 template <
typename OutputStream>
void prePad(
int n, OutputStream &ostream)
const;
171 template <
typename OutputStream>
void postPad(
int n, OutputStream &ostream)
const;
176 template <
typename OutputStream>
void formatBin(OutputStream &ostream)
const;
177 template <
typename OutputStream>
void formatHex(OutputStream &ostream)
const;
178 template <
typename OutputStream>
void formatDec(OutputStream &ostream)
const;
185 template <
typename Number>
192 template <
typename Number>
202 template <
typename Number>
212 template <
typename Number>
224 template <
typename Number>
225 template <
typename OutputStream>
228 int size = 8*
sizeof(Number);
231 for (
int i = size - 1; i>=0; i--)
233 ostream <<
"01"[((
value_ >> i) & 1)];
238 template <
typename Number>
239 template <
typename OutputStream>
242 static const char hex_string[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' };
244 int size = 2*
sizeof(Number);
247 for (
int i = size - 1; i>=0; i--)
250 ostream << hex_string[((value_ >> i*4) & 0xF)];
255 template <
typename Number>
256 template <
typename OutputStream>
260 char *s = convert(
value_);
261 int size = strlen(s);
267 template <
typename Number>
268 template <
typename OutputStream>
271 if ( n <= 0 ) {
return; }
282 template <
typename Number>
283 template <
typename OutputStream>
286 if ( n <= 0 ) {
return; }
297 template <
typename Number>
298 template <
typename OutputStream>
301 for (
int i = n; i > 0; --i )
312 template <
typename Number>
327 template <
typename Number>
342 template <
typename Number>
360 template <
typename OutputStream,
typename N>
363 bool ready = formatter.ready_to_format;
366 "either there is no data available, or you have tried to use the " 367 "formatter more than once in a single streaming operation. " 368 "C++ produces unspecified results when functors are used multiply " 369 "in the same stream sequence, so this is not permitted here.") );
373 switch(*(formatter.base_) )
376 formatter.formatBin(ostream);
380 formatter.formatHex(ostream);
384 formatter.formatDec(ostream);
388 if ( formatter.width_ != &(formatter.prm_width) ) {
389 formatter.width_ = &(formatter.prm_width);
390 formatter.alignment_ = &(formatter.prm_alignment);
391 formatter.base_ = &(formatter.prm_base);
393 formatter.ready_to_format =
false;
Embedded control libraries.
IntegralBase
Base format tags for the integral formatters.
Common formatting definitions.
#define ecl_assert_throw(expression, exception)
Hex representation for integral types.
#define ecl_assert_throw_decl(exception)
Alignment
Alignment tags for text formatting.
Decimal (i.e. normal) representation for integral types.
Binary representation for integral types.