PartialCsvParser  0.1.2
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PCP::Memory::CsvConfig Class Reference

Parses CSV from memory. More...

#include <PartialCsvParser.hpp>

Inheritance diagram for PCP::Memory::CsvConfig:
PCP::CsvConfig

Public Member Functions

 CsvConfig (const char *const str_with_null_terminator, bool has_header_line=true, char field_terminator= ',', char line_terminator= '\n', bool _lazy_initialization=false)
 Constructor to parse CSV from null-terminated C string. More...
 
 CsvConfig (size_t str_length, const char *const str, bool has_header_line=true, char field_terminator= ',', char line_terminator= '\n')
 Constructor to parse CSV from string with length. More...
 
virtual ~CsvConfig ()
 
size_t filesize () const
 Return the size of CSV from file. More...
 
const char *const content () const
 Return the pointer of CSV content. More...
 
size_t get_n_columns () const
 Return the number of columns in first line. More...
 
size_t body_offset () const
 Return the offset where CSV body (excluding header line) starts from. More...
 
std::vector< std::string > get_headers () const
 Return header string array. More...
 
const char get_field_terminator () const
 Return a character to separate columns. More...
 
const char get_line_terminator () const
 Return a character to separate rows. More...
 

Protected Member Functions

void init ()
 

Protected Attributes

const bool has_header_line
 
const char field_terminator
 
const char line_terminator
 
size_t csv_size
 
const char * csv_text
 
std::vector< std::string > headers
 
size_t header_length
 
size_t n_columns
 

Detailed Description

Parses CSV from memory.

Constructor & Destructor Documentation

PCP::Memory::CsvConfig::CsvConfig ( const char *const  str_with_null_terminator,
bool  has_header_line = true,
char  field_terminator = ',',
char  line_terminator = '\n',
bool  _lazy_initialization = false 
)
inline

Constructor to parse CSV from null-terminated C string.

Parameters
str_with_null_terminatorCSV string terminated with '\0'.
has_header_lineIf CSV file has header at first line, set true.
field_terminatorCharacter to separate columns. For UTF-8 compatibility, only 0 ~ 127 are allowed.
line_terminatorCharacter to separate rows. For UTF-8 compatibility, only 0 ~ 127 are allowed.
_lazy_initializationAlways set false.
PCP::Memory::CsvConfig::CsvConfig ( size_t  str_length,
const char *const  str,
bool  has_header_line = true,
char  field_terminator = ',',
char  line_terminator = '\n' 
)
inline

Constructor to parse CSV from string with length.

Parameters
str_lengthLength of str.
strCSV string, which is not necessarily terminated with '\0'.
has_header_lineIf CSV file has header at first line, set true.
field_terminatorCharacter to separate columns. For UTF-8 compatibility, only 0 ~ 127 are allowed.
line_terminatorCharacter to separate rows. For UTF-8 compatibility, only 0 ~ 127 are allowed.
virtual PCP::Memory::CsvConfig::~CsvConfig ( )
inlinevirtual

Reimplemented in PCP::CsvConfig.

Member Function Documentation

size_t PCP::Memory::CsvConfig::body_offset ( ) const
inline

Return the offset where CSV body (excluding header line) starts from.

const char* const PCP::Memory::CsvConfig::content ( ) const
inline

Return the pointer of CSV content.

size_t PCP::Memory::CsvConfig::filesize ( ) const
inline

Return the size of CSV from file.

const char PCP::Memory::CsvConfig::get_field_terminator ( ) const
inline

Return a character to separate columns.

std::vector<std::string> PCP::Memory::CsvConfig::get_headers ( ) const
inline

Return header string array.

has_header_line flag must be set true in constructor.

const char PCP::Memory::CsvConfig::get_line_terminator ( ) const
inline

Return a character to separate rows.

size_t PCP::Memory::CsvConfig::get_n_columns ( ) const
inline

Return the number of columns in first line.

void PCP::Memory::CsvConfig::init ( )
inlineprotected

Member Data Documentation

size_t PCP::Memory::CsvConfig::csv_size
protected
const char* PCP::Memory::CsvConfig::csv_text
protected
const char PCP::Memory::CsvConfig::field_terminator
protected
const bool PCP::Memory::CsvConfig::has_header_line
protected
size_t PCP::Memory::CsvConfig::header_length
protected
std::vector<std::string> PCP::Memory::CsvConfig::headers
protected
const char PCP::Memory::CsvConfig::line_terminator
protected
size_t PCP::Memory::CsvConfig::n_columns
protected

The documentation for this class was generated from the following file: