|
lib45d
45Drives C++ Library Development Documentation
|
This class extends ffd::Bytes to specify percents of an amount of bytes. More...
#include <45d/Quota.hpp>


Public Types | |
| enum | RoundingMethod { NEAREST, DOWN, UP } |
| Rounding method enum. More... | |
Public Types inherited from ffd::Bytes | |
| enum | PrefixType { BINARY, SI } |
| typedef off64_t | bytes_type |
| Type to store number of bytes. | |
Public Member Functions | |
| Quota (const Bytes &max, const std::string &str, RoundingMethod method=NEAREST) | |
| Construct a new Quota object. More... | |
| Quota (const Bytes &max, double fraction=1.0, RoundingMethod method=NEAREST) | |
| Construct a new Quota object. More... | |
| Quota (const Bytes &max, const Bytes &allotted, RoundingMethod method=NEAREST) | |
| Quota (void) | |
| Construct a new empty Quota object. More... | |
| Quota (const Quota &other) | |
| Copy constructor. More... | |
| Quota (Quota &&other) | |
| Move constructor. More... | |
| Quota & | operator= (const Quota &other) |
| Copy assignment. More... | |
| Quota & | operator= (Quota &&other) |
| Assignment move constructor. More... | |
| ~Quota ()=default | |
| Destroy the Quota object. | |
| void | set_rounding_method (RoundingMethod method) |
| bytes_type | get (void) const |
| Get value in bytes equal to total bytes_ * fraction_. More... | |
| bytes_type | get_max (void) const |
| Get the max number of bytes from parent. More... | |
| double | get_fraction (void) const |
| Get just the fraction as a double. More... | |
| void | set_fraction (double fraction) |
| Set the fraction. More... | |
| void | set_fraction (const std::string &str) |
| Set fraction from formatted string /\d+(.\d*)?\s*%?/. More... | |
| double | parse_fraction (const std::string &str) |
| Parse str from a percentage to a decimal fraction. More... | |
Public Member Functions inherited from ffd::Bytes | |
| Bytes (const std::string &str) | |
| Construct a new Bytes object from formatted string. More... | |
| Bytes (bytes_type bytes) | |
| Construct a new Bytes object from integral type. More... | |
| Bytes (void) | |
| Construct a new empty Bytes object. More... | |
| Bytes (const Bytes &other) | |
| Copy construct a new Bytes object. More... | |
| Bytes (Bytes &&other) | |
| Move constructor. More... | |
| Bytes & | operator= (const Bytes &other) |
| Copy assignment. More... | |
| Bytes & | operator= (Bytes &&other) |
| Assignment move constructor. More... | |
| ~Bytes ()=default | |
| Destroy the Bytes object. | |
| std::string | get_str (enum PrefixType prefix_type=BINARY, int precision=2) const |
| Get value as formatted string. More... | |
| void | set (bytes_type val) |
| Set value from integral type. More... | |
| void | set (const std::string &str) |
| Set value from formatted string /\d+(.\d*)?\s*[kmgtpezy]?i?b/i. More... | |
| Bytes & | operator+= (const Bytes &other) |
| Bytes & | operator-= (const Bytes &other) |
Private Member Functions | |
| bytes_type | round (double x) const |
| Round a double according to rounding_method_, called by get() More... | |
Private Attributes | |
| double | fraction_ |
| The percent of bytes_ to report with get() and get_str() | |
| RoundingMethod | rounding_method_ |
| Rounding method to use when reporing bytes. | |
Additional Inherited Members | |
Protected Member Functions inherited from ffd::Bytes | |
| bytes_type | parse_bytes (const std::string &str) const |
| Parse bytes from string. More... | |
Protected Attributes inherited from ffd::Bytes | |
| bytes_type | bytes_ |
| The actual value. | |
This class extends ffd::Bytes to specify percents of an amount of bytes.
| ffd::Quota::Quota | ( | const Bytes & | max, |
| const std::string & | str, | ||
| RoundingMethod | method = NEAREST |
||
| ) |
|
inline |
|
inline |
Construct a new empty Quota object.
|
inline |
Copy constructor.
| other |
|
inlinevirtual |
Get value in bytes equal to total bytes_ * fraction_.
Reimplemented from ffd::Bytes.
|
inline |
Get just the fraction as a double.
|
inline |
Get the max number of bytes from parent.
| double ffd::Quota::parse_fraction | ( | const std::string & | str | ) |
Parse str from a percentage to a decimal fraction.
| str | String to parse |
|
inlineprivate |
Round a double according to rounding_method_, called by get()
| x | The number to round, most likely double(bytes_) * fraction_ |
|
inline |
Set fraction from formatted string /\d+(.\d*)?\s*%?/.
| str |
|
inline |
Set the fraction.
| fraction | new value for fraction_ |
1.8.17