ZEDA  1.6.18
zeda_csv.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
12 #ifndef __ZEDA_CSV_H__
13 #define __ZEDA_CSV_H__
14 
15 #include <zeda/zeda_string.h>
16 
17 #ifndef __KERNEL__
18 
20 
21 /* ********************************************************** *//* ************************************************** */
24 
25 /* ********************************************************** *//* ******************************************************* */
31 typedef struct{
32  FILE *fp;
33  int nl;
34  long *pos;
35  int nf;
36  char buf[BUFSIZ];
37 } zCSV;
38 
40 #define zCSVLineNum(csv) (csv)->nl
41 
43 __EXPORT zCSV *zCSVOpen(zCSV *csv, char filename[]);
44 
46 __EXPORT void zCSVClose(zCSV *csv);
47 
49 __EXPORT void zCSVRewind(zCSV *csv);
50 
52 #define zCSVIsEOF(csv) feof( (csv)->fp )
53 
55 #define zCSVLineIsEmpty(csv) ( (csv)->buf[0] == '\0' )
56 
58 __EXPORT char *zCSVGetLine(zCSV *csv);
59 
61 __EXPORT char *zCSVGoToLine(zCSV *csv, int i);
62 
64 __EXPORT char *zCSVGetField(zCSV *csv, char *field, size_t size);
66 __EXPORT char *zCSVSkipField(zCSV *csv);
67 
69 __EXPORT bool zCSVGetInt(zCSV *csv, int *val);
71 __EXPORT bool zCSVGetIntN(zCSV *csv, int val[], int n);
72 
74 __EXPORT bool zCSVGetDouble(zCSV *csv, double *val);
76 __EXPORT bool zCSVGetDoubleN(zCSV *csv, double val[], int n);
77 
81 
82 #endif /* __KERNEL__ */
83 
84 #endif /* __ZEDA_CSV_H__ */
char * zCSVGoToLine(zCSV *csv, int i)
go to a specified line in a CSV file.
long * pos
Definition: zeda_csv.h:34
int nl
Definition: zeda_csv.h:33
CSV manager class.
Definition: zeda_csv.h:31
#define __END_DECLS
Definition: zeda_defs.h:30
bool zCSVGetDoubleN(zCSV *csv, double val[], int n)
get multiple double-precision floating-point values from the current buffer of a CSV file...
#define BUFSIZ
default buffer size.
Definition: zeda_defs.h:56
char * zCSVGetLine(zCSV *csv)
get a line from the current stream of a CSV file.
bool zCSVGetDouble(zCSV *csv, double *val)
get a double-precision floating-point value from the current buffer of a CSV file.
int nf
Definition: zeda_csv.h:35
FILE * fp
Definition: zeda_csv.h:32
zCSV * zCSVOpen(zCSV *csv, char filename[])
open a CSV file.
bool zCSVGetIntN(zCSV *csv, int val[], int n)
get multiple integer values from the current buffer of a CSV file.
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
char * zCSVSkipField(zCSV *csv)
skip a field from the current buffer of a CSV file.
void zCSVRewind(zCSV *csv)
rewind the stream of a CSV file.
string manipulations.
void zCSVClose(zCSV *csv)
close a CSV file.
#define __EXPORT
Definition: zeda_compat.h:32
char * zCSVGetField(zCSV *csv, char *field, size_t size)
get a field from the current buffer of a CSV file.
bool zCSVGetInt(zCSV *csv, int *val)
get an integer value from the current buffer of a CSV file.