This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
num_put<>::do_put (appendix)
- To: Benjamin Kosnik <bkoz@cygnus.com>
- Subject: num_put<>::do_put (appendix)
- From: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
- Date: Thu, 6 May 1999 14:18:18 +0200 (CEST)
- cc: libstdc++@sourceware.cygnus.com
- Reply-To: kabatek@chemie.uni-halle.de
Obvious we need only two functions for the finding out the
sprintf's format parameters.
The format matrix should be a parameter of the function.
const char* __fmt_double[][4] = {{"%.*f", "%+.*f", "%#.*f", "+#.*f"},
{"%.*e", "%+.*e", "%#.*e", "+#.*e"},
{"%.*g", "%+.*g", "%#.*g", "+#.*g"}};
const char* __fmt_ldouble[][4] = {{"%.*Lf", "%+.*Lf", "%#.*Lf", "+#.*Lf"},
{"%.*Le", "%+.*Le", "%#.*Le", "+#.*Le"},
{"%.*Lg", "%+.*Lg", "%#.*Lg", "+#.*Lg"}};
// double, long double
const char*
get_fmt_double(ios_base::fmtflags __flags,
const char* __fmt[][4])
{
int __line = 0;
ios_base::fmtflags __flf = __flags & ios_base::floatfield;
if (__flf == ios_base::fixed)
;
else if (__flf == ios_base::scientific)
__line = 1;
else
__line = 2;
int __column = 0;
if (__flags & ios_base::showpos)
__column += 1;
if (__flags & ios_base::showpoint)
__column += 2;
return __fmt[__line][__column];
}
const char* __fmt_long[][4] = {{"%ld", "%+ld", "%#ld", "+#ld"},
{"%lo", "%+lo", "%#lo", "+#lo"},
{"%lx", "%+lx", "%#lx", "+#lx"},
{"%lX", "%+lX", "%#lX", "+#lX"}};
const char* __fmt_ulong[][4] = {{"%lu", "%+lu", "%#lu", "+#lu"},
{"%lo", "%+lo", "%#lo", "+#lo"},
{"%lx", "%+lx", "%#lx", "+#lx"},
{"%lX", "%+lX", "%#lX", "+#lX"}};
const char* __fmt_llong[][4] = {{"%lld", "%+lld", "%#lld", "+#lld"},
{"%llo", "%+llo", "%#llo", "+#llo"},
{"%llx", "%+llx", "%#llx", "+#llx"},
{"%llX", "%+llX", "%#llX", "+#llX"}};
const char* __fmt_ullong[][4] = {{"%llu", "%+llu", "%#llu", "+#llu"},
{"%llo", "%+llo", "%#llo", "+#llo"},
{"%llx", "%+llx", "%#llx", "+#llx"},
{"%llX", "%+llX", "%#llX", "+#llX"}};
// long, unsigned long, long long, unsigned long long
const char*
get_fmt_long(ios_base::fmtflags __flags,
const char* __fmt[][4])
{
int __line = 0;
if (__flags & ios_base::oct)
__line += 1;
else if (__flags & ios_base::hex) {
__line += 2;
if (__flags & ios_base::uppercase)
__line += 1;
}
int __column = 0;
if (__flags & ios_base::showpos)
__column += 1;
if (__flags & ios_base::showbase)
__column += 2;
return __fmt[__line][__column];
}
Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129