csvpp 1.2.0
CSV parsing / writing libraries
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
Embedded CSV library

Classes

struct  EMBCSV_reader
 

Macros

#define EMBCSV_FIELD_BUF_SIZE   16
 Field buffer size. Any fields at or over this limit will be truncated.
 

Typedefs

typedef struct EMBCSV_reader EMBCSV_reader
 

Enumerations

enum  EMBCSV_result { EMBCSV_INCOMPLETE , EMBCSV_FIELD , EMBCSV_END_OF_ROW , EMBCSV_PARSE_ERROR }
 Parser result type. More...
 

Functions

EMBCSV_readerEMBCSV_reader_init_full (char delimiter, char quote, bool lenient)
 Create a new EMBCSV_reader.
 
EMBCSV_readerEMBCSV_reader_init (void)
 Create a new EMBCSV_reader with default settings.
 
void EMBCSV_reader_free (EMBCSV_reader *r)
 Free an EMBCSV_reader.
 
EMBCSV_result EMBCSV_reader_parse_char (EMBCSV_reader *r, int c, const char **field_out)
 Parse a character.
 

Detailed Description

CSV parser designed for use in embedded environments.

CSV input is parsed character-by-character, allowing reading from unbuffered input sources.

If malloc is not available or desired, compile with EMBCSV_NO_MALLOC set. The parser will then used a fixed-length buffer internally. This buffers size can be adjusted by setting EMBCSV_FIELD_BUF_SIZE at compilation. Any field exceeding this length will be truncated. The default size is 16. Note that fields will be at most EMBCSV_FIELD_BUF_SIZE - 1 characters due to the null-terminator.

EMBCSV_NO_MALLOC also changes the init function to accept an EMBCSV_reader to initialize rather than allocating a new one

Enumeration Type Documentation

◆ EMBCSV_result

Parser result type.

Enumerator
EMBCSV_INCOMPLETE 

Parsing is incomplete. Parse more characters.

EMBCSV_FIELD 

A field has been parsed.

EMBCSV_END_OF_ROW 

A field has been parsed, and parsing has reached the end of a row.

EMBCSV_PARSE_ERROR 

Syntax error found in input.

Function Documentation

◆ EMBCSV_reader_init()

EMBCSV_reader * EMBCSV_reader_init ( void )

Create a new EMBCSV_reader with default settings.

Equivalent to EMBCSV_reader_init_full(',', '"', false)

Returns
New EMBCSV_reader. Free with EMBCSV_reader_free()

◆ EMBCSV_reader_init_full()

EMBCSV_reader * EMBCSV_reader_init_full ( char delimiter,
char quote,
bool lenient )

Create a new EMBCSV_reader.

Parameters
delimiterDelimiter character
quoteQuote character
lenientEnable lenient parsing (will attempt to read past syntax errors)
Returns
New EMBCSV_reader. Free with EMBCSV_reader_free()

◆ EMBCSV_reader_parse_char()

EMBCSV_result EMBCSV_reader_parse_char ( EMBCSV_reader * r,
int c,
const char ** field_out )

Parse a character.

Parameters
cCharacter to parse
[out]field_outPointer to string, in which will be stored:
Returns
Result of parsing as an EMBCSV_result