diff --git a/cwCsv.cpp b/cwCsv.cpp index ee302d5..646032e 100644 --- a/cwCsv.cpp +++ b/cwCsv.cpp @@ -490,6 +490,12 @@ cw::rc_t cw::csv::field_char_count( handle_t h, unsigned colIdx, unsigned& charC return rc; } +cw::rc_t cw::csv::parse_field( handle_t h, unsigned colIdx, uint8_t& valRef ) +{ + csv_t* p = _handleToPtr(h); + return _parse_number_field( p, colIdx, valRef ) ; +} + cw::rc_t cw::csv::parse_field( handle_t h, unsigned colIdx, unsigned& valRef ) { csv_t* p = _handleToPtr(h); @@ -514,6 +520,12 @@ cw::rc_t cw::csv::parse_field( handle_t h, unsigned colIdx, const char*& valRef return _parse_string_field( p, colIdx, valRef ); } +cw::rc_t cw::csv::parse_field( handle_t h, const char* colLabel, uint8_t& valRef ) +{ + csv_t* p = _handleToPtr(h); + return _parse_number_field(p, colLabel, valRef ); +} + cw::rc_t cw::csv::parse_field( handle_t h, const char* colLabel, unsigned& valRef ) { csv_t* p = _handleToPtr(h); diff --git a/cwCsv.h b/cwCsv.h index 3da8978..f657862 100644 --- a/cwCsv.h +++ b/cwCsv.h @@ -32,20 +32,28 @@ namespace cw // This function return kEofRC when it increments past the last line in the file. rc_t next_line( handle_t h ); - // line index (first line==0) of the line currently being parsed. + // line index (first line==0) of the line currently bei[ng parsed. unsigned cur_line_index( handle_t h ); // Return the count of characters in the field identified by 'colIdx'. rc_t field_char_count( handle_t h, unsigned colIdx, unsigned& charCntRef ); + rc_t parse_field( handle_t h, unsigned colIdx, uint8_t& valRef ); rc_t parse_field( handle_t h, unsigned colIdx, unsigned& valRef ); rc_t parse_field( handle_t h, unsigned colIdx, int& valRef ); rc_t parse_field( handle_t h, unsigned colIdx, double& valRef ); + + // The returned pointer is a pointer into an internal 'line' buffer. + // The reference is therefore only valid until the next call to next_line(). rc_t parse_field( handle_t h, unsigned colIdx, const char*& valRef ); + rc_t parse_field( handle_t h, const char* colLabel, uint8_t& valRef ); rc_t parse_field( handle_t h, const char* colLabel, unsigned& valRef ); rc_t parse_field( handle_t h, const char* colLabel, int& valRef ); rc_t parse_field( handle_t h, const char* colLabel, double& valRef ); + + // The returned pointer is a pointer into an internal 'line' buffer. + // The reference is therefore only valid until the next call to next_line(). rc_t parse_field( handle_t h, const char* colLabel, const char*& valRef ); inline rc_t _getv(handle_t) { return kOkRC; }