257 lines
5.1 KiB
C
257 lines
5.1 KiB
C
#ifndef EASYCSV_H
|
|
#define EASYCSV_H
|
|
|
|
#include "../src/_easycsv.h"
|
|
|
|
/** Public easycsv members */
|
|
typedef struct easycsv {
|
|
EASYCSV_MODE mode;
|
|
_easycsv *_priv;
|
|
} easycsv;
|
|
|
|
/*** Constructors ***/
|
|
|
|
/**
|
|
* Initialise easycsv
|
|
* @param[in] relative path to CSV file
|
|
* @param[in] easycsv mode
|
|
* @return pointer to easycsv structure
|
|
*/
|
|
easycsv*
|
|
easycsv_init(const char*,
|
|
const EASYCSV_MODE);
|
|
|
|
/**
|
|
* Initialise easycsv structure with a given error message mode
|
|
* @param[in] relative path to CSV file
|
|
* @param[in] easycsv mode
|
|
* @param[in] easycsv error message mode
|
|
* @return pointer to easycsv structure
|
|
*/
|
|
easycsv*
|
|
easycsv_init_errormsg(const char*,
|
|
const EASYCSV_MODE,
|
|
const EASYCSV_ERRORMSG);
|
|
|
|
/**
|
|
* Destroy easycsv structure
|
|
* @param[in] Pointer to easycsv stucture
|
|
*/
|
|
void
|
|
easycsv_free(easycsv*);
|
|
|
|
/*** Access ***/
|
|
|
|
/**
|
|
* Find value and returns row and column
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @param[in] value to find
|
|
* @param[out] row number
|
|
* @param[out] column number
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_findvalue(const easycsv*,
|
|
const char*,
|
|
unsigned int*,
|
|
unsigned int*);
|
|
|
|
/**
|
|
* Find number of instances of value
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @param[in] value to find
|
|
* @return number of instances
|
|
*/
|
|
int
|
|
easycsv_findnumvalue(const easycsv*,
|
|
const char*);
|
|
|
|
/**
|
|
* Read string in a specific cell
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @param[in] row number
|
|
* @param[in] column number
|
|
* @return string value of cell, NULL if empty cell
|
|
*/
|
|
char*
|
|
easycsv_readvalue(const easycsv*,
|
|
unsigned int,
|
|
unsigned int);
|
|
|
|
/**
|
|
* Read string in a specific cell with named column in row 1
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @param[in] row value
|
|
* @param[in] column number
|
|
* @return string value of cell, NULL if empty cell
|
|
*/
|
|
char*
|
|
easycsv_readcolumnvalue(const easycsv*,
|
|
const char*,
|
|
unsigned int);
|
|
|
|
/**
|
|
* Return number of rows
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @return number of rows
|
|
*/
|
|
int
|
|
easycsv_printrows(const easycsv*);
|
|
|
|
/**
|
|
* Return number of columns
|
|
* @param[in] constant pointer to easycsv structure
|
|
* @return number of columns
|
|
*/
|
|
int
|
|
easycsv_printcolumns(const easycsv*);
|
|
|
|
/*** Modifications, sort ***/
|
|
|
|
/**
|
|
* Sort row
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] row value
|
|
* @param[in] easycsv sort mode
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_sortrow(easycsv*,
|
|
const char*,
|
|
EASYCSV_SORT);
|
|
|
|
/**
|
|
* Sort column
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] column value
|
|
* @param[in] easycsv sort mode
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_sortcolumn(easycsv*,
|
|
const char*,
|
|
EASYCSV_SORT);
|
|
|
|
/*** Modifications, insert ***/
|
|
|
|
/**
|
|
* Insert row into CSV file
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] cell value
|
|
* @param[in] row number
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_insertrow(easycsv*,
|
|
const char*,
|
|
int);
|
|
|
|
/**
|
|
* Insert string in a specific cell
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] cell value
|
|
* @param[in] row number
|
|
* @param[in] column number
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_insertvalue(easycsv*,
|
|
const char*,
|
|
unsigned int,
|
|
unsigned int);
|
|
|
|
/**
|
|
* Insert string in a specific cell with specific mode
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] cell value
|
|
* @param[in] row number
|
|
* @param[in] column number
|
|
* @param[in] easycsv value mode
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_insertvaluemode(easycsv*,
|
|
const char*,
|
|
unsigned int,
|
|
unsigned int,
|
|
EASYCSV_VALMODE);
|
|
|
|
/**
|
|
* Insert string in a specific cell with named column in a given row
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] cell value
|
|
* @param[in] row number
|
|
* @param[in] column value
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_insertcolumnvalue(easycsv*,
|
|
const char*,
|
|
unsigned int,
|
|
const char*);
|
|
|
|
/**
|
|
* Insert string in a specific cell with named column in a given row with specific mode
|
|
* @param[in] pointer to easycsv structure
|
|
* @param[in] cell value
|
|
* @param[in] row number
|
|
* @param[in] column value
|
|
* @param[in] easycsv value mode
|
|
* @return easycsv error code
|
|
*/
|
|
int
|
|
easycsv_insertcolumnvaluemode(easycsv*,
|
|
const char*,
|
|
unsigned int,
|
|
const char*,
|
|
EASYCSV_VALMODE);
|
|
|
|
/* Modifications, push */
|
|
|
|
/* Create new column on the RHS of an existing one */
|
|
int
|
|
easycsv_pushcolumn(easycsv*,
|
|
const char*);
|
|
|
|
/* Insert string in a vacant cell under a named column */
|
|
int
|
|
easycsv_pushcolumnvalue(easycsv*,
|
|
const char*,
|
|
const char*);
|
|
|
|
/* Modifications, delete */
|
|
|
|
/* Delete CSV value */
|
|
int
|
|
easycsv_deletevalue(easycsv*,
|
|
const unsigned int,
|
|
const unsigned int);
|
|
|
|
/* Delete numbered column */
|
|
int
|
|
easycsv_deletecolumnint(easycsv*,
|
|
const unsigned int);
|
|
|
|
/* Delete named column */
|
|
int
|
|
easycsv_deletecolumnstr(easycsv*,
|
|
const char*);
|
|
|
|
/* Delete numered row */
|
|
|
|
/* Delete named row */
|
|
|
|
|
|
|
|
/* Modifications, append */
|
|
int
|
|
easycsv_appendcsv(easycsv*,
|
|
easycsv*);
|
|
|
|
/*** Modifications, miscellenaeous ***/
|
|
|
|
int
|
|
easycsv_compress(easycsv*);
|
|
|
|
#endif /* EASYCSV_H */
|