forked from modelica/Reference-FMUs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsv.h
55 lines (45 loc) · 1.29 KB
/
csv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* (c) 2019 Jan Doczy
* This code is licensed under MIT license (see LICENSE.txt for details) */
/* simple and fast CSV reader:
* 1. Open CSV file by calling CsvOpen("filename.csv")
* 2. Read CSV row by calling CsvReadNextRow(csv_handle)
* 3. Read single CSV line column by calling CsvReadNextCol(returned_row_str, csv_handle)
*/
#ifndef CSV_H_INCLUDED
#define CSV_H_INCLUDED
#ifdef __cplusplus
extern "C" { /* C++ name mangling */
#endif
/* pointer to private handle structure */
typedef struct CsvHandle_ *CsvHandle;
/**
* openes csv file
* @filename: pathname of the file
* @return: csv handle
* @notes: you should call CsvClose() to release resources
*/
CsvHandle CsvOpen(const char* filename);
CsvHandle CsvOpen2(const char* filename,
char delim,
char quote,
char escape);
/**
* closes csv handle, releasing all resources
* @handle: csv handle
*/
void CsvClose(CsvHandle handle);
/**
* reads (first / next) line of csv file
* @handle: csv handle
*/
char* CsvReadNextRow(CsvHandle handle);
/**
* get column of file
* @row: csv row (you can use CsvReadNextRow() to parse next line)
* @context: handle returned by CsvOpen() or CsvOpen2()
*/
const char* CsvReadNextCol(char* row, CsvHandle handle);
#ifdef __cplusplus
};
#endif
#endif