This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

num_put<>::do_put (appendix)


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]