cwCsv.h/cpp: Added parse_field( ..., uint8_t )

This commit is contained in:
kevin 2023-07-25 20:19:59 -04:00
parent daa990944f
commit 7201b63412
2 changed files with 21 additions and 1 deletions

View File

@ -490,6 +490,12 @@ cw::rc_t cw::csv::field_char_count( handle_t h, unsigned colIdx, unsigned& charC
return rc; 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 ) cw::rc_t cw::csv::parse_field( handle_t h, unsigned colIdx, unsigned& valRef )
{ {
csv_t* p = _handleToPtr(h); 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 ); 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 ) cw::rc_t cw::csv::parse_field( handle_t h, const char* colLabel, unsigned& valRef )
{ {
csv_t* p = _handleToPtr(h); csv_t* p = _handleToPtr(h);

10
cwCsv.h
View File

@ -32,20 +32,28 @@ namespace cw
// This function return kEofRC when it increments past the last line in the file. // This function return kEofRC when it increments past the last line in the file.
rc_t next_line( handle_t h ); 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 ); unsigned cur_line_index( handle_t h );
// Return the count of characters in the field identified by 'colIdx'. // 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 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, unsigned& valRef );
rc_t parse_field( handle_t h, unsigned colIdx, int& valRef ); rc_t parse_field( handle_t h, unsigned colIdx, int& valRef );
rc_t parse_field( handle_t h, unsigned colIdx, double& 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, 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, unsigned& valRef );
rc_t parse_field( handle_t h, const char* colLabel, int& 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 ); 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 ); rc_t parse_field( handle_t h, const char* colLabel, const char*& valRef );
inline rc_t _getv(handle_t) { return kOkRC; } inline rc_t _getv(handle_t) { return kOkRC; }