1 #ifndef INCLUDED_ObjexxFCL_format_hh
2 #define INCLUDED_ObjexxFCL_format_hh
41 char const SPACE(
' ' );
53 template<
typename T >
72 Bite(
int const w,
int const d,
T & t ) :
97 while ( ( i < bite.
w_ ) && ( stream ) && ( stream.peek() !=
'\n' ) ) {
99 if ( stream ) ss << c;
103 stream.setstate( stream.rdstate() | ( ss.rdstate() & ~std::ios_base::eofbit ) );
133 template<
typename T >
146 }
else if ( s.find_first_not_of(
' ' ) == std::string::npos ) {
167 if ( ss.fail() ) t_ =
false;
224 if ( ss.fail() ) t_ = 0;
239 if ( ss.fail() ) t_ = 0;
254 if ( ss.fail() ) t_ = 0;
269 if ( ss.fail() ) t_ = 0;
284 if ( ss.fail() ) t_ = 0;
299 if ( ss.fail() ) t_ = 0;
315 if ( s.find_first_of(
"EeDd" ) == string::npos ) {
316 string::size_type
const i( s.find_last_of(
"+-" ) );
317 if ( ( i != string::npos ) && ( i > 0 ) ) {
318 s.insert( i, 1,
'E' );
325 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == string::npos ) ) {
326 t_ *=
std::pow( 10.0, static_cast< double >( -d_ ) );
343 if ( s.find_first_of(
"EeDd" ) == string::npos ) {
344 string::size_type
const i( s.find_last_of(
"+-" ) );
345 if ( ( i != string::npos ) && ( i > 0 ) ) {
346 s.insert( i, 1,
'E' );
353 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == string::npos ) ) {
354 t_ *=
std::pow( 10.0, static_cast< double >( -d_ ) );
371 if ( s.find_first_of(
"EeDd" ) == string::npos ) {
372 string::size_type
const i( s.find_last_of(
"+-" ) );
373 if ( ( i != string::npos ) && ( i > 0 ) ) {
374 s.insert( i, 1,
'E' );
381 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == string::npos ) ) {
382 t_ *=
std::pow( 10.0l, static_cast< long double >( -d_ ) );
401 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == std::string::npos ) ) {
402 t_ *=
std::pow( 10.0, static_cast< double >( -d_ ) );
421 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == std::string::npos ) ) {
422 t_ *=
std::pow( 10.0, static_cast< double >( -d_ ) );
441 }
else if ( ( d_ != 0 ) && ( ss.str().find(
'.' ) == std::string::npos ) ) {
442 t_ *=
std::pow( 10.0l, static_cast< long double >( -d_ ) );
468 template<
typename T >
478 template<
typename T >
552 while ( ( i < skip.
w_ ) && ( stream ) && ( stream.peek() !=
'\n' ) ) {
604 template<
typename T >
609 std::ostringstream fmt_stream;
610 fmt_stream << std::left << std::noshowpoint <<
std::uppercase <<
' ' << t;
611 return fmt_stream.str();
618 SS(
bool const & t );
624 SS(
float const & t );
630 SS(
double const & t );
636 SS(
long double const & t );
642 SS( std::complex< float >
const & t );
648 SS( std::complex< double >
const & t );
654 SS( std::complex< long double >
const & t );
658 template<
typename T >
663 std::ostringstream fmt_stream;
664 fmt_stream << std::left << std::setw( w ) << t;
665 return fmt_stream.str();
670 template<
typename T >
675 std::ostringstream fmt_stream;
676 fmt_stream << std::right << std::setw( w ) << t;
677 return fmt_stream.str();
686 A(
int const w,
char const c );
706 A(
int const w, std::string
const &
s );
711 A( std::string
const &
s );
743 L(
int const w,
bool const & t );
755 template<
typename T >
758 I(
int const w,
T const & t )
760 std::ostringstream fmt_stream;
761 fmt_stream << std::right << std::setw( w ) << t;
762 return fmt_stream.str();
767 template<
typename T >
770 I(
int const w,
int const m,
T const & t )
772 std::ostringstream fmt_stream;
773 fmt_stream << std::right << std::setfill(
'0' ) << std::setw(
std::min( m, w ) ) << t;
774 std::string
const str( fmt_stream.str() );
775 return std::string(
std::max( w - static_cast< int >( str.length() ), 0 ),
' ' ) + str;
784 E(
int const w,
int const d,
float const & t );
789 E(
int const w,
int const d,
double const & t );
794 E(
int const w,
int const d,
long double const & t );
799 E(
int const w,
int const d, std::complex< float >
const & t );
804 E(
int const w,
int const d, std::complex< double >
const & t );
809 E(
int const w,
int const d, std::complex< long double >
const & t );
814 F(
int const w,
int const d,
float const & t );
819 F(
int const w,
int const d,
double const & t );
824 F(
int const w,
int const d,
long double const & t );
829 F(
int const w,
int const d, std::complex< float >
const & t );
834 F(
int const w,
int const d, std::complex< double >
const & t );
839 F(
int const w,
int const d, std::complex< long double >
const & t );
844 G(
int const w,
int const d,
float const & t );
849 G(
int const w,
int const d,
double const & t );
854 G(
int const w,
int const d,
long double const & t );
859 G(
int const w,
int const d, std::complex< float >
const & t );
864 G(
int const w,
int const d, std::complex< double >
const & t );
869 G(
int const w,
int const d, std::complex< long double >
const & t );
876 template<
typename T >
881 std::ostringstream fmt_stream;
882 fmt_stream << std::left << std::noshowpoint <<
std::uppercase << t;
883 return fmt_stream.str();
890 SW(
bool const & t );
902 SW(
short int const & t );
908 SW(
unsigned short int const & t );
920 SW(
unsigned int const & t );
926 SW(
long int const & t );
932 SW(
unsigned long int const & t );
938 SW(
float const & t );
944 SW(
double const & t );
950 SW(
long double const & t );
956 SW( std::complex< float >
const & t );
962 SW( std::complex< double >
const & t );
968 SW( std::complex< long double >
const & t );
976 general( std::ios_base & base );
987 if ( ( i > 1 ) && ( ( i - 1 ) % n == 0 ) ) {
999 #endif // INCLUDED_ObjexxFCL_format_HH
cmplx w(cmplx z, double relerr)
DimensionExpressionPow pow(Dimension const &dim1, Dimension const &dim2)
pow( Dimension, Dimension )
std::string stripped(std::string const &s, std::string const &chars)
Specified Characters Stripped from a string's Tails Copy of a string.
Fstring: Fixed-Length Fortran-Compatible String.
char & uppercase(char &c)
Uppercase a Character.