12 #ifndef ECL_FORMATTERS_FLOATS_HPP_ 13 #define ECL_FORMATTERS_FLOATS_HPP_ 22 #include <ecl/exceptions/standard_exception.hpp> 25 #define snprintf _snprintf 48 namespace interfaces {
60 template <
typename Number>
106 FormatFloat<Number>&
width(
const int w);
151 FormatFloat<Number>&
operator()(
unsigned int p,
const int w);
175 FormatFloat<Number>&
operator() (
const Number n);
186 FormatFloat<Number>&
operator() (
const Number n,
const unsigned int p,
const int w);
208 template <
typename OutputStream,
typename N>
228 template <
typename OutputStream>
void pad(
int n, OutputStream &ostream)
const;
229 template <
typename OutputStream>
void prePad(
int n, OutputStream &ostream)
const;
230 template <
typename OutputStream>
void postPad(
int n, OutputStream &ostream)
const;
235 template <
typename OutputStream>
void formatFixed(OutputStream &ostream)
const;
236 template <
typename OutputStream>
void formatSci(OutputStream &ostream)
const;
247 template <
typename Number>
257 template <
typename Number>
273 template <
typename Number>
288 template <
typename Number>
296 template <
typename Number>
309 template <
typename Number>
319 template <
typename Number>
339 template <
typename Number>
363 template <
typename Number>
364 template <
typename OutputStream>
367 static char format_specifier[6] =
"%.xff";
370 format_specifier[3] =
'f';
371 format_specifier[4] =
'\0';
373 format_specifier[2] =
'1';
375 format_specifier[4] =
'f';
377 format_specifier[2] =
'2';
378 format_specifier[3] =
'0';
379 format_specifier[4] =
'f';
381 static const int buffer_size = 30;
382 static char buffer[buffer_size];
384 snprintf(buffer, buffer_size, format_specifier,
value_);
389 int length = strlen(buffer);
395 template <
typename Number>
396 template <
typename OutputStream>
399 ostream <<
"Scientific format is not yet supported." <<
"\n";
403 template <
typename Number>
404 template <
typename OutputStream>
407 if ( n <= 0 ) {
return; }
418 template <
typename Number>
419 template <
typename OutputStream>
422 if ( n <= 0 ) {
return; }
433 template <
typename Number>
434 template <
typename OutputStream>
437 for (
int i = n; i > 0; --i )
446 template <
typename OutputStream,
typename N>
449 bool ready = formatter.ready_to_format;
452 "either there is no data available, or you have tried to use the " 453 "formatter more than once in a single streaming operation. " 454 "C++ produces unspecified results when functors are used multiply " 455 "in the same stream sequence, so this is not permitted here.") );
459 switch(*(formatter.base_) )
462 formatter.formatFixed(ostream);
466 formatter.formatSci(ostream);
472 if ( formatter.width_ != &(formatter.prm_width) ) {
473 formatter.width_ = &(formatter.prm_width);
474 formatter.precision_ = &(formatter.prm_precision);
475 formatter.alignment_ = &(formatter.prm_alignment);
476 formatter.base_ = &(formatter.prm_base);
478 formatter.ready_to_format =
false;
#define LOC
Stringify the line of code you are at.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
Standard exception type, provides code location and error string.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
TFSIMD_FORCE_INLINE const tfScalar & w() const
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)