|
libcsv v0.1.0
|
#include <stdio.h>

Go to the source code of this file.
Classes | |
| struct | CSVRow |
| Structure representing a single CSV row. More... | |
| struct | CSVParser |
| Structure managing the state of a CSV file parser. More... | |
Enumerations | |
| enum | CSVError { CSV_SUCCESS , CSV_ERROR_MEMORY , CSV_ERROR_FILE_OPEN , CSV_ERROR_INVALID_ARG } |
| Error codes returned by library operations. More... | |
Functions | |
| CSVParser * | csv_parser_create (const char *filename, char delimiter) |
| Creates and initializes a parser to read a CSV file. | |
| void | csv_parser_destroy (CSVParser *parser) |
| Frees resources associated with the parser and closes the open file. | |
| CSVRow * | csv_read_row (CSVParser *parser) |
| Reads the next row from the CSV file using the parser. | |
| CSVRow * | csv_row_create (int field_count, const char **fields) |
| Manually creates and allocates a CSVRow structure from an array of strings. | |
| void | csv_row_destroy (CSVRow *row) |
| Frees memory allocated for a CSVRow structure and all its internal fields. | |
| CSVRow * | csv_parse_string (const char *csv_string, char delimiter) |
| Parses an individual CSV-formatted string into a CSVRow structure. | |
| char * | csv_write_string (const CSVRow *row, char delimiter) |
| Converts a CSVRow structure into a single formatted string. | |
| int | csv_write_file (const CSVRow *row, const char *filename, char delimiter) |
| Writes the contents of a CSVRow directly to a file. | |
| char * | csv_get_field (const CSVRow *row, int field_index) |
| Retrieves the value of a specific field in a row by its index. | |
| void | csv_set_delimiter (CSVParser *parser, char new_delimiter) |
| Updates the delimiter character used by an active parser. | |
| char | csv_get_delimiter (const CSVParser *parser) |
| Gets the current delimiter configured for the parser. | |
| const char * | csv_error_message (CSVError error) |
| Returns a human-readable message corresponding to an error code. | |
| CSVError | csv_get_last_error (void) |
| Gets the last error code produced by the library on the calling thread. | |
| enum CSVError |
| const char * csv_error_message | ( | CSVError | error | ) |
Returns a human-readable message corresponding to an error code.
| error | The CSVError code. |
| char csv_get_delimiter | ( | const CSVParser * | parser | ) |
Gets the current delimiter configured for the parser.
| parser | Pointer to the CSVParser instance. |
| char * csv_get_field | ( | const CSVRow * | row, |
| int | field_index | ||
| ) |
Retrieves the value of a specific field in a row by its index.
| row | Pointer to the CSV row structure. |
| field_index | Zero-based index of the target field. |
| CSVError csv_get_last_error | ( | void | ) |
Gets the last error code produced by the library on the calling thread.
| CSVRow * csv_parse_string | ( | const char * | csv_string, |
| char | delimiter | ||
| ) |
| CSVParser * csv_parser_create | ( | const char * | filename, |
| char | delimiter | ||
| ) |
Creates and initializes a parser to read a CSV file.
| filename | Path to the CSV file to be opened. |
| delimiter | Field delimiter character. |
| void csv_parser_destroy | ( | CSVParser * | parser | ) |
Frees resources associated with the parser and closes the open file.
| parser | Pointer to the CSVParser structure to destroy. |
| CSVRow * csv_row_create | ( | int | field_count, |
| const char ** | fields | ||
| ) |
| void csv_row_destroy | ( | CSVRow * | row | ) |
| void csv_set_delimiter | ( | CSVParser * | parser, |
| char | new_delimiter | ||
| ) |
Updates the delimiter character used by an active parser.
| parser | Pointer to the CSVParser instance. |
| new_delimiter | New delimiter character to set. |
| int csv_write_file | ( | const CSVRow * | row, |
| const char * | filename, | ||
| char | delimiter | ||
| ) |
Writes the contents of a CSVRow directly to a file.
| row | Pointer to the row to write. |
| filename | Path to the output destination file. |
| delimiter | Field delimiter character. |
| char * csv_write_string | ( | const CSVRow * | row, |
| char | delimiter | ||
| ) |
Converts a CSVRow structure into a single formatted string.
| row | Pointer to the CSV row structure. |
| delimiter | Character to place between fields. |