1 #ifndef UTIL_BINARY_FILE_O_ARCHIVE_H 2 #define UTIL_BINARY_FILE_O_ARCHIVE_H 12 #include "serialize.h" 14 #include <util/space/Vector.h> 15 #include <util/space/IntVector.h> 68 std::ofstream&
file();
86 void pack(
const T& data);
95 void pack(
const T* array,
int n);
108 template <
typename T>
109 void pack(
const T* array,
int m,
int n,
int np);
114 std::ofstream* filePtr_;
117 unsigned int version_;
137 template <
typename T>
140 serialize(*
this, data, version_);
147 template <
typename T>
150 serialize(*
this, data, version_);
159 template <
typename T>
161 { filePtr_->write( (
char*)(&data),
sizeof(T)); }
166 template <
typename T>
169 for (
int i=0; i < n; ++i) {
170 filePtr_->write( (
char*)(&array[i]),
sizeof(T));
177 template <
typename T>
181 for (i=0; i < m; ++i) {
182 for (j=0; j < n; ++j) {
183 filePtr_->write( (
char*)(&array[i*np + j]),
sizeof(T));
195 const unsigned int version)
203 const unsigned int version)
211 const unsigned int version)
219 const unsigned int version)
227 const unsigned int version)
235 const unsigned int version)
243 const unsigned int version)
251 const unsigned int version)
257 template <
typename T>
259 const unsigned int version)
261 size_t size = data.size();
263 for (
size_t i = 0; i < size; ++i) {
276 const unsigned int version)
285 const unsigned int version)
293 const unsigned int version)
295 size_t size = data.size() + 1;
297 const char* temp = data.c_str();
308 const unsigned int version)
316 const unsigned int version)
A Vector is a Cartesian vector.
BinaryFileOArchive & operator<<(T &data)
Save one object.
BinaryFileOArchive & operator&(T &data)
Save one object.
Saving / output archive for binary ostream.
static bool is_saving()
Returns true;.
void pack(const T &data)
Pack one object of type T.
static bool is_loading()
Returns false;.
Utility classes for scientific computation.
virtual ~BinaryFileOArchive()
Destructor.
An IntVector is an integer Cartesian vector.
BinaryFileOArchive()
Constructor.
std::ofstream & file()
Get the underlying ifstream by reference.