1 #ifndef UTIL_TEXT_FILE_O_ARCHIVE_H 2 #define UTIL_TEXT_FILE_O_ARCHIVE_H 12 #include "serialize.h" 14 #include <util/space/Vector.h> 15 #include <util/space/IntVector.h> 68 std::ofstream&
file();
88 void pack(
const T& data);
97 void pack(
const T* array,
int n);
107 template <
typename T>
108 void pack(
const T* array,
int m,
int n,
int np);
113 std::ofstream* filePtr_;
116 unsigned int version_;
136 template <
typename T>
139 serialize(*
this, data, version_);
146 template <
typename T>
149 serialize(*
this, data, version_);
158 template <
typename T>
160 { *filePtr_ << data << std::endl; }
168 filePtr_->setf(std::ios::scientific);
170 filePtr_->precision(17);
171 *filePtr_ << data << std::endl;
177 template <
typename T>
180 for (
int i=0; i < n; ++i) {
181 *filePtr_ << array[i] <<
" ";
183 *filePtr_ << std::endl;
189 template <
typename T>
193 for (i=0; i < m; ++i) {
194 for (j=0; j < n; ++j) {
195 *filePtr_ << array[i*np + j] <<
" ";
197 *filePtr_ << std::endl;
207 filePtr_->setf(std::ios::scientific);
208 filePtr_->precision(16);
209 for (
int i=0; i < n; ++i) {
211 *filePtr_ << array[i] <<
" ";
213 *filePtr_ << std::endl;
223 const unsigned int version)
231 const unsigned int version)
239 const unsigned int version)
247 const unsigned int version)
255 const unsigned int version)
263 const unsigned int version)
271 const unsigned int version)
279 const unsigned int version)
285 template <
typename T>
287 const unsigned int version)
289 size_t size = data.size();
291 for (
size_t i = 0; i < size; ++i) {
304 const unsigned int version)
313 const unsigned int version)
321 const unsigned int version)
323 int size = data.size();
337 const unsigned int version)
345 const unsigned int version)
A Vector is a Cartesian vector.
static bool is_saving()
Returns true;.
void pack(const T &data)
Save one T object to this archive.
std::ofstream & file()
Get the underlying ifstream by reference.
virtual ~TextFileOArchive()
Destructor.
Utility classes for scientific computation.
TextFileOArchive & operator&(T &data)
Save one T object to this archive.
static bool is_loading()
Returns false;.
An IntVector is an integer Cartesian vector.
TextFileOArchive()
Constructor.
TextFileOArchive & operator<<(T &data)
Save one T object to this archive.
Saving archive for character based ostream.