#include "asserts.h"
#include "types.h"
#include "estring.h"
#include "rmath.h"
Go to the source code of this file.
Functions | |
template<class T > | |
std::string | size_to_string (T a_t, const std::string &a_base_size_unit="b", uint16 a_width=8, uint16 a_precision=1, uint16 a_kilo=1024) |
Given an integral number, return a string with the number formatted as a human-readable machine-type size. | |
template<class T > | |
std::string | num_to_string (T a_t, uint16 a_width=0) |
Given an integral number, return a string with the number formatted in a generic, human-readable format. | |
template<class T > | |
std::string | throughput_to_string (T a_t, const std::string &a_base_size_unit="b", const std::string &a_base_time_unit="s", uint16 a_width=10, uint16 a_precision=1, uint16 a_kilo=1024) |
Given an integral number, return a string with the number formated as a number of machine-type size per second. | |
template<typename T > | |
std::string | percent_string (const T &a_complete, const T &a_total) |
Given a count complete and a count total, calculate a percentage. |
std::string num_to_string | ( | T | a_t, | |
uint16 | a_width = 0 | |||
) | [inline] |
Given an integral number, return a string with the number formatted in a generic, human-readable format.
(Ex: 10240 becomes "10,240")
Definition at line 96 of file strfmt.h.
References estring::align(), estring::fmt_str(), estring::right, TRY_nomem, and estring::width().
Referenced by test2().
std::string percent_string | ( | const T & | a_complete, | |
const T & | a_total | |||
) | [inline] |
Given a count complete and a count total, calculate a percentage.
Definition at line 157 of file strfmt.h.
References estring::align(), estring::fillchar(), estring::fmt_str(), estring::precision(), estring::right, TRY, TRY_nomem, safe_num< T >::value(), and estring::width().
Referenced by vault_manager::delete_oldest_archive(), jobs_report::format_synopsis(), vault_manager::overflow(), test(), test4(), and vault_report::write_report().
std::string size_to_string | ( | T | a_t, | |
const std::string & | a_base_size_unit = "b" , |
|||
uint16 | a_width = 8 , |
|||
uint16 | a_precision = 1 , |
|||
uint16 | a_kilo = 1024 | |||
) | [inline] |
Given an integral number, return a string with the number formatted as a human-readable machine-type size.
(Ex: 10240 becomes "10Kb")
Definition at line 12 of file strfmt.h.
References estring::right, TRY, TRY_nomem, and safe_num< T >::value().
Referenced by test1(), and throughput_to_string().
std::string throughput_to_string | ( | T | a_t, | |
const std::string & | a_base_size_unit = "b" , |
|||
const std::string & | a_base_time_unit = "s" , |
|||
uint16 | a_width = 10 , |
|||
uint16 | a_precision = 1 , |
|||
uint16 | a_kilo = 1024 | |||
) | [inline] |
Given an integral number, return a string with the number formated as a number of machine-type size per second.
(Ex: 10240 becomes "10Kb/s")
Definition at line 135 of file strfmt.h.
References size_to_string(), and TRY_nomem.
Referenced by timer::bps(), and test3().