24 #ifndef ASLABDFORMAT_H 25 #define ASLABDFORMAT_H 34 #include <data/aslDataWrapper.h> 49 class ABDFileIn:
public std::ifstream{
52 inline ABDFileIn(
string name);
59 class ABDFileOut:
public std::ofstream{
62 inline ABDFileOut(
string name);
72 inline ABDFileOut &
operator <<(ABDFileOut & f,
const int a);
74 inline ABDFileIn &
operator >>(ABDFileIn & f,
int & a);
76 inline ABDFileOut &
operator <<(ABDFileOut & f,
const unsigned int a);
78 inline ABDFileIn &
operator >>(ABDFileIn & f,
unsigned int & a);
80 inline ABDFileOut &
operator <<(ABDFileOut & f,
const float a);
82 inline ABDFileIn &
operator >>(ABDFileIn & f,
float & a);
84 inline ABDFileOut &
operator <<(ABDFileOut & f,
const double a);
86 inline ABDFileIn &
operator >>(ABDFileIn & f,
double & a);
90 template <
typename T>
inline ABDFileOut & operator <<(ABDFileOut & f,pair<T*, unsigned int> a);
92 template <
typename T>
inline ABDFileIn &
operator >>(ABDFileIn & f,pair<T*, unsigned int> a);
95 inline ABDFileOut &
operator <<(ABDFileOut & f,
const string &a);
97 inline ABDFileIn &
operator >>(ABDFileIn & f,
string &a);
100 template <
typename T>
inline ABDFileOut & operator <<(ABDFileOut & f, const AVec<T> & a);
102 template <
typename T>
inline ABDFileIn &
operator >>(ABDFileIn & f,AVec<T> & a);
107 ABDFileOut &
operator <<(ABDFileOut & f,
const Block &a);
117 ABDFileOut &
operator <<(ABDFileOut & f,
const AbstractData &a);
123 ABDFileIn &
operator >>(ABDFileIn & f, AbstractData &a);
137 void writeABD(
const string &fileName,
const AbstractData & data,
const string & name);
142 ABDFileIn::ABDFileIn():ifstream()
145 ifstream(name,ios::
in | ios::binary)
151 ofstream(name,ios::out | ios::binary)
154 inline ABDFileOut &
operator <<(ABDFileOut & f,
const int a)
156 f.write((
char*)&a,
sizeof(
int));
160 inline ABDFileIn &
operator >>(ABDFileIn & f,
int & a)
162 f.read((
char*)&a,
sizeof(
int));
166 inline ABDFileOut &
operator <<(ABDFileOut & f,
const unsigned int a)
168 f.write((
char*)&a,
sizeof(
unsigned int));
172 inline ABDFileIn &
operator >>(ABDFileIn & f,
unsigned int & a)
174 f.read((
char*)&a,
sizeof(
unsigned int));
178 inline ABDFileOut &
operator <<(ABDFileOut & f,
const float a)
180 f.write((
char*)&a,
sizeof(
float));
184 inline ABDFileIn &
operator >>(ABDFileIn & f,
float & a)
186 f.read((
char*)&a,
sizeof(
float));
190 inline ABDFileOut &
operator <<(ABDFileOut & f,
const double a)
192 f.write((
char*)&a,
sizeof(
double));
196 inline ABDFileIn &
operator >>(ABDFileIn & f,
double & a)
198 f.read((
char*)&a,
sizeof(
double));
203 template <
typename T>
inline ABDFileOut & operator <<(ABDFileOut & f,pair<T*, unsigned int> a)
205 f.write((
char*)a.first,
sizeof(T)*a.second);
208 template <
typename T>
inline ABDFileIn &
operator >>(ABDFileIn & f,pair<T*, unsigned int> a)
210 f.read((
char*)a.first,
sizeof(T)*a.second);
214 inline ABDFileOut &
operator <<(ABDFileOut & f,
const string &a){
215 unsigned int n=a.size();
216 f<<n<<make_pair(&a[0],n);
220 inline ABDFileIn &
operator >>(ABDFileIn & f,
string &a){
223 f>>make_pair(a.data(),n);
227 template <
typename T>
inline ABDFileOut & operator <<(ABDFileOut & f, const AVec<T> & a)
229 unsigned int n(a.getSize());
230 f<<n<<make_pair(&(a[0]),n);
234 template <
typename T>
inline ABDFileIn &
operator >>(ABDFileIn & f,AVec<T> & a)
239 f>>make_pair(&(a[0]),n);
246 #endif //ASLVTKFORMAT_H Advanced Simulation Library.
ABDFileOut & operator<<(ABDFileOut &f, const AVec< T > &a)
bool in(const T &xx, const T &x1, const T &x2)
Checks the belonging to a closed interval [x1,x2], .
std::ostream & operator<<(std::ostream &output, const std::vector< T > &vector)
Prints elements of the vector separated by space.
ABDFileIn & operator>>(ABDFileIn &f, AVec< T > &a)
ABDFileIn & operator>>(ABDFileIn &f, int &a)