GDAL

cpl_csv.h
1/******************************************************************************
2 * $Id$
3 *
4 * Project: Common Portability Library
5 * Purpose: Functions for reading and scanning CSV (comma separated,
6 * variable length text files holding tables) files.
7 * Author: Frank Warmerdam, warmerdam@pobox.com
8 *
9 ******************************************************************************
10 * Copyright (c) 1999, Frank Warmerdam
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 ****************************************************************************/
30
31#ifndef CPL_CSV_H_INCLUDED
32#define CPL_CSV_H_INCLUDED
33
34#include <stdio.h>
35
36#include "cpl_conv.h"
37#include "cpl_string.h"
38#include "cpl_vsi.h"
39#include <stdbool.h>
40
41 CPL_C_START
42
43 typedef enum
44{
45 CC_ExactString,
46 CC_ApproxString,
47 CC_Integer
48} CSVCompareCriteria;
49
50 const char CPL_DLL *CSVFilename(const char *);
51
52 char CPL_DLL CSVDetectSeperator(const char *pszLine);
53
54 char CPL_DLL **CSVReadParseLine(FILE *fp);
55 char CPL_DLL **CSVReadParseLine2(FILE *fp, char chDelimiter);
56
57 char CPL_DLL **CSVReadParseLineL(VSILFILE *fp);
58 char CPL_DLL **CSVReadParseLine2L(VSILFILE *fp, char chDelimiter);
59
60 char CPL_DLL **CSVReadParseLine3L(VSILFILE *fp, size_t nMaxLineSize,
61 const char *pszDelimiter, bool bHonourStrings,
62 bool bKeepLeadingAndClosingQuotes,
63 bool bMergeDelimiter, bool bSkipBOM);
64
65 char CPL_DLL **CSVScanLines(FILE *, int, const char *, CSVCompareCriteria);
66 char CPL_DLL **CSVScanLinesL(VSILFILE *, int, const char *, CSVCompareCriteria);
67 char CPL_DLL **CSVScanFile(const char *, int, const char *, CSVCompareCriteria);
68 char CPL_DLL **CSVScanFileByName(const char *, const char *, const char *,
69 CSVCompareCriteria);
70 void CPL_DLL CSVRewind(const char *);
71 char CPL_DLL **CSVGetNextLine(const char *);
72 int CPL_DLL CSVGetFieldId(FILE *, const char *);
73 int CPL_DLL CSVGetFieldIdL(VSILFILE *, const char *);
74 int CPL_DLL CSVGetFileFieldId(const char *, const char *);
75
76 void CPL_DLL CSVDeaccess(const char *);
77
78 const char CPL_DLL *CSVGetField(const char *, const char *, const char *,
79 CSVCompareCriteria, const char *);
80
81#ifndef DOXYGEN_XML
82 void CPL_DLL SetCSVFilenameHook(const char *(*)(const char *));
83#endif
84
85 CPL_C_END
86
87#endif /* ndef CPL_CSV_H_INCLUDED */
cpl_conv.h
Various convenience functions for CPL.
CPL_C_END
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:299
CPL_C_START
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:295
cpl_string.h
Various convenience functions for working with strings and string lists.
cpl_vsi.h
Standard C Covers.
VSIVirtualHandle
Virtual file handle.
Definition cpl_vsi_virtual.h:63