Loading...
Searching...
No Matches
BALL::BinaryFileAdaptor< T > Class Template Reference
Foundation Classes » Operating system support

`#include <BALL/SYSTEM/binaryFileAdaptor.h>`

## Public Member Functions

Constructors and destructor
| BinaryFileAdaptor ()
| Default constructor.
| BinaryFileAdaptor (const T &data, bool swap_endian=false)
| Detailed constructor.

## Accessors

T | data_
bool | swap_endian_
void | setSwapEndian (bool swap_endian)
| Set the swap_endian flag.
bool | getSwapEndian () const
| return the swap_endian flag
void | setData (const T &data)
const T & | getData () const
T & | getData ()

## Detailed Description

template<typename T>
class BALL::BinaryFileAdaptor< T >

Helper class for data conversion. BinaryFileAdaptors are used to read and write binary data from and to streams. This is done by reading the member data as a byte stream through an explicit cast and utilizing the stream read() and write() functions.

  Caveat: This concept relies on the C++ memory layout and thus is highly non-portable!

  The flag swap_endian can be used to swap between big- and little-endian.

Definition at line 53 of file binaryFileAdaptor.h.

## Constructor & Destructor Documentation

## BinaryFileAdaptor() [1/2]

template<typename T>

BALL::BinaryFileAdaptor< T >::BinaryFileAdaptor | ( |  | ) |

Default constructor.

Definition at line 102 of file binaryFileAdaptor.h.

## BinaryFileAdaptor() [2/2]

template<typename T>

BALL::BinaryFileAdaptor< T >::BinaryFileAdaptor | ( | const T & | data,
|  | bool | swap_endian = false )

Detailed constructor.

Definition at line 109 of file binaryFileAdaptor.h.

## Member Function Documentation

## getData() [1/2]

template<typename T>

T & BALL::BinaryFileAdaptor< T >::getData | ( |  | ) |

Returns a mutable reference to the data stored in the adaptor

Definition at line 140 of file binaryFileAdaptor.h.

## getData() [2/2]

template<typename T>

const T & BALL::BinaryFileAdaptor< T >::getData | ( |  | ) | const

Returns a const reference to the data stored in the adaptor

Definition at line 134 of file binaryFileAdaptor.h.

## getSwapEndian()

template<typename T>

bool BALL::BinaryFileAdaptor< T >::getSwapEndian | ( |  | ) | const

return the swap_endian flag

Definition at line 122 of file binaryFileAdaptor.h.

## setData()

template<typename T>

void BALL::BinaryFileAdaptor< T >::setData | ( | const T & | data | ) |

Sets the member data to the desired value.

Parameters

  data | data of type T

Definition at line 128 of file binaryFileAdaptor.h.

## setSwapEndian()

template<typename T>

void BALL::BinaryFileAdaptor< T >::setSwapEndian | ( | bool | swap_endian | ) |

Set the swap_endian flag.

Definition at line 116 of file binaryFileAdaptor.h.

## Member Data Documentation

## data_

template<typename T>

T BALL::BinaryFileAdaptor< T >::data_

protected

Definition at line 95 of file binaryFileAdaptor.h.

## swap_endian_

template<typename T>

bool BALL::BinaryFileAdaptor< T >::swap_endian_

protected

Definition at line 98 of file binaryFileAdaptor.h.