OpendTect 8.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Private Member Functions | List of all members
NrBytesToStringCreator Class Reference

#include <nrbytes2string.h>

Public Types

enum  Unit {
  Bytes =0 , KB =1 , MB =2 , GB =3 ,
  TB =4 , PB =5
}
 

Public Member Functions

 NrBytesToStringCreator ()
 
 NrBytesToStringCreator (od_uint64 nrbytes)
 
StringView getString (od_uint64 number, int nrdecimals=2, bool withunit=true) const
 
StringView getUnitString () const
 
void setUnitFrom (od_uint64 number, bool maximum=true)
 

Static Public Member Functions

static StringView toString (Unit)
 

Protected Attributes

Unit unit_
 

Static Private Member Functions

static double convertFromBytes (od_int64 fsz, File::SizeUnit outunit)
 
static od_int64 convertToBytes (double fsz, File::SizeUnit inpunit)
 

Detailed Description

Converts integer with number of bytes to a string with KB, GB or similar unit.

<>

Member Enumeration Documentation

◆ Unit

Enumerator
Bytes 
KB 
MB 
GB 
TB 
PB 

Constructor & Destructor Documentation

◆ NrBytesToStringCreator() [1/2]

NrBytesToStringCreator::NrBytesToStringCreator ( )

◆ NrBytesToStringCreator() [2/2]

NrBytesToStringCreator::NrBytesToStringCreator ( od_uint64 nrbytes)

Unit is set from nrbytes

Member Function Documentation

◆ convertFromBytes()

static double NrBytesToStringCreator::convertFromBytes ( od_int64 fsz,
File::SizeUnit outunit )
staticprivate

◆ convertToBytes()

static od_int64 NrBytesToStringCreator::convertToBytes ( double fsz,
File::SizeUnit inpunit )
staticprivate

◆ getString()

StringView NrBytesToStringCreator::getString ( od_uint64 number,
int nrdecimals = 2,
bool withunit = true ) const

Use string before doing anything else, as it will be overwritten at next call from same thread.

◆ getUnitString()

StringView NrBytesToStringCreator::getUnitString ( ) const

◆ setUnitFrom()

void NrBytesToStringCreator::setUnitFrom ( od_uint64 number,
bool maximum = true )

Sets the unit (B, KB, MB, GB, TB) based on the number.

Parameters
number
maximumwill only change unit if a larger unit is needed.

◆ toString()

static StringView NrBytesToStringCreator::toString ( Unit )
static

Member Data Documentation

◆ unit_

Unit NrBytesToStringCreator::unit_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2025