Go to the documentation of this file. 1 #ifndef BALL_SYSTEM_BINARYFILEADAPTOR_H
2 #define BALL_SYSTEM_BINARYFILEADAPTOR_H
7 #ifndef BALL_COMMON_LOGSTREAM_H
19 if (
sizeof(T) % 2 != 0)
21 Log.
error() <<
"Cannot swap types of uneven size." << std::endl;
25 char* tmp =
reinterpret_cast<char*
>(&t);
26 std::reverse(tmp, tmp +
sizeof(T));
101 template <
typename T>
108 template <
typename T>
111 swap_endian_(swap_endian)
115 template <
typename T>
118 swap_endian_ = swap_endian;
121 template <
typename T>
127 template <
typename T>
133 template <
typename T>
139 template <
typename T>
146 template <
typename T>
152 os.write(
reinterpret_cast<const char*
>(&data.
getData()),
sizeof(T));
156 T swapped_data = data.
getData();
158 os.write(
reinterpret_cast<const char*
>(&swapped_data),
sizeof(T));
164 template <
typename T>
170 is.read(
reinterpret_cast<char*
>(&data.
getData()),
sizeof(T));
175 is.read(
reinterpret_cast<char*
>(&swapped_data),
sizeof(T));
184 #ifndef BALL_NO_INLINE_FUNCTIONS
185 #include <BALL/SYSTEM/binaryFileAdaptor.iC>
188 #endif //BALL_SYSTEM_BINARYFILEADAPTOR_H
bool getSwapEndian() const
return the swap_endian flag
void setSwapEndian(bool swap_endian)
Set the swap_endian flag.
BALL_EXPORT LogStream Log
LogStream & error(int n=0)
void setData(const T &data)
const T & getData() const
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
BinaryFileAdaptor()
Default constructor.
BinaryFileAdaptor(const T &data, bool swap_endian=false)
Detailed constructor.