4 #include "ester-config.h"
16 void open(
int argc_in,
char *argv_in[]);
17 int get(
char *&arg,
char *&val);
18 void ack(
char *arg,
char *val);
27 int open(
const char *file);
28 int get(
char *&arg,
char *&val);
35 void write_tag(
const char *tag,
unsigned long n);
37 int open(
const char *name,
char mode=
'b');
43 void write(
const char *tag,T *x,
unsigned long n=1) {
44 size_t size=
sizeof(T);
46 if(
typeid(x[0])==
typeid(char))
write_tag(tag,1);
50 std::stringstream temp;
52 temp.setf(std::ios::scientific, std::ios::floatfield);
53 for(
unsigned long i=0;i<n;i++) {
56 temp<<x[i]<<std::endl;
58 fprintf(
fp,
"%s",str.c_str());
59 if(
typeid(x[i])!=
typeid(char)||i==n-1) fprintf(
fp,
"\n");
61 }
else fwrite(x,size,n,
fp);
64 void write_fmt(
const char *tag,
const char *fmt,T *x,
unsigned long n=1) {
66 for(
unsigned long i=0;i<n;i++) {
77 unsigned long seek(
const char *tag);
80 int open(
const char *name,
char mode=
'b');
81 unsigned long len(
const char *tag);
85 int read(
const char *tag,T *x) {
86 unsigned long n=
seek(tag);
90 if(
typeid(x[0])==
typeid(
char)) {
92 strcpy((
char *)x,str);
94 for(
unsigned long i=0;i<n;i++) {
96 std::stringstream temp(str);
101 else if(n!=fread(x,1,n,
fp))
return 1;
105 int read_fmt(
const char *tag,
const char *fmt,T *x) {
106 unsigned long n=
seek(tag);
108 for(
unsigned long i=0;i<n;i++)
109 if(!fscanf(
fp,fmt,&x[i]))
return 0;
char mode
Definition: parser.h:34
char ** argv
Definition: parser.h:14
void close()
Definition: iofile.cpp:143
void write(const char *tag, T *x, unsigned long n=1)
Definition: parser.h:43
void write_tag(const char *tag, unsigned long n)
Definition: iofile.cpp:39
int open(const char *name, char mode='b')
Definition: iofile.cpp:109
The matrix class is used to facilitate the work with regular dense matrices.
Definition: matrix.h:9
unsigned long seek(const char *tag)
Definition: iofile.cpp:165
FILE * fp
Definition: parser.h:23
char line[1024]
Definition: parser.h:25
void write(const char *tag, matrix_map *m)
Definition: parser.h:41
void write(const char *tag, const matrix *)
Definition: iofile.cpp:51
void write(const char *tag, matrix *m)
Definition: parser.h:40
unsigned long len(const char *tag)
Definition: iofile.cpp:207
void close()
Definition: iofile.cpp:33
int read(const char *tag, T *x)
Definition: parser.h:85
void close()
Definition: parser.cpp:57
FILE * fp
Definition: parser.h:75
char * getline(char *, int n)
Definition: iofile.cpp:149
void open(int argc_in, char *argv_in[])
Definition: parser.cpp:8
char mode
Definition: parser.h:76
void write_fmt(const char *tag, const char *fmt, T *x, unsigned long n=1)
Definition: parser.h:64
int iline
Definition: parser.h:24
void close()
Definition: parser.cpp:103
FILE * fp
Definition: parser.h:33
int open(const char *name, char mode='b')
Definition: iofile.cpp:10
int i
Definition: parser.h:13
int open(const char *file)
Definition: parser.cpp:60
int read_fmt(const char *tag, const char *fmt, T *x)
Definition: parser.h:105
void ack(char *arg, char *val)
Definition: parser.cpp:50
int argc
Definition: parser.h:13
int read(const char *tag, matrix *)
Definition: iofile.cpp:213