1#ifndef UTIL_TEXT_FILE_I_ARCHIVE_H
2#define UTIL_TEXT_FILE_I_ARCHIVE_H
14#include <util/space/Vector.h>
15#include <util/space/IntVector.h>
76 std::ifstream&
file();
108 template <
typename T,
size_t N>
118 template <
typename T,
size_t N>
132 template <
typename T>
145 template <
typename T>
146 void unpack(T* array,
int n);
160 template <
typename T>
161 void unpack(T* array,
int m,
int n,
int np);
166 std::ifstream* filePtr_;
169 unsigned int version_;
189 template <
typename T>
192 serialize(*
this, data, version_);
199 template <
typename T>
202 serialize(*
this, data, version_);
209 template <
typename T,
size_t N>
212 for (
size_t i = 0; i < N; ++i) {
213 serialize(*
this, data[i], version_);
221 template <
typename T,
size_t N>
224 for (
size_t i = 0; i < N; ++i) {
225 serialize(*
this, data[i], version_);
235 template <
typename T>
237 { *filePtr_ >> data; }
242 template <
typename T>
245 for (
int i=0; i < n; ++i) {
246 *filePtr_ >> array[i];
253 template <
typename T>
257 for (i = 0; i < m; ++i) {
258 for (j = 0; j < n; ++j) {
259 *filePtr_ >> array[i*np + j];
269 { filePtr_->get(data); }
277 filePtr_->get(array, n+1,
'\0');
286 inline void serialize(TextFileIArchive& ar,
bool& data,
287 const unsigned int version)
294 inline void serialize(TextFileIArchive& ar,
char& data,
295 const unsigned int version)
302 inline void serialize(TextFileIArchive& ar,
unsigned int& data,
303 const unsigned int version)
310 inline void serialize(TextFileIArchive& ar,
int& data,
311 const unsigned int version)
318 inline void serialize(TextFileIArchive& ar,
unsigned long& data,
319 const unsigned int version)
326 inline void serialize(TextFileIArchive& ar,
long& data,
327 const unsigned int version)
334 inline void serialize(TextFileIArchive& ar,
float& data,
335 const unsigned int version)
342 inline void serialize(TextFileIArchive& ar,
double& data,
343 const unsigned int version)
349 template <
typename T>
350 void serialize(TextFileIArchive& ar, std::vector<T>& data,
351 const unsigned int version)
358 for (
size_t i = 0; i < size; ++i) {
360 data.push_back(element);
371 void serialize(TextFileIArchive& ar, std::complex<float>& data,
372 const unsigned int version)
380 void serialize(TextFileIArchive& ar, std::complex<double>& data,
381 const unsigned int version)
388 void serialize(TextFileIArchive& ar, std::string& data,
389 const unsigned int version);
397 inline void serialize(TextFileIArchive& ar, Vector& data,
398 const unsigned int version)
405 inline void serialize(TextFileIArchive& ar, IntVector& data,
406 const unsigned int version)
Loading archive for text istream.
TextFileIArchive()
Constructor.
TextFileIArchive & operator&(T &data)
Load one object of type T via operator &.
std::ifstream & file()
Get the underlying ifstream by reference.
static bool is_saving()
Is this a saving (output) archive? Returns false.
TextFileIArchive & operator>>(T &data)
Load one object of type T via operator >>.
void unpack(T &data)
Load a single T object.
static bool is_loading()
Is this a loading (input) archive? Returns true.
virtual ~TextFileIArchive()
Destructor.
Utility classes for scientific computation.