1#ifndef UTIL_BINARY_FILE_I_ARCHIVE_H
2#define UTIL_BINARY_FILE_I_ARCHIVE_H
14#include <util/space/Vector.h>
15#include <util/space/IntVector.h>
72 std::ifstream&
file();
101 template <
typename T,
size_t N>
111 template <
typename T,
size_t N>
118 template <
typename T>
127 template <
typename T>
128 void unpack(T* array,
int n);
143 template <
typename T>
144 void unpack(T* array,
int m,
int n,
int np);
149 std::ifstream* filePtr_;
152 unsigned int version_;
172 template <
typename T>
175 serialize(*
this, data, version_);
182 template <
typename T>
185 serialize(*
this, data, version_);
192 template <
typename T,
size_t N>
196 for (
size_t i=0; i < N; ++i) {
197 serialize(*
this, data[i], version_);
205 template <
typename T,
size_t N>
209 for (
size_t i=0; i < N; ++i) {
210 serialize(*
this, data[i], version_);
220 template <
typename T>
222 { filePtr_->read( (
char*)(&data),
sizeof(T) ); }
227 template <
typename T>
230 for (
int i=0; i < n; ++i) {
231 filePtr_->read( (
char*)(&array[i]),
sizeof(T));
238 template <
typename T>
242 for (i = 0; i < m; ++i) {
243 for (j = 0; j < n; ++j) {
244 filePtr_->read( (
char*)(&array[i*np + j]),
sizeof(T));
256 const unsigned int version)
263 inline void serialize(BinaryFileIArchive& ar,
char& data,
264 const unsigned int version)
271 inline void serialize(BinaryFileIArchive& ar,
unsigned int& data,
272 const unsigned int version)
279 inline void serialize(BinaryFileIArchive& ar,
int& data,
280 const unsigned int version)
287 inline void serialize(BinaryFileIArchive& ar,
unsigned long& data,
288 const unsigned int version)
295 inline void serialize(BinaryFileIArchive& ar,
long& data,
296 const unsigned int version)
303 inline void serialize(BinaryFileIArchive& ar,
float& data,
304 const unsigned int version)
311 inline void serialize(BinaryFileIArchive& ar,
double& data,
312 const unsigned int version)
318 template <
typename T>
319 void serialize(BinaryFileIArchive& ar, std::vector<T>& data,
320 const unsigned int version)
327 for (
size_t i = 0; i < size; ++i) {
329 data.push_back(element);
340 void serialize(BinaryFileIArchive& ar, std::complex<float>& data,
341 const unsigned int version)
349 void serialize(BinaryFileIArchive& ar, std::complex<double>& data,
350 const unsigned int version)
357 void serialize(BinaryFileIArchive& ar, std::string& data,
358 const unsigned int version);
366 inline void serialize(BinaryFileIArchive& ar, Vector& data,
367 const unsigned int version)
374 inline void serialize(BinaryFileIArchive& ar, IntVector& data,
375 const unsigned int version)
Loading (input) archive for binary istream.
BinaryFileIArchive & operator>>(T &data)
Load (read) one object of type T via the & operator.
static bool is_loading()
Is this a loading (input) archive? Returns true.
void unpack(T &data)
Unpack a single T object.
std::ifstream & file()
Get the underlying ifstream by reference.
virtual ~BinaryFileIArchive()
Destructor.
BinaryFileIArchive & operator&(T &data)
Load (read) one object of type T via the & operator.
static bool is_saving()
Is this a saving (output) archive? Returns false.
BinaryFileIArchive()
Constructor.
Utility classes for scientific computation.