Logo Search packages:      
Sourcecode: gaffitter version File versions  Download package

std::string Params::PrettySize ( Size_t  size  )  const

Print filesizes using either Bytes, KiB, MiB or GiB units ("human" readable form); KB, MB and GB if '--si' option is set. Also, if using direct input and no unit just print the size without suffixes.

If --show-bytes is set then it print output sizes in bytes too (except for direct input without a metric).

Definition at line 364 of file Params.cc.

References m_no_metric, m_show_bytes, and m_unit_symbol.

Referenced by BruteForce::Evolve(), Optimizer::Output(), and Optimizer::Write().

{
   std::ostringstream o;

   if (m_no_metric) // = (m_direct_input && m_no_metric)
   {
      // just print the size without units
      o.precision(16); o << size; return o.str();
   }

   // format adjust
   o << std::fixed; 
   
   // module
   Size_t positive_bytes = (size < 0.0) ? -size : size;

   o.precision(2);

   if (positive_bytes >= GB())
      o << size/GB() << 'G'<<m_unit_symbol<<'B';
   else if (positive_bytes >= MB())
      o << size/MB() << 'M'<<m_unit_symbol<<'B';
   else if (positive_bytes >= KB())
      o << size/KB() << 'K'<<m_unit_symbol<<'B';
   else { o.precision(0); o << size << "Bytes"; }
   
   // print bytes together?
   if (m_show_bytes) { o.precision(0); o << " (" << size << ")"; }

   return o.str();
}


Generated by  Doxygen 1.6.0   Back to index