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 32
108typedef struct das_encoding{
133 char sFmt[DASENC_FMT_LEN];
140 char sType[DASENC_TYPE_LEN];
183#define del_DasEncoding(pEnc) free(pEnc)
185#define DasEnc_isUtf8(pEnc) ((pEnc->nCat == DAS2DT_TIME)||(pEnc->nCat == DAS2DT_ASCII))
279 DasEncoding* pThis,
const char* sTimeFmt,
int nFmtWidth
284#define DAS2DT_BE_REAL_8 0x0801
287#define DAS2DT_LE_REAL_8 0x0802
290#ifdef HOST_IS_LSB_FIRST
291#define DAS2DT_DOUBLE 0x0802
293#define DAS2DT_DOUBLE 0x0801
297#define DAS2DT_BE_REAL_4 0x0401
300#define DAS2DT_LE_REAL_4 0x0402
304#ifdef HOST_IS_LSB_FIRST
305#define DAS2DT_FLOAT 0x0402
307#define DAS2DT_FLOAT 0x0401
311#define DAS2DT_ASCII_10 0x0A03
312#define DAS2DT_ASCII_24 0x1804
313#define DAS2DT_ASCII_14 0x0E04
315#define DAS2DT_TIME_25 0x1904
316#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:184
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition units.h:144
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 internal 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...