cmCsv.h : Renamed cmCsvInsertTextColAfter() to cmCsvInsertQTestColAfter() to be clear that the output will be quoted.
Added cmCsvInsertIdentColAfter() to insert non-quoted text.
This commit is contained in:
parent
dbc6c77c17
commit
198a0039f1
40
cmCsv.c
40
cmCsv.c
@ -772,6 +772,24 @@ unsigned cmCsvInsertSymDouble( cmCsvH_t h, double v )
|
||||
|
||||
}
|
||||
|
||||
cmCsvRC_t cmCsvSetCellIdent( cmCsvH_t h, unsigned row, unsigned col, const char* text )
|
||||
{
|
||||
cmCsvCell_t* cp;
|
||||
unsigned symId;
|
||||
|
||||
if((cp = _cmCsvCellPtr(h,row,col)) == NULL )
|
||||
return cmErrLastRC(&_cmCsvHandleToPtr(h)->err);
|
||||
|
||||
if((symId = cmCsvInsertSymText(h,text)) == cmInvalidId )
|
||||
return cmErrLastRC(&_cmCsvHandleToPtr(h)->err);
|
||||
|
||||
cp->symId = symId;
|
||||
cp->flags &= !kTypeTMask;
|
||||
cp->flags |= kIdentCsvTFl;
|
||||
|
||||
return kOkCsvRC;
|
||||
}
|
||||
|
||||
cmCsvRC_t cmCsvSetCellText( cmCsvH_t h, unsigned row, unsigned col, const char* text )
|
||||
{
|
||||
cmCsvCell_t* cp;
|
||||
@ -1011,7 +1029,23 @@ cmCsvRC_t cmCsvInsertColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_
|
||||
|
||||
}
|
||||
|
||||
cmCsvRC_t cmCsvInsertTextColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* text, unsigned lexTId )
|
||||
cmCsvRC_t cmCsvInsertIdentColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* text, unsigned lexTId )
|
||||
{
|
||||
cmCsvRC_t rc;
|
||||
cmCsvCell_t* ncp;
|
||||
|
||||
if( cellPtrPtr != NULL )
|
||||
*cellPtrPtr = NULL;
|
||||
|
||||
if((rc = cmCsvInsertColAfter(h, leftCellPtr, &ncp, cmInvalidId, 0, lexTId )) == kOkCsvRC )
|
||||
if((rc = cmCsvSetCellIdent(h, ncp->row, ncp->col, text )) == kOkCsvRC )
|
||||
if( cellPtrPtr != NULL )
|
||||
*cellPtrPtr = ncp;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmCsvRC_t cmCsvInsertQTextColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* text, unsigned lexTId )
|
||||
{
|
||||
cmCsvRC_t rc;
|
||||
cmCsvCell_t* ncp;
|
||||
@ -1137,12 +1171,12 @@ cmCsvRC_t cmCsvWrite( cmCsvH_t h, const char* fn )
|
||||
if((tp = cmHashTblStr(p->htH,cp->symId)) == NULL )
|
||||
return _cmCsvError(p,kHashTblErrCsvRC,"Unable to locate the symbol text for cell at row:%i col:%i.",cp->row,cp->col);
|
||||
|
||||
if( cmIsFlag(cp->flags,kTextTMask) )
|
||||
if( cmIsFlag(cp->flags,kStrCsvTFl) )
|
||||
fprintf(fp,"\"");
|
||||
|
||||
fputs(tp,fp);
|
||||
|
||||
if( cmIsFlag(cp->flags,kTextTMask) )
|
||||
if( cmIsFlag(cp->flags,kStrCsvTFl) )
|
||||
fprintf(fp,"\"");
|
||||
|
||||
cp = cp->rowPtr;
|
||||
|
6
cmCsv.h
6
cmCsv.h
@ -117,7 +117,8 @@ extern "C" {
|
||||
|
||||
|
||||
// Set the value associated with a cell.
|
||||
cmCsvRC_t cmCsvSetCellText( cmCsvH_t h, unsigned row, unsigned col, const char* text );
|
||||
cmCsvRC_t cmCsvSetCellIdent( cmCsvH_t h, unsigned row, unsigned col, const char* text );
|
||||
cmCsvRC_t cmCsvSetCellQText( cmCsvH_t h, unsigned row, unsigned col, const char* text );
|
||||
cmCsvRC_t cmCsvSetCellInt( cmCsvH_t h, unsigned row, unsigned col, int v );
|
||||
cmCsvRC_t cmCsvSetCellUInt( cmCsvH_t h, unsigned row, unsigned col, unsigned v );
|
||||
cmCsvRC_t cmCsvSetCellHex( cmCsvH_t h, unsigned row, unsigned col, unsigned v );
|
||||
@ -138,7 +139,8 @@ extern "C" {
|
||||
// cmCsvCell_t.lexTId in the new cell. There are no constraints on its value.
|
||||
cmCsvRC_t cmCsvInsertColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, unsigned symId, unsigned flags, unsigned lexTId );
|
||||
|
||||
cmCsvRC_t cmCsvInsertTextColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* val, unsigned lexTId );
|
||||
cmCsvRC_t cmCsvInsertIdentColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* val, unsigned lexTId );
|
||||
cmCsvRC_t cmCsvInsertQTextColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, const char* val, unsigned lexTId );
|
||||
cmCsvRC_t cmCsvInsertIntColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, int val, unsigned lexTId );
|
||||
cmCsvRC_t cmCsvInsertUIntColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, unsigned val, unsigned lexTId );
|
||||
cmCsvRC_t cmCsvInsertHexColAfter( cmCsvH_t h, cmCsvCell_t* leftCellPtr, cmCsvCell_t** cellPtrPtr, unsigned val, unsigned lexTId );
|
||||
|
Loading…
Reference in New Issue
Block a user