Imported Upstream version 14.32.2
[platform/upstream/libzypp.git] / zypp / base / Unit.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/base/Unit.cc
10  *
11 */
12 #include "zypp/base/String.h"
13
14 #include "zypp/base/Unit.h"
15
16 ///////////////////////////////////////////////////////////////////
17 namespace zypp
18 { /////////////////////////////////////////////////////////////////
19   ///////////////////////////////////////////////////////////////////
20   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
37     /////////////////////////////////////////////////////////////////
38   } // namespace base
39   ///////////////////////////////////////////////////////////////////
40   /////////////////////////////////////////////////////////////////
41 } // namespace zypp
42 ///////////////////////////////////////////////////////////////////