24 #ifndef ASLABDFORMAT_H
25 #define ASLABDFORMAT_H
34 #include <data/aslDataWrapper.h>
49 class ABDFileIn:
public std::ifstream{
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);
ABD (ASL Binary Dump) file, input.
ABDFileIn & get(ABDFileIn &f, AbstractData &a, std::shared_ptr< double > d)
reads data. It is assumed that the class has the propper size
ABD (ASL Binary Dump) file, output.
Advanced Simulation Library.
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, int &a)
ABDFileOut & operator<<(ABDFileOut &f, const AVec< T > &a)
ABDFileIn & operator>>(ABDFileIn &f, AVec< T > &a)