libtgd 4.2
A library that makes working with multidimensional arrays in C++ easy
Classes | Enumerations | Functions | Variables
TGD Namespace Reference

Classes

class  Array
 An Array with a specific component data type given the template parameter. This is the main class to work with since it allows useful for operations on arrays (e.g. component-wise addition) and provides iterators. More...
 
class  ArrayContainer
 The ArrayContainer class manages arrays with arbitrary component data types. More...
 
class  ArrayDescription
 The ArrayDescription manages array metadata. More...
 
class  Exporter
 The exporter class exports arrays to files or streams. More...
 
class  Importer
 The importer class imports arrays from files or streams. More...
 
class  TagList
 A tag list to store key/value pairs, where both key and value are strings. More...
 

Enumerations

enum  Type {
  int8 = 0 , uint8 = 1 , int16 = 2 , uint16 = 3 ,
  int32 = 4 , uint32 = 5 , int64 = 6 , uint64 = 7 ,
  float32 = 8 , float64 = 9
}
 The data type that array element components can represent. More...
 
enum  Error {
  ErrorNone = 0 , ErrorFormatUnsupported = 1 , ErrorFeaturesUnsupported = 2 , ErrorMissingHints = 3 ,
  ErrorInvalidData = 4 , ErrorSeekingNotSupported = 5 , ErrorAppendingNotSupported = 6 , ErrorLibrary = 7 ,
  ErrorSysErrno = 8
}
 Input/output errors. More...
 

Functions

constexpr size_t typeSize (Type t)
 Returns the size of a TGD type. More...
 
template<typename T >
constexpr Type typeFromTemplate ()
 Returns the TGD component type that corresponds to the template parameter. More...
 
bool typeFromString (const std::string &s, Type *t)
 Determine the TGD component type described in the string, return false if this fails. More...
 
const char * typeToString (Type t)
 Return the name of the given type. More...
 
ArrayContainer convert (const ArrayContainer &a, Type newType)
 Convert the given array to the given new component type. If conversion is not actually necessary because the new type is the same as the old, the returned array will simply share its data with the original array. More...
 
template<typename T , typename FUNC >
Array< T > forEachComponent (const Array< T > &a, FUNC func)
 Apply func to all components in array a. More...
 
template<typename T , typename FUNC >
Array< T > & forEachComponentInplace (Array< T > &a, FUNC func)
 Apply func to all components in array a, in place. More...
 
template<typename T , typename FUNC >
Array< T > forEachComponent (const Array< T > &a, T b, FUNC func)
 Apply func to all components in array a using value b. More...
 
template<typename T , typename FUNC >
Array< T > & forEachComponentInplace (Array< T > &a, T b, FUNC func)
 Apply func to all components in array a using value b, in place. More...
 
template<typename T , typename FUNC >
Array< T > forEachComponent (const Array< T > &a, const Array< T > &b, FUNC func)
 Apply func to all components in arrays a and b. More...
 
template<typename T , typename FUNC >
Array< T > & forEachComponentInplace (Array< T > &a, const Array< T > &b, FUNC func)
 Apply func to all components in arrays a and b, in place. More...
 
template<typename T , typename FUNC >
Array< T > forEachElement (const Array< T > &a, FUNC func)
 Apply func to all elements in array a. More...
 
template<typename T , typename FUNC >
Array< T > & forEachElementInplace (Array< T > &a, FUNC func)
 Apply func to all elements in array a, in place. More...
 
template<typename T , typename FUNC >
Array< T > forEachElement (const Array< T > &a, const T *b, FUNC func)
 Apply func to all elements in array a using element b. More...
 
template<typename T , typename FUNC >
Array< T > & forEachElementInplace (Array< T > &a, const T *b, FUNC func)
 Apply func to all elements in array a using element b, in place. More...
 
template<typename T , typename FUNC >
Array< T > forEachElement (const Array< T > &a, const Array< T > &b, FUNC func)
 Apply func to all elements in arrays a and b. More...
 
template<typename T , typename FUNC >
Array< T > & forEachElementInplace (Array< T > &a, const Array< T > &b, FUNC func)
 Apply func to all elements in arrays a and b, in place. More...
 
template<typename T >
Array< T > operator- (const Array< T > &a)
 
template<typename T >
Array< T > abs (const Array< T > &a)
 
template<typename T >
Array< T > absInplace (Array< T > &a)
 
template<typename T >
Array< T > operator+ (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator+ (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator+= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator+= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator- (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator- (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator-= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator-= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator* (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator* (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator*= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator*= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator/ (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator/ (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator/= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator/= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator% (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator% (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator%= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator%= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator& (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator& (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator&= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator&= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator| (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator| (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator|= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator|= (Array< T > &a, T b)
 
template<typename T >
Array< T > operator^ (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator^ (const Array< T > &a, T b)
 
template<typename T >
Array< T > operator^= (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > operator^= (Array< T > &a, T b)
 
template<typename T >
Array< T > min (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > min (const Array< T > &a, T b)
 
template<typename T >
Array< T > minInplace (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > minInplace (Array< T > &a, T b)
 
template<typename T >
Array< T > max (const Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > max (const Array< T > &a, T b)
 
template<typename T >
Array< T > maxInplace (Array< T > &a, const Array< T > &b)
 
template<typename T >
Array< T > maxInplace (Array< T > &a, T b)
 
const char * strerror (Error e)
 Convert an input/output error to human-readable string. More...
 
ArrayContainer load (const std::string &fileName, const TagList &hints=TagList(), Error *error=nullptr)
 Shortcut to read a single array from a file in a single line of code. More...
 
bool save (const ArrayContainer &A, const std::string &fileName, bool append=Overwrite, Error *error=nullptr, const TagList &hints=TagList())
 Shortcut to write a single array to a file in a single line of code. More...
 

Variables

const bool Append = true
 Flag to be used for the append parameter of TGD::save() More...
 
const bool Overwrite = false
 Flag to be used for the append parameter of TGD::save() More...
 

Enumeration Type Documentation

◆ Error

enum TGD::Error

Input/output errors.

Enumerator
ErrorNone 

No error.

ErrorFormatUnsupported 

Unsupported file format.

ErrorFeaturesUnsupported 

Unsupported features used by the file.

ErrorMissingHints 

File format requires hints that are missing.

ErrorInvalidData 

Invalid data.

ErrorSeekingNotSupported 

Seeking not supported.

ErrorAppendingNotSupported 

Appending not supported.

ErrorLibrary 

Failure of external library.

ErrorSysErrno 

System error, consult errno.

◆ Type

enum TGD::Type

The data type that array element components can represent.

Enumerator
int8 

int8_t

uint8 

uint8_t

int16 

int16_t

uint16 

uint16_t

int32 

int32_t

uint32 

uint32_t

int64 

int64_t

uint64 

uint64_t

float32 

IEEE 754 single precision floating point (on all relevant platforms: float)

float64 

IEEE 754 double precision floating point (on all relevant platforms: double)

Function Documentation

◆ abs()

template<typename T >
Array< T > TGD::abs ( const Array< T > &  a)

◆ absInplace()

template<typename T >
Array< T > TGD::absInplace ( Array< T > &  a)

◆ convert()

ArrayContainer TGD::convert ( const ArrayContainer a,
Type  newType 
)
inline

Convert the given array to the given new component type. If conversion is not actually necessary because the new type is the same as the old, the returned array will simply share its data with the original array.

◆ forEachComponent() [1/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachComponent ( const Array< T > &  a,
const Array< T > &  b,
FUNC  func 
)

Apply func to all components in arrays a and b.

◆ forEachComponent() [2/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachComponent ( const Array< T > &  a,
FUNC  func 
)

Apply func to all components in array a.

◆ forEachComponent() [3/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachComponent ( const Array< T > &  a,
b,
FUNC  func 
)

Apply func to all components in array a using value b.

◆ forEachComponentInplace() [1/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachComponentInplace ( Array< T > &  a,
const Array< T > &  b,
FUNC  func 
)

Apply func to all components in arrays a and b, in place.

◆ forEachComponentInplace() [2/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachComponentInplace ( Array< T > &  a,
FUNC  func 
)

Apply func to all components in array a, in place.

◆ forEachComponentInplace() [3/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachComponentInplace ( Array< T > &  a,
b,
FUNC  func 
)

Apply func to all components in array a using value b, in place.

◆ forEachElement() [1/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachElement ( const Array< T > &  a,
const Array< T > &  b,
FUNC  func 
)

Apply func to all elements in arrays a and b.

◆ forEachElement() [2/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachElement ( const Array< T > &  a,
const T *  b,
FUNC  func 
)

Apply func to all elements in array a using element b.

◆ forEachElement() [3/3]

template<typename T , typename FUNC >
Array< T > TGD::forEachElement ( const Array< T > &  a,
FUNC  func 
)

Apply func to all elements in array a.

◆ forEachElementInplace() [1/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachElementInplace ( Array< T > &  a,
const Array< T > &  b,
FUNC  func 
)

Apply func to all elements in arrays a and b, in place.

◆ forEachElementInplace() [2/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachElementInplace ( Array< T > &  a,
const T *  b,
FUNC  func 
)

Apply func to all elements in array a using element b, in place.

◆ forEachElementInplace() [3/3]

template<typename T , typename FUNC >
Array< T > & TGD::forEachElementInplace ( Array< T > &  a,
FUNC  func 
)

Apply func to all elements in array a, in place.

◆ load()

ArrayContainer TGD::load ( const std::string &  fileName,
const TagList hints = TagList(),
Error error = nullptr 
)
inline

Shortcut to read a single array from a file in a single line of code.

◆ max() [1/2]

template<typename T >
Array< T > TGD::max ( const Array< T > &  a,
const Array< T > &  b 
)

◆ max() [2/2]

template<typename T >
Array< T > TGD::max ( const Array< T > &  a,
b 
)

◆ maxInplace() [1/2]

template<typename T >
Array< T > TGD::maxInplace ( Array< T > &  a,
const Array< T > &  b 
)

◆ maxInplace() [2/2]

template<typename T >
Array< T > TGD::maxInplace ( Array< T > &  a,
b 
)

◆ min() [1/2]

template<typename T >
Array< T > TGD::min ( const Array< T > &  a,
const Array< T > &  b 
)

◆ min() [2/2]

template<typename T >
Array< T > TGD::min ( const Array< T > &  a,
b 
)

◆ minInplace() [1/2]

template<typename T >
Array< T > TGD::minInplace ( Array< T > &  a,
const Array< T > &  b 
)

◆ minInplace() [2/2]

template<typename T >
Array< T > TGD::minInplace ( Array< T > &  a,
b 
)

◆ operator%() [1/2]

template<typename T >
Array< T > TGD::operator% ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator%() [2/2]

template<typename T >
Array< T > TGD::operator% ( const Array< T > &  a,
b 
)

◆ operator%=() [1/2]

template<typename T >
Array< T > TGD::operator%= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator%=() [2/2]

template<typename T >
Array< T > TGD::operator%= ( Array< T > &  a,
b 
)

◆ operator&() [1/2]

template<typename T >
Array< T > TGD::operator& ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator&() [2/2]

template<typename T >
Array< T > TGD::operator& ( const Array< T > &  a,
b 
)

◆ operator&=() [1/2]

template<typename T >
Array< T > TGD::operator&= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator&=() [2/2]

template<typename T >
Array< T > TGD::operator&= ( Array< T > &  a,
b 
)

◆ operator*() [1/2]

template<typename T >
Array< T > TGD::operator* ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator*() [2/2]

template<typename T >
Array< T > TGD::operator* ( const Array< T > &  a,
b 
)

◆ operator*=() [1/2]

template<typename T >
Array< T > TGD::operator*= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator*=() [2/2]

template<typename T >
Array< T > TGD::operator*= ( Array< T > &  a,
b 
)

◆ operator+() [1/2]

template<typename T >
Array< T > TGD::operator+ ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator+() [2/2]

template<typename T >
Array< T > TGD::operator+ ( const Array< T > &  a,
b 
)

◆ operator+=() [1/2]

template<typename T >
Array< T > TGD::operator+= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator+=() [2/2]

template<typename T >
Array< T > TGD::operator+= ( Array< T > &  a,
b 
)

◆ operator-() [1/3]

template<typename T >
Array< T > TGD::operator- ( const Array< T > &  a)

◆ operator-() [2/3]

template<typename T >
Array< T > TGD::operator- ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator-() [3/3]

template<typename T >
Array< T > TGD::operator- ( const Array< T > &  a,
b 
)

◆ operator-=() [1/2]

template<typename T >
Array< T > TGD::operator-= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator-=() [2/2]

template<typename T >
Array< T > TGD::operator-= ( Array< T > &  a,
b 
)

◆ operator/() [1/2]

template<typename T >
Array< T > TGD::operator/ ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator/() [2/2]

template<typename T >
Array< T > TGD::operator/ ( const Array< T > &  a,
b 
)

◆ operator/=() [1/2]

template<typename T >
Array< T > TGD::operator/= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator/=() [2/2]

template<typename T >
Array< T > TGD::operator/= ( Array< T > &  a,
b 
)

◆ operator^() [1/2]

template<typename T >
Array< T > TGD::operator^ ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator^() [2/2]

template<typename T >
Array< T > TGD::operator^ ( const Array< T > &  a,
b 
)

◆ operator^=() [1/2]

template<typename T >
Array< T > TGD::operator^= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator^=() [2/2]

template<typename T >
Array< T > TGD::operator^= ( Array< T > &  a,
b 
)

◆ operator|() [1/2]

template<typename T >
Array< T > TGD::operator| ( const Array< T > &  a,
const Array< T > &  b 
)

◆ operator|() [2/2]

template<typename T >
Array< T > TGD::operator| ( const Array< T > &  a,
b 
)

◆ operator|=() [1/2]

template<typename T >
Array< T > TGD::operator|= ( Array< T > &  a,
const Array< T > &  b 
)

◆ operator|=() [2/2]

template<typename T >
Array< T > TGD::operator|= ( Array< T > &  a,
b 
)

◆ save()

bool TGD::save ( const ArrayContainer A,
const std::string &  fileName,
bool  append = Overwrite,
Error error = nullptr,
const TagList hints = TagList() 
)
inline

Shortcut to write a single array to a file in a single line of code.

◆ strerror()

const char * TGD::strerror ( Error  e)

Convert an input/output error to human-readable string.

◆ typeFromString()

bool TGD::typeFromString ( const std::string &  s,
Type t 
)
inline

Determine the TGD component type described in the string, return false if this fails.

◆ typeFromTemplate()

template<typename T >
constexpr Type TGD::typeFromTemplate ( )
inlineconstexpr

Returns the TGD component type that corresponds to the template parameter.

◆ typeSize()

constexpr size_t TGD::typeSize ( Type  t)
inlineconstexpr

Returns the size of a TGD type.

◆ typeToString()

const char * TGD::typeToString ( Type  t)
inline

Return the name of the given type.

Variable Documentation

◆ Append

const bool TGD::Append = true

Flag to be used for the append parameter of TGD::save()

◆ Overwrite

const bool TGD::Overwrite = false

Flag to be used for the append parameter of TGD::save()