Skip to content

Commit

Permalink
export some csv function
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 9, 2023
1 parent a0b08f0 commit f5972bc
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion src/csv/csv_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,82 @@ ret_t csv_file_load_file(csv_file_t* csv, const char* filename);
*/
ret_t csv_file_destroy(csv_file_t* csv);

/*public for test*/
/**
* @method csv_file_get_by_name
*
* 根据列名获取数据。
*
* @param {csv_file_t*} csv csv对象。
* @param {uint32_t} row 行号。
* @param {const char*} name 列名。
*
* @return {const char*} 返回数据。
*/
const char* csv_file_get_by_name(csv_file_t* csv, uint32_t row, const char* name);

/**
* @method csv_file_get_col_of_name
*
* 根据列名获取列号。
*
* @param {csv_file_t*} csv csv对象。
* @param {const char*} name 列名。
*
* @return {int32_t} 返回列号。
*/
int32_t csv_file_get_col_of_name(csv_file_t* csv, const char* name);

/**
* @method csv_file_get_row
*
* 获取指定行。
*
* @param {csv_file_t*} csv csv对象。
* @param {uint32_t} row 行号。
*
* @return {csv_row_t*} 返回行对象。
*/
csv_row_t* csv_file_get_row(csv_file_t* csv, uint32_t row);

/**
* @class csv_row_t
* 行对象。
*/

/**
* @method csv_row_count_cols
* 获取列数。
* @param {csv_row_t*} row 行对象。
* @return {uint32_t} 返回列数。
*/
uint32_t csv_row_count_cols(csv_row_t* row);

/**
* @method csv_row_get
*
* 获取指定列的数据。
*
* @param {csv_row_t*} row 行对象。
* @param {uint32_t} col 列号。
*
* @return {const char*} 返回数据。
*/
const char* csv_row_get(csv_row_t* row, uint32_t col);

/**
* @method csv_row_set
*
* 修改指定列的数据。
*
* @param {csv_row_t*} row 行对象。
* @param {uint32_t} col 列号。
* @param {const char*} value 值。
*
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
*/
ret_t csv_row_set(csv_row_t* row, uint32_t col, const char* value);

/*public for test*/
ret_t csv_row_init(csv_row_t* row, char* buff, uint32_t size, bool_t should_free_buff);
ret_t csv_row_reset(csv_row_t* row);

Expand Down

0 comments on commit f5972bc

Please sign in to comment.