include/csv_parser/csv_parser.hpp File Reference

#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>

Classes

class  csv_parser

Defines

#define LIBCSV_PARSER_MAJOR_VERSION   1
#define LIBCSV_PARSER_MINOR_VERSION   0
#define LIBCSV_PARSER_PATCH_VERSION   0
#define LIBCSV_PARSER_VERSION_NUMBER   10000
#define CSV_PARSER_FREE_BUFFER_PTR(ptr)
#define CSV_PARSER_FREE_FILE_PTR(fptr)

Typedefs

typedef vector< string > csv_row
typedef csv_rowcsv_row_ptr

Enumerations

enum  enclosure_type_t {
  ENCLOSURE_TYPE_BEGIN = 0, ENCLOSURE_NONE = 1, ENCLOSURE_REQUIRED = 2, ENCLOSURE_OPTIONAL = 3,
  ENCLOSURE_TYPE_END
}

Define Documentation

#define CSV_PARSER_FREE_BUFFER_PTR ( ptr   ) 

Value:

if (ptr != NULL)                                                \
{                                                                               \
        free(ptr);                                                      \
                                                                                \
        ptr = NULL;                                                     \
}
Used to deallocate buffer pointers

It deallocates the pointer only if it is not null

#define CSV_PARSER_FREE_FILE_PTR ( fptr   ) 

Value:

if (fptr != NULL)                                               \
{                                                                               \
        fclose(fptr);                                           \
                                                                                \
        fptr = NULL;                                            \
}
Used to close open file handles

It closes the file only if it is not null

#define LIBCSV_PARSER_MAJOR_VERSION   1

csv_parser Header File

This object is used to parse text documents that are delimited by some type of character. Some of the common ones use spaces, tabs, commas and semi-colons.

This is a list of common characters encountered by this program

This list was prepared from the data from http://www.asciitable.com

  • DEC is how it would be represented in decimal form (base 10)
  • HEX is how it would be represented in hexadecimal format (base 16)
  • DEC HEX Character Name
  • 0 0x00 null
  • 9 0x09 horizontal tab
  • 10 0x0A line feed, new line
  • 13 0x0D carriage return
  • 27 0x1B escape
  • 32 0x20 space
  • 33 0x21 double quote
  • 39 0x27 single quote
  • 44 0x2C comma
  • 92 0x5C backslash
Author:
Israel Ekpo <israel.ekpo@israelekpo.com>

#define LIBCSV_PARSER_MINOR_VERSION   0

#define LIBCSV_PARSER_PATCH_VERSION   0

#define LIBCSV_PARSER_VERSION_NUMBER   10000


Typedef Documentation

Data structure used to represent a record.

This is an alias for vector <string>

Pointer to a csv_row object

Expands to vector <string> *


Enumeration Type Documentation

This enum type is used to set the mode in which the CSV file is parsed.

  • ENCLOSURE_NONE (1) means the CSV file does not use any enclosure characters for the fields
  • ENCLOSURE_REQUIRED (2) means the CSV file requires enclosure characters for all the fields
  • ENCLOSURE_OPTIONAL (3) means the use of enclosure characters for the fields is optional
The ENCLOSURE_TYPE_BEGIN and ENCLOSURE_TYPE_END members of this enum definition are never to be used.
Enumerator:
ENCLOSURE_TYPE_BEGIN 
ENCLOSURE_NONE 
ENCLOSURE_REQUIRED 
ENCLOSURE_OPTIONAL 
ENCLOSURE_TYPE_END 


Generated on Sun Jun 28 21:19:30 2009 for CSV Parser by  doxygen 1.5.5