37#include <itpp/itexports.h>
138 explicit it_ifile(
const std::string& filename);
142 void open(
const std::string& filename);
144 virtual void close();
149 bool read_check_file_header();
154 void low_level_read(
char& x);
156 void low_level_read(uint64_t& x);
158 void low_level_read(
bool &x);
161 void low_level_read(
bin& x);
163 void low_level_read(
short& x);
165 void low_level_read(
int& x);
167 void low_level_read(
float& x);
169 void low_level_read(
double& x);
171 void low_level_read(std::complex<float>& x);
173 void low_level_read(std::complex<double>& x);
176 void low_level_read(bvec& v);
178 void low_level_read(svec& v);
180 void low_level_read(ivec& v);
182 void low_level_read_lo(vec& v);
184 void low_level_read_hi(vec& v);
186 void low_level_read_lo(cvec& v);
188 void low_level_read_hi(cvec& v);
191 void low_level_read(std::string& str);
194 void low_level_read(
bmat& m);
196 void low_level_read(smat& m);
198 void low_level_read(imat& m);
200 void low_level_read_lo(mat& m);
202 void low_level_read_hi(mat& m);
204 void low_level_read_lo(cmat& m);
206 void low_level_read_hi(cmat& m);
221 void low_level_read(
Array<std::complex<float> >& v);
223 void low_level_read_lo(
Array<std::complex<double> >& v);
225 void low_level_read_hi(
Array<std::complex<double> >& v);
228 bool seek(
const std::string& name);
232 void info(std::string& name, std::string& type, std::string& desc,
260 explicit it_file(
const std::string& filename,
bool trunc =
false);
271 void open(
const std::string& filename,
bool trunc =
false);
288 const std::string& description =
"")
292 void write_file_header();
294 void write_data_header(
const std::string& type, uint64_t
size);
296 void write_data_header(
const std::string& type,
const std::string& name,
297 uint64_t
size,
const std::string& description =
"");
300 void low_level_write(
char x);
302 void low_level_write(uint64_t x);
304 void low_level_write(
bool x);
307 void low_level_write(
bin x);
309 void low_level_write(
short x);
311 void low_level_write(
int x);
313 void low_level_write(
float x);
315 void low_level_write(
double x);
317 void low_level_write(
const std::complex<float>& x);
319 void low_level_write(
const std::complex<double>& x);
322 void low_level_write(
const bvec& v);
324 void low_level_write(
const svec& v);
326 void low_level_write(
const ivec& v);
328 void low_level_write(
const vec& v);
330 void low_level_write(
const cvec& v);
333 void low_level_write(
const std::string& str);
336 void low_level_write(
const bmat& m);
338 void low_level_write(
const smat& m);
340 void low_level_write(
const imat& m);
342 void low_level_write(
const mat& m);
344 void low_level_write(
const cmat& m);
357 void low_level_write(
const Array<std::complex<float> >& v);
359 void low_level_write(
const Array<std::complex<double> >& v);
365 void remove(
const std::string& name);
367 bool exists(
const std::string& name);
375 void write_data_header_here(
const data_header& h);
385 struct Strings_Holder
387 std::string _next_name;
388 std::string _next_desc;
390 Strings_Holder():_next_name(
""),_next_desc(
""),_fname(
""){}
392 Strings_Holder* _strings;
394 std::string& fname() {
return _strings->_fname;}
432 Name(
const std::string& n,
const std::string& d =
""):
name(n),
desc(d) {}
460ITPP_EXPORT it_ifile&
operator>>(it_ifile& f,
char& v);
462ITPP_EXPORT it_ifile&
operator>>(it_ifile &f,
bool &v);
465ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, bin& v);
467ITPP_EXPORT it_ifile&
operator>>(it_ifile& f,
short& v);
469ITPP_EXPORT it_ifile&
operator>>(it_ifile& f,
int& v);
471ITPP_EXPORT it_ifile&
operator>>(it_ifile& f,
float& v);
473ITPP_EXPORT it_ifile&
operator>>(it_ifile& f,
double& v);
475ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, std::complex<float>& v);
477ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, std::complex<double>& v);
480ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, bvec& v);
482ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, svec& v);
484ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, ivec& v);
486ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, vec& v);
488ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, cvec& v);
491ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, std::string& str);
496ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, smat& m);
498ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, imat& m);
500ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, mat& m);
502ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, cmat& m);
505ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<bin>& v);
507ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<short>& v);
509ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<int>& v);
511ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<float>& v);
513ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<double>& v);
515ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<std::complex<float> >& v);
517ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<std::complex<double> >& v);
520ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<bvec>& v);
522ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<svec>& v);
524ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<ivec>& v);
526ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<vec>& v);
528ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<cvec>& v);
531ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<std::string>& v);
534ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<bmat>& v);
536ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<smat>& v);
538ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<imat>& v);
540ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<mat>& v);
542ITPP_EXPORT it_ifile&
operator>>(it_ifile& f, Array<cmat>& v);
546ITPP_EXPORT it_file&
operator<<(it_file& f,
char x);
548ITPP_EXPORT it_file&
operator<<(it_file &f,
bool x);
551ITPP_EXPORT it_file&
operator<<(it_file& f, bin x);
553ITPP_EXPORT it_file&
operator<<(it_file& f,
short x);
555ITPP_EXPORT it_file&
operator<<(it_file& f,
int x);
557ITPP_EXPORT it_file&
operator<<(it_file& f,
float x);
559ITPP_EXPORT it_file&
operator<<(it_file& f,
double x);
561ITPP_EXPORT it_file&
operator<<(it_file& f, std::complex<float> x);
563ITPP_EXPORT it_file&
operator<<(it_file& f, std::complex<double> x);
566ITPP_EXPORT it_file&
operator<<(it_file& f,
const bvec& v);
568ITPP_EXPORT it_file&
operator<<(it_file& f,
const svec& v);
570ITPP_EXPORT it_file&
operator<<(it_file& f,
const ivec& v);
572ITPP_EXPORT it_file&
operator<<(it_file& f,
const vec& v);
574ITPP_EXPORT it_file&
operator<<(it_file& f,
const cvec& v);
577ITPP_EXPORT it_file&
operator<<(it_file& f,
const std::string& str);
582ITPP_EXPORT it_file&
operator<<(it_file& f,
const smat& m);
584ITPP_EXPORT it_file&
operator<<(it_file& f,
const imat& m);
586ITPP_EXPORT it_file&
operator<<(it_file& f,
const mat& m);
588ITPP_EXPORT it_file&
operator<<(it_file& f,
const cmat& m);
591ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<bin>& v);
593ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<short>& v);
595ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<int>& v);
597ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<float>& v);
599ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<double>& v);
601ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<std::complex<float> >& v);
603ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<std::complex<double> >& v);
606ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<bvec>& v);
608ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<svec>& v);
610ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<ivec>& v);
612ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<vec>& v);
614ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<cvec>& v);
617ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<std::string>& v);
620ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<bmat>& v);
622ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<smat>& v);
624ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<imat>& v);
626ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<mat>& v);
628ITPP_EXPORT it_file&
operator<<(it_file& f,
const Array<cmat>& v);
631template <
class T>
inline
635 f <<
Name(name) << v;
640template <
class T>
inline
650#define it_save_var(v) it_save_var_as(v,#v)
652#define it_load_var(v) it_load_var_as(v,#v)
717 void open(
const std::string& name);
719 virtual void close();
724 bool read_check_file_header();
726 void read_data_header(data_header& h);
728 void low_level_read(
char& x);
730 void low_level_read(
bin& x);
732 void low_level_read(
short& x);
734 void low_level_read(
int& x);
736 void low_level_read(
float& x);
738 void low_level_read(
double& x);
740 void low_level_read(std::complex<float>& x);
742 void low_level_read(std::complex<double>& x);
744 void low_level_read_lo(vec& v);
746 void low_level_read_hi(vec& v);
748 void low_level_read(ivec& v);
750 void low_level_read(bvec& v);
752 void low_level_read_lo(cvec& v);
754 void low_level_read_hi(cvec& v);
756 void low_level_read(std::string& str);
758 void low_level_read_lo(mat& m);
760 void low_level_read_hi(mat& m);
762 void low_level_read(imat& m);
764 void low_level_read(
bmat& m);
766 void low_level_read_lo(cmat& m);
768 void low_level_read_hi(cmat& m);
781 void low_level_read_lo(
Array<std::complex<float> >& v);
783 void low_level_read_lo(
Array<std::complex<double> >& v);
785 void low_level_read_hi(
Array<std::complex<double> >& v);
788 bool seek(
const std::string& name);
793 void info(std::string& name, std::string& type,
int& bytes);
821 explicit it_file_old(
const std::string& name,
bool trunc =
false);
832 void open(
const std::string& name,
bool trunc =
false);
853 void write_file_header();
855 void write_data_header(
const std::string& type, uint32_t
size);
857 void write_data_header(
const std::string& type,
const std::string& name,
860 void low_level_write(
char x);
862 void low_level_write(
bin x);
864 void low_level_write(
short x);
866 void low_level_write(
int x);
868 void low_level_write(
float x);
870 void low_level_write(
double x);
872 void low_level_write(
const std::complex<float>& x);
874 void low_level_write(
const std::complex<double>& x);
876 void low_level_write(
const vec& v);
878 void low_level_write(
const ivec& v);
880 void low_level_write(
const bvec& v);
882 void low_level_write(
const cvec& v);
884 void low_level_write(
const std::string& str);
886 void low_level_write(
const mat& m);
888 void low_level_write(
const imat& m);
890 void low_level_write(
const bmat& m);
892 void low_level_write(
const cmat& m);
902 void low_level_write(
const Array<std::complex<float> >& v);
904 void low_level_write(
const Array<std::complex<double> >& v);
910 void remove(
const std::string& name);
912 bool exists(
const std::string& name);
920 void write_data_header_here(
const data_header& h);
929 std::string _next_name;
930 String_Holder():_next_name(
""){}
932 String_Holder* _string;
972ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f,
char& v);
975ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, bin& v);
978ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f,
short& v);
981ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f,
int& v);
984ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f,
float& v);
987ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f,
double& v);
990ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, std::complex<float>& v);
993ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, std::complex<double>& v);
996ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, vec& v);
999ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, ivec& v);
1002ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, bvec& v);
1005ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, cvec& v);
1008ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, std::string& str);
1011ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, mat& m);
1014ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, imat& m);
1020ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, cmat& m);
1023ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<float>& v);
1026ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<double>& v);
1029ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<int>& v);
1032ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<bin>& v);
1035ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<std::complex<float> >& v);
1038ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<std::complex<double> >& v);
1041ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<vec>& v);
1044ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<ivec>& v);
1047ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<bvec>& v);
1050ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<cvec>& v);
1053ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<std::string>& v);
1056ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<mat>& v);
1059ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<imat>& v);
1062ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<bmat>& v);
1065ITPP_EXPORT it_ifile_old&
operator>>(it_ifile_old& f, Array<cmat>& v);
1069ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
char x);
1072ITPP_EXPORT it_file_old&
operator<<(it_file_old& f, bin x);
1075ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
short x);
1078ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
int x);
1081ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
float x);
1084ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
double x);
1087ITPP_EXPORT it_file_old&
operator<<(it_file_old& f, std::complex<float> x);
1090ITPP_EXPORT it_file_old&
operator<<(it_file_old& f, std::complex<double> x);
1093ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const vec& v);
1096ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const ivec& v);
1099ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const bvec& v);
1102ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const cvec& v);
1105ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const std::string& str);
1108ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const mat& m);
1111ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const imat& m);
1114ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const bmat& m);
1117ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const cmat& m);
1120ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<float>& v);
1123ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<double>& v);
1126ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<int>& v);
1129ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<bin>& v);
1132ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<std::complex<float> >& v);
1135ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<std::complex<double> >& v);
1138ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<vec>& v);
1141ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<ivec>& v);
1144ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<bvec>& v);
1147ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<cvec>& v);
1150ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<std::string>& v);
1153ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<mat>& v);
1156ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<imat>& v);
1159ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<bmat>& v);
1162ITPP_EXPORT it_file_old&
operator<<(it_file_old& f,
const Array<cmat>& v);
Definition of Array class (container)
Binary file formats definitions.
Automatic naming when saving.
Name & operator=(const Name &)
Dummy assignment operator - MSVC++ warning C4512.
const std::string & name
The name string.
Name(const std::string &n, const std::string &d="")
Constructor.
const std::string & desc
The description.
Binary in/out-file Class.
Binary arithmetic (boolean) class.
Base class for it_ifile_old and it_file_old.
static char file_version
ACTION: Add documentation.
static char file_magic[4]
ACTION: Add documentation.
Base class for it_ifile and it_file.
static char file_magic[4]
IT++ file marker: "IT++".
static char file_version
IT++ file version.
The old (version 2) IT++ file format reading and writing class.
bool low_prec
ACTION: Add documenation for this protected member.
it_file_old & operator<<(it_manip func)
ACTION: ADD DOCUMENTATION FOR THIS MEMBER !!!!!!!!
void flush()
Flush the data to disk.
bool get_low_precision()
Get the precision.
void set_next_name(const std::string &n)
Set the name of the next name to be saved. See also the Name class.
it_file_old()
Constructor.
std::string & next_name()
ACTION: Add documenation for this protected member.
it_file_old &(* it_manip)(it_file_old &)
ACTION: Add documentation for this typedef.
void set_low_precision(bool p=true)
Set the precision. Low precision means floats, high means doubles.
virtual ~it_file_old()
Destructor.
bfstream & low_level()
Returns pointer to the underlying bfstream used.
The IT++ file format reading and writing class.
void flush()
Flush the data to disk.
bool get_low_precision() const
Get the precision.
void set_low_precision(bool p=true)
Set the precision. Low precision means floats, high means doubles.
std::string & next_name()
Name to be used for saving the next variable.
void close()
Close the file.
std::string & next_desc()
Description to be used for saving the next variable.
it_file &(* it_manip)(it_file &)
ACTION: Add documentation for this typedef.
virtual ~it_file()
Destructor.
void set_next_name(const std::string &name, const std::string &description="")
Set the name and optionally description of the next variable to be saved.
it_file & operator<<(it_manip func)
ACTION: ADD DOCUMENTATION FOR THIS MEMBER !!!!!!!!
bfstream & low_level()
Returns pointer to the underlying bfstream used.
bool low_prec
Low precision flag. If true, use float type, otherwise double.
it_file()
Default constructor.
The old (version 2) IT++ file format reading class.
bool seek(const std::string &name)
Find the variable name.
it_ifile_old()
Constructor.
virtual ~it_ifile_old()
Destructor.
bfstream & low_level()
Returns pointer to the underlying bfstream used.
bfstream s
Protected binary file stream.
The IT++ file format reading class.
bool seek(const std::string &name)
Find the variable name.
virtual void close()
Close the file.
bfstream & low_level()
Returns pointer to the underlying bfstream used.
virtual ~it_ifile()
Destructor.
bfstream s
Protected binary file stream.
it_ifile()
Default constructor.
void it_load_var_as(T &v, const std::string &name)
Load the variable v from the file name.it as the name name.
void it_save_var_as(const T &v, const std::string &name)
Save the variable v in the file name.it as the name name.
it_file & flush(it_file &f)
Flush operator.
int size(const Vec< T > &v)
Length of vector.
Mat< bin > bmat
bin matrix
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Templated Vector Class Definitions.