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