GDAL
cpl_csv.h
1/******************************************************************************
2 *
3 * Project: Common Portability Library
4 * Purpose: Functions for reading and scanning CSV (comma separated,
5 * variable length text files holding tables) files.
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1999, Frank Warmerdam
10 *
11 * SPDX-License-Identifier: MIT
12 ****************************************************************************/
13
14#ifndef CPL_CSV_H_INCLUDED
15#define CPL_CSV_H_INCLUDED
16
17#include <stdio.h>
18
19#include "cpl_conv.h"
20#include "cpl_string.h"
21#include "cpl_vsi.h"
22#include <stdbool.h>
23
25
26typedef enum
27{
28 CC_ExactString,
29 CC_ApproxString,
30 CC_Integer
31} CSVCompareCriteria;
32
33const char CPL_DLL *CSVFilename(const char *);
34
35char CPL_DLL CSVDetectSeperator(const char *pszLine);
36
37char CPL_DLL **CSVReadParseLine(FILE *fp);
38char CPL_DLL **CSVReadParseLine2(FILE *fp, char chDelimiter);
39
40char CPL_DLL **CSVReadParseLineL(VSILFILE *fp);
41char CPL_DLL **CSVReadParseLine2L(VSILFILE *fp, char chDelimiter);
42
43char CPL_DLL **CSVReadParseLine3L(VSILFILE *fp, size_t nMaxLineSize,
44 const char *pszDelimiter, bool bHonourStrings,
45 bool bKeepLeadingAndClosingQuotes,
46 bool bMergeDelimiter, bool bSkipBOM);
47
48char CPL_DLL **CSVScanLines(FILE *, int, const char *, CSVCompareCriteria);
49char CPL_DLL **CSVScanLinesL(VSILFILE *, int, const char *, CSVCompareCriteria);
50char CPL_DLL **CSVScanFile(const char *, int, const char *, CSVCompareCriteria);
51char CPL_DLL **CSVScanFileByName(const char *, const char *, const char *,
52 CSVCompareCriteria);
53void CPL_DLL CSVRewind(const char *);
54char CPL_DLL **CSVGetNextLine(const char *);
55int CPL_DLL CSVGetFieldId(FILE *, const char *);
56int CPL_DLL CSVGetFieldIdL(VSILFILE *, const char *);
57int CPL_DLL CSVGetFileFieldId(const char *, const char *);
58
59void CPL_DLL CSVDeaccess(const char *);
60
61const char CPL_DLL *CSVGetField(const char *, const char *, const char *,
62 CSVCompareCriteria, const char *);
63
64#ifndef DOXYGEN_XML
65void CPL_DLL SetCSVFilenameHook(const char *(*)(const char *));
66#endif
67
69
70#endif /* ndef CPL_CSV_H_INCLUDED */
Various convenience functions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
Various convenience functions for working with strings and string lists.
Standard C Covers.
struct VSIVirtualHandle VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition cpl_vsi.h:141