libzypp  13.10.6
Unit.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include "zypp/base/String.h"
13 
14 #include "zypp/base/Unit.h"
15 
17 namespace zypp
18 {
19  namespace base
21  {
22 
23  std::string Unit::form( double val_r,
24  const std::string & symbol_r,
25  unsigned field_width_r,
26  unsigned unit_width_r,
27  unsigned prec_r )
28  {
29  std::string ret = str::form( "%*.*f", field_width_r, prec_r, val_r );
30  if ( unit_width_r )
31  {
32  ret += str::form( " %*s", unit_width_r, symbol_r.c_str() );
33  }
34  return ret;
35  }
36 
38  } // namespace base
41 } // namespace zypp
std::string form(ValueType val_r, unsigned field_width_r=0, unsigned unit_width_r=1) const
Build string representation of val_r.
Definition: Unit.h:70
std::string form(const char *format,...)
Printf style construction of std::string.
Definition: String.cc:34