23 #ifndef _das_encoding_h_
24 #define _das_encoding_h_
42 #define DAS2DT_BE_REAL 0x0001
45 #define DAS2DT_LE_REAL 0x0002
47 #ifdef HOST_IS_LSB_FIRST
48 #define DAS2DT_HOST_REAL 0x0002
50 #define DAS2DT_HOST_REAL 0x0001
58 #define DAS2DT_ASCII 0x0003
65 #define DAS2DT_TIME 0x0004
68 #define DAS2DT_BE_INT 0x0005
71 #define DAS2DT_LE_INT 0x0006
74 #define DAS2DT_BE_UINT 0x0007
77 #define DAS2DT_LE_UINT 0x0008
79 #define DASENC_FMT_LEN 64
80 #define DASENC_TYPE_LEN 48
108 typedef struct das_encoding{
133 char sFmt[DASENC_FMT_LEN];
140 char sType[DASENC_TYPE_LEN];
183 #define del_DasEncoding(pEnc) free(pEnc)
277 DasEncoding* pThis,
const char* sTimeFmt,
int nFmtWidth
282 #define DAS2DT_BE_REAL_8 0x0801
285 #define DAS2DT_LE_REAL_8 0x0802
288 #ifdef HOST_IS_LSB_FIRST
289 #define DAS2DT_DOUBLE 0x0802
291 #define DAS2DT_DOUBLE 0x0801
295 #define DAS2DT_BE_REAL_4 0x0401
298 #define DAS2DT_LE_REAL_4 0x0402
302 #ifdef HOST_IS_LSB_FIRST
303 #define DAS2DT_FLOAT 0x0402
305 #define DAS2DT_FLOAT 0x0401
309 #define DAS2DT_ASCII_10 0x0A03
310 #define DAS2DT_ASCII_24 0x1804
311 #define DAS2DT_ASCII_14 0x0E04
313 #define DAS2DT_TIME_25 0x1904
314 #define DAS2DT_TIME_28 0x1c04
Utility to assist with encode and decode operations.
DAS_API DasEncoding * DasEnc_copy(DasEncoding *pThis)
Deepcopy a DasEncoding pointer.
DAS_API bool DasEnc_equals(const DasEncoding *pOne, const DasEncoding *pTwo)
Check for equality between two encodings.
DAS_API int isDas2Fill(double value)
An inconvenient way to check for the canonical fill value, -1e31.
DAS_API double getDas2Fill(void)
An inconvenient way to get canonical fill value, -1e31.
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: defs.h:164
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition: units.h:139
Buffer class to handle accumulating byte streams.
Definition: buffer.h:47
Reading and writing values to buffers.
Definition: encoding.h:108
DAS_API DasErrCode DasEnc_toStr(DasEncoding *pThis, char *sType, size_t nLen)
Get a string representation of the data type.
DAS_API DasEncoding * new_DasEncoding(int nCat, int nWidth, const char *sFmt)
Make a new data encoder/decoder.
unsigned int nCat
The basic encoding category.
Definition: encoding.h:119
DAS_API unsigned int DasEnc_hash(const DasEncoding *pThis)
Get a hash value suitable for use in switch statements.
DAS_API void DasEnc_setTimeFormat(DasEncoding *pThis, const char *sTimeFmt, int nFmtWidth)
Set the output format to be used when converting binary time values to to ASCII strings.
DAS_API DasEncoding * new_DasEncoding_str(const char *sType)
Create a new encoding based on the encoding type string.
unsigned int nWidth
The width in bytes of the encoded values.
Definition: encoding.h:126
DAS_API void DasEnc_setAsciiFormat(DasEncoding *pThis, const char *sValFmt, int nFmtWidth)
Set the output format to be used when converting interal binary values to ASCII strings.
DAS_API DasErrCode DasEnc_write(DasEncoding *pThis, DasBuf *pBuf, double value, das_units units)
Encode and write a value onto a string.
DAS_API DasErrCode DasEnc_read(const DasEncoding *pThis, DasBuf *pBuf, das_units units, double *pOut)
Read and Decode a value from a string.
Defines units used for items in the stream, most notably time units that reference an epoch and a ste...