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
67#define DASENC_FMT_LEN 64
68#define DASENC_TYPE_LEN 32
96typedef struct das_encoding{
121 char sFmt[DASENC_FMT_LEN];
128 char sType[DASENC_TYPE_LEN];
164#define del_DasEncoding(pEnc) free(pEnc)
166#define DasEnc_isUtf8(pEnc) ((pEnc->nCat == DAS2DT_TIME)||(pEnc->nCat == DAS2DT_ASCII))
260 DasEncoding* pThis,
const char* sTimeFmt,
int nFmtWidth
265#define DAS2DT_BE_REAL_8 0x0801
268#define DAS2DT_LE_REAL_8 0x0802
271#ifdef HOST_IS_LSB_FIRST
272#define DAS2DT_DOUBLE 0x0802
274#define DAS2DT_DOUBLE 0x0801
278#define DAS2DT_BE_REAL_4 0x0401
281#define DAS2DT_LE_REAL_4 0x0402
285#ifdef HOST_IS_LSB_FIRST
286#define DAS2DT_FLOAT 0x0402
288#define DAS2DT_FLOAT 0x0401
292#define DAS2DT_ASCII_10 0x0A03
293#define DAS2DT_ASCII_24 0x1804
294#define DAS2DT_ASCII_14 0x0E04
296#define DAS2DT_TIME_25 0x1904
297#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:189
const char * das_units
Handle SI and other units, with accommodations for Epoch systems, from units.h.
Definition units.h:141
Buffer class to handle accumulating byte streams.
Definition buffer.h:47
Reading and writing values to buffers.
Definition encoding.h:96
DAS_API DasEncoding * new_DasEncoding(int nCat, int nWidth, const char *sFmt)
Make a new data encoder/decoder.
#define DasEnc_toStr(P, B, N)
Get a string representation of the data type.
unsigned int nCat
The basic encoding category.
Definition encoding.h:107
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:114
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...