libzypp: zypp-core/base/Unit.cc Source File

libzypp 17.36.6

Unit.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <zypp-core/base/String.h>
13
14#include <zypp-core/base/Unit.h>
15
17namespace zypp
18{
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
38 } // namespace base
41} // namespace zypp
zypp::base::Unit::form
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:73
zypp::base
Definition Random.cc:7
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
String.h
Unit.h