1#ifndef UTIL_BINARY_FILE_O_ARCHIVE_H
2#define UTIL_BINARY_FILE_O_ARCHIVE_H
14#include <util/space/Vector.h>
15#include <util/space/IntVector.h>
68 std::ofstream&
file();
101 template <
typename T,
size_t N>
111 template <
typename T,
size_t N>
121 template <
typename T>
122 void pack(
const T& data);
130 template <
typename T>
131 void pack(
const T* array,
int n);
144 template <
typename T>
145 void pack(
const T* array,
int m,
int n,
int np);
150 std::ofstream* filePtr_;
153 unsigned int version_;
173 template <
typename T>
176 serialize(*
this, data, version_);
183 template <
typename T>
186 serialize(*
this, data, version_);
193 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>
208 for (
size_t i=0; i < N; ++i) {
209 serialize(*
this, data[i], version_);
219 template <
typename T>
221 { filePtr_->write( (
char*)(&data),
sizeof(T)); }
226 template <
typename T>
229 for (
int i=0; i < n; ++i) {
230 filePtr_->write( (
char*)(&array[i]),
sizeof(T));
237 template <
typename T>
241 for (i=0; i < m; ++i) {
242 for (j=0; j < n; ++j) {
243 filePtr_->write( (
char*)(&array[i*np + j]),
sizeof(T));
255 const unsigned int version)
262 inline void serialize(BinaryFileOArchive& ar,
char& data,
263 const unsigned int version)
271 const unsigned int version)
279 const unsigned int version)
287 const unsigned int version)
295 const unsigned int version)
303 const unsigned int version)
311 const unsigned int version)
317 template <
typename T>
319 const unsigned int version)
321 size_t size = data.size();
323 for (
size_t i = 0; i < size; ++i) {
336 const unsigned int version)
345 const unsigned int version)
353 const unsigned int version)
355 size_t size = data.size() + 1;
357 const char* temp = data.c_str();
368 const unsigned int version)
376 const unsigned int version)
Saving / output archive for binary ostream.
static bool is_loading()
Returns false;.
BinaryFileOArchive & operator<<(T &data)
Save (write) one object of type T via the << operator.
BinaryFileOArchive()
Constructor.
BinaryFileOArchive & operator&(T &data)
Save (write) one object of type T via the & operator.
std::ofstream & file()
Get the underlying ifstream by reference.
static bool is_saving()
Returns true;.
virtual ~BinaryFileOArchive()
Destructor.
void pack(const T &data)
Pack one object of type T.
An IntVector is an integer Cartesian vector.
A Vector is a Cartesian vector.
Utility classes for scientific computation.