ImFusion SDK 4.3
ByteSize Class Referencefinal

#include <ImFusion/Core/ByteSize.h>

Helper class to facilitate handling byte sizes. More...

Detailed Description

Helper class to facilitate handling byte sizes.

ByteSize enables you to quickly convert between Bytes, Kilobytes, Megabytes, and Gigabytes using base 2 (i.e. 1KB = 1024 bytes). Futhermore, there is a set of custom custom literals, to specify larger quantities in a human-readable fashion.

using namespace ImFusion::Literals;
ByteSize fileSize = ...;
if (fileSize > 100_MB)
LOG_WARN("large file detected");
ByteSize(size_t numBytes)
Creates a new object from number of bytes.
Definition ByteSize.h:30
#define LOG_WARN(...)
Emits a log message of Log::Level::Warning, optionally with a category.
Definition Log.h:252
Custom literals for classes of the ImFusion SDK.
Definition ByteSize.h:77
See also
Literals

Public Member Functions

 ByteSize (size_t numBytes)
 Creates a new object from number of bytes.
 
 operator size_t () const
 Implicit conversion to number of bytes.
 
size_t numBytes () const
 Returns the number of bytes.
 
size_t numKB () const
 Returns the number of Kilobytes.
 
size_t numMB () const
 Returns the number of Megabytes.
 
size_t numGB () const
 Returns the number of Gigabytes.
 
std::string toString () const
 Convert to a pretty-printed, human readable string representation with a maximum of 4 digits.
 
ByteSizeoperator+= (const ByteSize &rhs)
 
ByteSizeoperator-= (const ByteSize &rhs)
 

Static Public Member Functions

static ByteSize fromKB (size_t numKB)
 Creates a new object from number of Kilobytes.
 
static ByteSize fromMB (size_t numMB)
 Creates a new object from number of Megabytes.
 
static ByteSize fromGB (size_t numGB)
 Creates a new object from number of Gigabytes.
 

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close