Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

FSize Class Reference

Store and operate on (file/package/partition) sizes (long long). More...

#include <FSize.h>

List of all members.

Public Types

enum  Unit {
  B = 0, K, M, G,
  T
}

Public Member Functions

 FSize (const long long size_r=0)
 FSize (const long long size_r, const Unit unit_r)
 FSize (const std::string &sizeStr, const Unit unit_r=B)
 operator long long () const
FSize & operator+= (const long long rhs)
FSize & operator-= (const long long rhs)
FSize & operator *= (const long long rhs)
FSize & operator/= (const long long rhs)
FSize & operator++ ()
FSize & operator-- ()
FSize operator++ (int)
FSize operator-- (int)
FSize & fillBlock (FSize blocksize_r=KB)
FSize fullBlock (FSize blocksize_r=KB) const
long long operator() (const Unit unit_r) const
Unit bestUnit () const
std::string form (const Unit unit_r, unsigned fw=0, unsigned prec=bestPrec, const bool showunit=true) const
std::string form (unsigned fw=0, unsigned prec=bestPrec, const bool showunit=true) const
std::string asString () const

Static Public Member Functions

static long long factor (const Unit unit_r)
static const char * unit (const Unit unit_r)

Static Public Attributes

static const long long KB = 1024
static const long long MB = 1024 * KB
static const long long GB = 1024 * MB
static const long long TB = 1024 * GB
static const unsigned bestPrec = (unsigned)-1

Private Attributes

long long _size

Friends

std::ostream & operator<< (std::ostream &str, const FSize &obj)


Detailed Description

Store and operate on (file/package/partition) sizes (long long).


Member Enumeration Documentation

enum FSize::Unit
 

The Units

Enumerator:
B 
K 
M 
G 
T 


Constructor & Destructor Documentation

FSize::FSize (  const long long  size_r = 0  )  [inline]
 

Construct from size in Byte.

FSize::FSize (  const long long  size_r,
const Unit  unit_r
)  [inline]
 

Construct from size in certain unit. E.g. FSize( 1, FSize::K ) makes 1024 Byte.

FSize::FSize (  const std::string &  sizeStr,
const Unit  unit_r = B
) 
 

Construct from string containing a number in given unit.


Member Function Documentation

std::string FSize::asString (   )  const
 

Default string representation (precision 1 and unit appended).

Unit FSize::bestUnit (   )  const
 

Return the best unit for string representation.

static long long FSize::factor (  const Unit  unit_r  )  [inline, static]
 

Return ammount of Byte in Unit.

FSize& FSize::fillBlock (  FSize  blocksize_r = KB  ) 
 

Adjust size to multiple of blocksize_r

std::string FSize::form (  unsigned  fw = 0,
unsigned  prec = bestPrec,
const bool  showunit = true
)  const [inline]
 

Return string representation in bestUnit.

std::string FSize::form (  const Unit  unit_r,
unsigned  fw = 0,
unsigned  prec = bestPrec,
const bool  showunit = true
)  const
 

Return string representation in given Unit. Parameter fw and prec denote field width and precision as in a "%*.*f" printf format string. Avalue of bestPrec automatically picks an appropriate precision depending on the unit. If showunit ist true, the string representaion of Unit is appended separated by a single blank.

If Unit is Byte, precision is set to zero.

FSize FSize::fullBlock (  FSize  blocksize_r = KB  )  const [inline]
 

Return size adjusted to multiple of blocksize_r

FSize& FSize::operator *= (  const long long  rhs  )  [inline]
 

FSize::operator long long (   )  const [inline]
 

Conversion to long long

long long FSize::operator() (  const Unit  unit_r  )  const [inline]
 

Return size in Unit ( not rounded )

FSize FSize::operator++ (  int   )  [inline]
 

FSize& FSize::operator++ (   )  [inline]
 

FSize& FSize::operator+= (  const long long  rhs  )  [inline]
 

FSize FSize::operator-- (  int   )  [inline]
 

FSize& FSize::operator-- (   )  [inline]
 

FSize& FSize::operator-= (  const long long  rhs  )  [inline]
 

FSize& FSize::operator/= (  const long long  rhs  )  [inline]
 

static const char* FSize::unit (  const Unit  unit_r  )  [inline, static]
 

String representation of Unit.


Friends And Related Function Documentation

std::ostream& operator<< (  std::ostream &  str,
const FSize &  obj
)  [friend]
 

Write asString.


Member Data Documentation

long long FSize::_size [private]
 

The size in Byte

const unsigned FSize::bestPrec = (unsigned)-1 [static]
 

Used as precision argument to form(), the 'best' precision according to Unist is chosen.

const long long FSize::GB = 1024 * MB [static]
 

const long long FSize::KB = 1024 [static]
 

const long long FSize::MB = 1024 * KB [static]
 

const long long FSize::TB = 1024 * GB [static]
 


The documentation for this class was generated from the following file:
Generated on Fri Feb 24 00:30:02 2006 for liby2util by  doxygen 1.4.4