#include <bytedisp.hpp>
Public Types | |
enum | Units { byte = 0, kilo, mega, giga, tera, peta, exa, zetta, yotta } |
List of the units. More... | |
enum | UnitsFormat { None, Short, Long } |
Units format types. More... | |
Public Member Functions | |
BytesDisplayer (const unsigned long value) | |
Constructor with a long integer type. | |
BytesDisplayer (const long value) | |
Constructor with a long integer type. | |
BytesDisplayer (const double value) | |
Constructor with a double type. | |
BytesDisplayer (const BytesDisplayer &source) | |
Copy constructor. | |
BytesDisplayer () | |
Default constructor. | |
BytesDisplayer & | operator+= (const BytesDisplayer &a) |
Operator +=. | |
BytesDisplayer & | operator= (const unsigned long value) |
Assignment operator. | |
BytesDisplayer & | operator= (const long value) |
Assignment operator. | |
BytesDisplayer & | operator= (const double value) |
Assignment operator. | |
BytesDisplayer & | operator= (const BytesDisplayer &source) |
Assignment operator. | |
double | toDouble (const Units u=byte) const |
Gets the size as a double. | |
wxString | toString (const UnitsFormat uf=Short) const |
Gets the size as a string. | |
wxString | toString (const Units u, const UnitsFormat uf=Short) const |
Gets the size as a string. | |
Static Public Member Functions | |
void | initStatic () |
Initializes the static part of the class. | |
Protected Types | |
typedef double | bytesize_type |
Internal type of size values. | |
Protected Member Functions | |
void | clone (const BytesDisplayer &source) |
Clones the source instance in this instance. | |
void | normalize () |
Normalizes the value. | |
Protected Attributes | |
bytesize_type | size |
Value of the size. | |
Units | unit |
Current unit. | |
Static Protected Attributes | |
wxString | long_units [9] |
Name of the units (long format). | |
wxString | short_units [9] |
Name of the units (short format). |
Important: Call initStatic() (only once is needed) before using this class. It is needed for i18n.
The suffix could be:
Name | Abbr | Factor |
kilo | K | 210 = 1024 |
mega | M | 220 = 1 048 576 |
giga | G | 230 = 1 073 741 824 |
tera | T | 240 = 1 099 511 627 776 |
peta | P | 250 = 1 125 899 906 842 624 |
exa | E | 260 = 1 152 921 504 606 846 976 |
zetta | Z | 270 = 1 180 591 620 717 411 303 424 |
yotta | Y | 280 = 1 208 925 819 614 629 174 706 176 |
This class manages only positives integers and should not be used for precise work with sizes since it uses internally doubles values. Use it only for display sizes in xB.
Definition at line 67 of file bytedisp.hpp.
|
Internal type of size values.
Definition at line 98 of file bytedisp.hpp. Referenced by operator+=(). |
|
List of the units.
Definition at line 71 of file bytedisp.hpp. Referenced by operator+=(), and toDouble(). |
|
Units format types.
Definition at line 85 of file bytedisp.hpp. |
|
Default constructor.
Definition at line 99 of file bytedisp.cpp. |
|
Copy constructor.
Definition at line 128 of file bytedisp.cpp. References clone(). |
|
Constructor with a double type.
Definition at line 202 of file bytedisp.cpp. References normalize(), size, and unit. |
|
Constructor with a long integer type.
Definition at line 216 of file bytedisp.cpp. References normalize(), size, and unit. |
|
Constructor with a long integer type.
Definition at line 230 of file bytedisp.cpp. References normalize(), size, and unit. |
|
Clones the source instance in this instance.
Definition at line 112 of file bytedisp.cpp. References clone(), size, and unit. Referenced by BytesDisplayer(), clone(), and operator=(). |
|
Initializes the static part of the class. Please call this function before the first use of this class. Definition at line 72 of file bytedisp.cpp. References long_units, and short_units. Referenced by CkSumsApp::OnInit(). |
|
Normalizes the value. After calling this function:
Definition at line 249 of file bytedisp.cpp. Referenced by BytesDisplayer(), operator+=(), and operator=(). |
|
Operator +=.
Definition at line 282 of file bytedisp.cpp. References bytesize_type, normalize(), operator+=(), size, unit, and Units. Referenced by operator+=(). |
|
Assignment operator.
Definition at line 187 of file bytedisp.cpp. References normalize(), operator=(), size, and unit. |
|
Assignment operator.
Definition at line 171 of file bytedisp.cpp. References normalize(), operator=(), size, and unit. |
|
Assignment operator.
Definition at line 155 of file bytedisp.cpp. References normalize(), operator=(), size, and unit. |
|
Assignment operator.
Definition at line 141 of file bytedisp.cpp. References clone(), and operator=(). Referenced by operator=(). |
|
Gets the size as a double.
Definition at line 311 of file bytedisp.cpp. References size, toDouble(), unit, and Units. Referenced by ChecksumsListView::ChecksumProgress::ChecksumProgress(), dlgMultiCheck::setReadBytes(), dlgBatchCreation::setReadBytes(), dlgMultiCheck::setTotalBytes(), dlgBatchCreation::setTotalBytes(), toDouble(), toString(), ChecksumsListView::ChecksumProgress::update(), dlgMultiCheck::updateCurrentCheckedFile(), and dlgBatchCreation::updateCurrentProcessedFile(). |
|
Gets the size as a string.
Definition at line 366 of file bytedisp.cpp. References toString(), and unit. |
|
Gets the size as a string.
Definition at line 338 of file bytedisp.cpp. References long_units, short_units, toDouble(), and toString(). Referenced by ChecksumsListView::ChecksumProgress::ChecksumProgress(), toString(), and ChecksumsListView::ChecksumProgress::update(). |
|
Name of the units (long format).
Definition at line 48 of file bytedisp.cpp. Referenced by initStatic(), and toString(). |
|
Name of the units (short format).
Definition at line 49 of file bytedisp.cpp. Referenced by initStatic(), and toString(). |
|
Value of the size.
Definition at line 100 of file bytedisp.hpp. Referenced by BytesDisplayer(), clone(), normalize(), operator+=(), operator=(), and toDouble(). |
|
Current unit.
Definition at line 101 of file bytedisp.hpp. Referenced by BytesDisplayer(), clone(), normalize(), operator+=(), operator=(), toDouble(), and toString(). |