Skip to content

Commit

Permalink
Added annotation attribute, more encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiker committed Aug 30, 2024
1 parent bd7028d commit 5b471a0
Show file tree
Hide file tree
Showing 18 changed files with 1,448 additions and 1,049 deletions.
12 changes: 12 additions & 0 deletions das2/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,3 +917,15 @@ int DasCodec_decode(

return nBufLen - nBytesRead; /* Return number of unread bytes */
}


/* ************************************************************************* */
/* Main encoder */

int DasCodec_encode(DasCodec* pThis, DasBuf* pBuf, int nWrite, bool bLast)
{

DasBuf_printf(pBuf, "Adding %d values here\n", nWrite);
return nWrite;

}
6 changes: 5 additions & 1 deletion das2/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ DAS_API int DasCodec_decode(
DasCodec* pThis, const ubyte* pBuf, int nBufLen, int nExpect, int* pValsRead
);

/** Write values from an array into a buffer, does not change the array */
/** Write values from an array into a buffer, does not change the array
*
* @returns The number of values written or a negative ERR code if a data
* conversion error occured.
*/
DAS_API int DasCodec_encode(
DasCodec* pThis, DasBuf* pBuf, int nWrite, bool bLast
);
Expand Down
31 changes: 18 additions & 13 deletions das2/dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void _DasDs_codecsGoLarger(DasDs* pThis)
pThis->uSzCodecs = uNewSz;
}

DasErrCode DasDs_addFixedCodec(
DasCodec* DasDs_addFixedCodec(
DasDs* pThis, const char* sAryId, const char* sSemantic,
const char* sEncType, int nItemBytes, int nNumItems
){
Expand All @@ -395,8 +395,10 @@ DasErrCode DasDs_addFixedCodec(

/* Find the array with this ID */
DasAry* pAry = DasDs_getAryById(pThis, sAryId);
if(pAry == NULL)
return das_error(DASERR_DS, "An array with id '%s' was not found", sAryId);
if(pAry == NULL){
das_error(DASERR_DS, "An array with id '%s' was not found", sAryId);
return NULL;
}

DasCodec* pCodec = pThis->lCodecs + pThis->uCodecs;

Expand All @@ -405,15 +407,15 @@ DasErrCode DasDs_addFixedCodec(
);

if(nRet != DAS_OKAY)
return nRet;
return NULL;

pThis->lItems[pThis->uCodecs] = nNumItems;
pThis->uCodecs += 1;

return DAS_OKAY;
return pCodec;
}

DasErrCode DasDs_addFixedCodecFrom(
DasCodec* DasDs_addFixedCodecFrom(
DasDs* pThis, const char* sAryId, const DasCodec* pOther, int nNumItems
){
/* Go dynamic? */
Expand All @@ -431,8 +433,10 @@ DasErrCode DasDs_addFixedCodecFrom(

/* Look for the array in this dataset, not the other one */
DasAry* pAry = DasDs_getAryById(pThis, _sFindAry);
if(pAry == NULL)
return das_error(DASERR_DS, "An array with id '%s' was not found", _sFindAry);
if(pAry == NULL){
das_error(DASERR_DS, "An array with id '%s' was not found", _sFindAry);
return NULL;
}

DasCodec* pDest = pThis->lCodecs + pThis->uCodecs;

Expand All @@ -444,14 +448,15 @@ DasErrCode DasDs_addFixedCodecFrom(
pThis->lItems[pThis->uCodecs] = nNumItems;
pThis->uCodecs += 1;

return DAS_OKAY;
return pDest;
}

DasErrCode DasDs_addRaggedCodec(
DasCodec* DasDs_addRaggedCodec(
DasDs* pThis, const char* sAryId, const char* sSemantic, const char* sEncType,
int nItemBytes, int nSeps, ubyte uSepLen, const ubyte* pSepByIdx
){
return das_error(DASERR_NOTIMP, "Ragged codec creation not yet implimented");
das_error(DASERR_NOTIMP, "Ragged codec creation not yet implimented");
return NULL;
}

int DasDs_recBytes(const DasDs* pThis)
Expand All @@ -469,7 +474,7 @@ int DasDs_recBytes(const DasDs* pThis)
return nBytesPerPkt;
}

const DasCodec* DasDs_getCodecFor(
DasCodec* DasDs_getCodecFor(
const DasDs* pThis, const char* sAryId, int* pItems
){
size_t u;
Expand All @@ -485,7 +490,7 @@ const DasCodec* DasDs_getCodecFor(
return NULL;
}

const DasCodec* pCodec = NULL;
DasCodec* pCodec = NULL;
for( u = 0; u < pThis->uCodecs; u++){
pCodec = &(pThis->lCodecs[u]);
if(pCodec->pAry == pFind){
Expand Down
18 changes: 10 additions & 8 deletions das2/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ DAS_API size_t DasDs_memOwned(const DasDs* pThis);
*
* @memberof DasDs
*/
DAS_API const DasCodec* DasDs_getCodecFor(
DAS_API DasCodec* DasDs_getCodecFor(
const DasDs* pThis, const char* sAryId, int* pItems
);

Expand Down Expand Up @@ -614,11 +614,12 @@ DAS_API const DasCodec* DasDs_getCodecFor(
*
* @param nNumItems The number of items to read/write at a time.
*
* @returns DAS_OKAY if the array codec could be defined
* @returns NULL if the codec couldn't be defined, or a pointer to
* the new codec otherwise
*
* @memberof DasDs
*/
DAS_API DasErrCode DasDs_addFixedCodec(
DAS_API DasCodec* DasDs_addFixedCodec(
DasDs* pThis, const char* sAryId, const char* sSemantic,
const char* sEncType, int nItemBytes, int nNumItems
);
Expand All @@ -639,12 +640,12 @@ DAS_API DasErrCode DasDs_addFixedCodec(
*
* @param nNumItems The number of items to read/write at a time.
*
* @returns DAS_OKAY if a new codec could be initialized, a positive error
* value otherwies.
* @returns NULL if the codec couldn't be defined, or a pointer to
* the new codec otherwise
*
* @memberof DasDs
*/
DAS_API DasErrCode DasDs_addFixedCodecFrom(
DAS_API DasCodec* DasDs_addFixedCodecFrom(
DasDs* pThis, const char* sAryId, const DasCodec* pOther, int nNumItems
);

Expand Down Expand Up @@ -677,11 +678,12 @@ DAS_API DasErrCode DasDs_addFixedCodecFrom(
* @param pSepByIdx Pointer to an array of separator bytes. This must
* be nSeps * uSepLen long.
*
* @returns DAS_OKAY if the array codec could be defined
* @returns NULL if the codec couldn't be defined, or a pointer to
* the new codec otherwise
*
* @memberof DasDs
*/
DAS_API DasErrCode DasDs_addRaggedCodec(
DAS_API DasCodec* DasDs_addRaggedCodec(
DasDs* pThis, const char* sAryId, const char* sSemantic,
const char* sEncType, int nItemBytes, int nSeps, ubyte uSepLen, const ubyte* pSepByIdx
);
Expand Down
Loading

0 comments on commit 5b471a0

Please sign in to comment.