From a83c1e875be68095674c933992b7397b970e9cc3 Mon Sep 17 00:00:00 2001 From: Ali Mirghasemi Date: Wed, 13 Nov 2024 15:27:45 +0330 Subject: [PATCH] Add new features --- Src/InputStream.h | 262 ++++++++++++++++++++++++++++----------------- Src/OutputStream.h | 50 +++++---- Src/StreamBuffer.c | 56 +++------- Src/StreamBuffer.h | 206 ++++++++++++++++++++++------------- 4 files changed, 344 insertions(+), 230 deletions(-) diff --git a/Src/InputStream.h b/Src/InputStream.h index a4d3446..70952e6 100644 --- a/Src/InputStream.h +++ b/Src/InputStream.h @@ -16,7 +16,7 @@ extern "C" { #endif #define ISTREAM_VER_MAJOR 0 -#define ISTREAM_VER_MINOR 6 +#define ISTREAM_VER_MINOR 7 #define ISTREAM_VER_FIX 0 #include "StreamBuffer.h" @@ -144,101 +144,96 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #define IStream_ignore(STREAM, LEN) Stream_moveReadPos(&((STREAM)->Buffer), (LEN)) -/* Read function same as StreamBuffer read functions */ -#define IStream_readBytes(STREAM, VAL, LEN) Stream_readBytes(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readBytesReverse(STREAM, VAL, LEN) Stream_readBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_read(STREAM, VAL, LEN) Stream_read(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readStream(IN, OUT, LEN) Stream_readStream(&((IN)->Buffer), &((OUT)->Buffer), (LEN)) - -#define IStream_readCharSafe(STREAM) Stream_readCharSafe(&((STREAM)->Buffer)) -#define IStream_readUInt8Safe(STREAM) Stream_readUInt8Safe(&((STREAM)->Buffer)) -#define IStream_readInt8Safe(STREAM) Stream_readInt8Safe(&((STREAM)->Buffer)) -#define IStream_readUInt16Safe(STREAM) Stream_readUInt16Safe(&((STREAM)->Buffer)) -#define IStream_readInt16Safe(STREAM) Stream_readInt16Safe(&((STREAM)->Buffer)) -#define IStream_readUInt32Safe(STREAM) Stream_readUInt32Safe(&((STREAM)->Buffer)) -#define IStream_readInt32Safe(STREAM) Stream_readInt32Safe(&((STREAM)->Buffer)) -#define IStream_readFloatSafe(STREAM) Stream_readFloatSafe(&((STREAM)->Buffer)) - +/* ------------------------------------ General Read APIs ---------------------------------- */ +#define IStream_readValue(STREAM, LEN) Stream_readValue(&((STREAM)->Buffer), (LEN)) +#define IStream_readBytes(STREAM, VAL, LEN) Stream_readBytes(&((STREAM)->Buffer), (VAL), (LEN)) +#if STREAM_READ_REVERSE + #define IStream_readBytesReverse(STREAM, VAL, LEN) Stream_readBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_read(STREAM, VAL, LEN) Stream_read(&((STREAM)->Buffer), (VAL), (LEN)) +#else + #define IStream_read(STREAM, VAL, LEN) IStream_readBytes((STREAM), (VAL), (LEN)) +#endif +#if STREAM_READ_STREAM + #define IStream_readStream(IN, OUT, LEN) Stream_readStream(&((IN)->Buffer), &((OUT)->Buffer), (LEN)) +#endif +/* ------------------------------------ Read Value Safe APIs ---------------------------------- */ +#define IStream_readCharSafe(STREAM) Stream_readCharSafe(&((STREAM)->Buffer)) +#define IStream_readUInt8Safe(STREAM) Stream_readUInt8Safe(&((STREAM)->Buffer)) +#define IStream_readInt8Safe(STREAM) Stream_readInt8Safe(&((STREAM)->Buffer)) +#define IStream_readUInt16Safe(STREAM) Stream_readUInt16Safe(&((STREAM)->Buffer)) +#define IStream_readInt16Safe(STREAM) Stream_readInt16Safe(&((STREAM)->Buffer)) +#define IStream_readUInt32Safe(STREAM) Stream_readUInt32Safe(&((STREAM)->Buffer)) +#define IStream_readInt32Safe(STREAM) Stream_readInt32Safe(&((STREAM)->Buffer)) +#define IStream_readFloatSafe(STREAM) Stream_readFloatSafe(&((STREAM)->Buffer)) #if STREAM_UINT64 - #define IStream_readUInt64Safe(STREAM) Stream_readUInt64Safe(&((STREAM)->Buffer)) - #define IStream_readInt64Safe(STREAM) Stream_readInt64Safe(&((STREAM)->Buffer)) + #define IStream_readUInt64Safe(STREAM) Stream_readUInt64Safe(&((STREAM)->Buffer)) + #define IStream_readInt64Safe(STREAM) Stream_readInt64Safe(&((STREAM)->Buffer)) #endif // STREAM_UINT64 #if STREAM_DOUBLE - #define IStream_readDoubleSafe(STREAM) Stream_readDoubleSafe(&((STREAM)->Buffer)) + #define IStream_readDoubleSafe(STREAM) Stream_readDoubleSafe(&((STREAM)->Buffer)) #endif // STREAM_DOUBLE - -#define IStream_readChar(STREAM) Stream_readChar(&((STREAM)->Buffer)) -#define IStream_readUInt8(STREAM) Stream_readUInt8(&((STREAM)->Buffer)) -#define IStream_readInt8(STREAM) Stream_readInt8(&((STREAM)->Buffer)) -#define IStream_readUInt16(STREAM) Stream_readUInt16(&((STREAM)->Buffer)) -#define IStream_readInt16(STREAM) Stream_readInt16(&((STREAM)->Buffer)) -#define IStream_readUInt32(STREAM) Stream_readUInt32(&((STREAM)->Buffer)) -#define IStream_readInt32(STREAM) Stream_readInt32(&((STREAM)->Buffer)) -#define IStream_readFloat(STREAM) Stream_readFloat(&((STREAM)->Buffer)) - +/* ------------------------------------ Read Value APIs ---------------------------------- */ +#define IStream_readChar(STREAM) Stream_readChar(&((STREAM)->Buffer)) +#define IStream_readUInt8(STREAM) Stream_readUInt8(&((STREAM)->Buffer)) +#define IStream_readInt8(STREAM) Stream_readInt8(&((STREAM)->Buffer)) +#define IStream_readUInt16(STREAM) Stream_readUInt16(&((STREAM)->Buffer)) +#define IStream_readInt16(STREAM) Stream_readInt16(&((STREAM)->Buffer)) +#define IStream_readUInt32(STREAM) Stream_readUInt32(&((STREAM)->Buffer)) +#define IStream_readInt32(STREAM) Stream_readInt32(&((STREAM)->Buffer)) +#define IStream_readFloat(STREAM) Stream_readFloat(&((STREAM)->Buffer)) #if STREAM_UINT64 - #define IStream_readUInt64(STREAM) Stream_readUInt64(&((STREAM)->Buffer)) - #define IStream_readInt64(STREAM) Stream_readInt64(&((STREAM)->Buffer)) + #define IStream_readUInt64(STREAM) Stream_readUInt64(&((STREAM)->Buffer)) + #define IStream_readInt64(STREAM) Stream_readInt64(&((STREAM)->Buffer)) #endif // STREAM_UINT64 #if STREAM_DOUBLE - #define IStream_readDouble(STREAM) Stream_readDouble(&((STREAM)->Buffer)) + #define IStream_readDouble(STREAM) Stream_readDouble(&((STREAM)->Buffer)) #endif // STREAM_DOUBLE - -#define IStream_readCharArray(STREAM, VAL, LEN) Stream_readCharArray(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readUInt8Array(STREAM, VAL, LEN) Stream_readUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readInt8Array(STREAM, VAL, LEN) Stream_readInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readUInt16Array(STREAM, VAL, LEN) Stream_readUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readInt16Array(STREAM, VAL, LEN) Stream_readInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readUInt32Array(STREAM, VAL, LEN) Stream_readUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readInt32Array(STREAM, VAL, LEN) Stream_readInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_readFloatArray(STREAM, VAL, LEN) Stream_readFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) - +/* ------------------------------------ Read Value Array APIs ---------------------------------- */ +#if STREAM_READ_ARRAY +#define IStream_readArray(STREAM, VAL, ITEM_LEN, LEN) Stream_readArray(&((STREAM)->Buffer), (VAL), (ITEM_LEN), (LEN)) +#define IStream_readCharArray(STREAM, VAL, LEN) Stream_readCharArray(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readUInt8Array(STREAM, VAL, LEN) Stream_readUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readInt8Array(STREAM, VAL, LEN) Stream_readInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readUInt16Array(STREAM, VAL, LEN) Stream_readUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readInt16Array(STREAM, VAL, LEN) Stream_readInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readUInt32Array(STREAM, VAL, LEN) Stream_readUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readInt32Array(STREAM, VAL, LEN) Stream_readInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_readFloatArray(STREAM, VAL, LEN) Stream_readFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) #if STREAM_UINT64 - #define IStream_readUInt64Array(STREAM,VAL,LEN) Stream_readUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) - #define IStream_readInt64Array(STREAM,VAL,LEN) Stream_readInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_readUInt64Array(STREAM,VAL,LEN) Stream_readUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_readInt64Array(STREAM,VAL,LEN) Stream_readInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) #endif // STREAM_UINT64 #if STREAM_DOUBLE - #define IStream_readDoubleArray(STREAM,VAL,LEN) Stream_readDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_readDoubleArray(STREAM,VAL,LEN) Stream_readDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) #endif // STREAM_DOUBLE - -#define IStream_getBytes(STREAM, VAL, LEN) Stream_getBytes((STREAM), (VAL), (LEN)) -#define IStream_getBytesReverse(STREAM, VAL, LEN) Stream_getBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)); -#define IStream_getChar(STREAM) Stream_getChar(&((STREAM)->Buffer)) -#define IStream_getUInt8(STREAM) Stream_getUInt8(&((STREAM)->Buffer)) -#define IStream_getInt8(STREAM) Stream_getInt8(&((STREAM)->Buffer)) -#define IStream_getUInt16(STREAM) Stream_getUInt16(&((STREAM)->Buffer)) -#define IStream_getInt16(STREAM) Stream_getInt16(&((STREAM)->Buffer)) -#define IStream_getUInt32(STREAM) Stream_getUInt32(&((STREAM)->Buffer)) -#define IStream_getInt32(STREAM) Stream_getInt32(&((STREAM)->Buffer)) -#define IStream_getFloat(STREAM) Stream_getFloat(&((STREAM)->Buffer)) - -#if STREAM_UINT64 - #define IStream_getUInt64(STREAM) Stream_getUInt64(&((STREAM)->Buffer)) - #define IStream_getInt64(STREAM) Stream_getInt64(&((STREAM)->Buffer)) -#endif // STREAM_UINT64 -#if STREAM_DOUBLE - #define IStream_getDouble(STREAM) Stream_getDouble(&((STREAM)->Buffer)) -#endif // STREAM_DOUBLE - -#define IStream_getCharArray(STREAM, VAL, LEN) Stream_getCharArray(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getUInt8Array(STREAM, VAL, LEN) Stream_getUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getInt8Array(STREAM, VAL, LEN) Stream_getInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getUInt16Array(STREAM, VAL, LEN) Stream_getUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getInt16Array(STREAM, VAL, LEN) Stream_getInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getUInt32Array(STREAM, VAL, LEN) Stream_getUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getInt32Array(STREAM, VAL, LEN) Stream_getInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define IStream_getFloatArray(STREAM, VAL, LEN) Stream_getFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) - +#endif // STREAM_READ_ARRAY +/* ------------------------------------ General GetAt APIs ---------------------------------- */ +#if STREAM_GET_AT_FUNCTIONS +#define IStream_getValueAt(STREAM, LEN, IDX) Stream_getValueAt(&((STREAM)->Buffer), (LEN), (IDX)) +#define IStream_getBytesAt(STREAM, IXD, VAL, LEN) Stream_getBytesAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) +#if STREAM_GET_AT_BYTES_REVERSE + #define IStream_getBytesReverseAt(STREAM, IDX, VAL, LEN) Stream_getBytesReverseAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)); + #define IStream_getAt(STREAM, IDX, VAL, LEN) Stream_getAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) +#else + #define IStream_getAt(STREAM, IDX, VAL, LEN) IStream_getBytesAt((STREAM), (IDX), (VAL), (LEN)) +#endif +/* ------------------------------------ GetAt Value Safe APIs ---------------------------------- */ +#define IStream_getCharAtSafe(STREAM, IDX, VAL) Stream_getCharAtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getUInt8AtSafe(STREAM, IDX, VAL) Stream_getUInt8AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getInt8AtSafe(STREAM, IDX, VAL) Stream_getInt8AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getUInt16AtSafe(STREAM, IDX, VAL) Stream_getUInt16AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getInt16AtSafe(STREAM, IDX, VAL) Stream_getInt16AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getUInt32AtSafe(STREAM, IDX, VAL) Stream_getUInt32AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getInt32AtSafe(STREAM, IDX, VAL) Stream_getInt32AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) +#define IStream_getFloatAtSafe(STREAM, IDX, VAL) Stream_getFloatAtSafe(&((STREAM)->Buffer), (IDX), (VAL)) #if STREAM_UINT64 - #define IStream_getUInt64Array(STREAM,VAL,LEN) Stream_getUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) - #define IStream_getInt64Array(STREAM,VAL,LEN) Stream_getInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_getUInt64AtSafe(STREAM, IDX, VAL) Stream_getUInt64AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) + #define IStream_getInt64AtSafe(STREAM, IDX, VAL) Stream_getInt64AtSafe(&((STREAM)->Buffer), (IDX), (VAL)) #endif // STREAM_UINT64 #if STREAM_DOUBLE - #define IStream_getDoubleArray(STREAM,VAL,LEN) Stream_getDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_getDoubleAtSafe(STREAM, IDX, VAL) Stream_getDoubleAtSafe(&((STREAM)->Buffer), (IDX), (VAL)) #endif // STREAM_DOUBLE - -#define IStream_getBytesAt(STREAM, IXD, VAL, LEN) Stream_getBytesAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) -#define IStream_getBytesReverseAt(STREAM, IDX, VAL, LEN) Stream_getBytesReverseAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)); +/* ------------------------------------ GetAt Value APIs ---------------------------------- */ #define IStream_getCharAt(STREAM, IDX) Stream_getCharAt(&((STREAM)->Buffer), (IDX)) #define IStream_getUInt8At(STREAM, IDX) Stream_getUInt8At(&((STREAM)->Buffer), (IDX)) #define IStream_getInt8At(STREAM, IDX) Stream_getInt8At(&((STREAM)->Buffer), (IDX)) @@ -247,7 +242,6 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #define IStream_getUInt32At(STREAM, IDX) Stream_getUInt32At(&((STREAM)->Buffer), (IDX)) #define IStream_getInt32At(STREAM, IDX) Stream_getInt32At(&((STREAM)->Buffer), (IDX)) #define IStream_getFloatAt(STREAM, IDX) Stream_getFloatAt(&((STREAM)->Buffer), (IDX)) - #if STREAM_UINT64 #define IStream_getUInt64At(STREAM) Stream_getUInt64At(&((STREAM)->Buffer), (IDX)) #define IStream_getInt64At(STREAM) Stream_getInt64At(&((STREAM)->Buffer), (IDX)) @@ -255,7 +249,9 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #if STREAM_DOUBLE #define IStream_getDoubleAt(STREAM) Stream_getDoubleAt(&((STREAM)->Buffer), (IDX)) #endif // STREAM_DOUBLE - +/* ------------------------------------ GetAt Value Array APIs ---------------------------------- */ +#if STREAM_GET_AT_ARRAY +#define IStream_getArrayAt(STREAM, VAL, ITEM_LEN, LEN) Stream_getArrayAt(&((STREAM)->Buffer), (VAL), (ITEM_LEN), (LEN)) #define IStream_getCharArrayAt(STREAM, IDX, VAL, LEN) Stream_getCharArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #define IStream_getUInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getUInt8ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #define IStream_getInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getInt8ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) @@ -264,7 +260,6 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #define IStream_getUInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getUInt32ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #define IStream_getInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getInt32ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #define IStream_getFloatArrayAt(STREAM, IDX, VAL, LEN) Stream_getFloatArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) - #if STREAM_UINT64 #define IStream_getUInt64ArrayAt(STREAM,IDX,VAL,LEN) Stream_getUInt64ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #define IStream_getInt64ArrayAt(STREAM,IDX,VAL,LEN) Stream_getInt64ArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) @@ -272,13 +267,77 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #if STREAM_DOUBLE #define IStream_getDoubleArrayAt(STREAM,IDX,VAL,LEN) Stream_getDoubleArrayAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) #endif // STREAM_DOUBLE - -/* ------------------------------------ Find APIs ---------------------------------- */ -#if STREAM_FIND_AT_FUNCTIONS +#endif // STREAM_GET_AT_ARRAY +#endif // STREAM_GET_AT_FUNCTIONS +/* ------------------------------------ General Get APIs ---------------------------------- */ +#if STREAM_GET_AT_FUNCTIONS && STREAM_GET_FUNCTIONS +#define IStream_getValue(STREAM, LEN) Stream_getValue(&((STREAM)->Buffer), (LEN)) +#define IStream_getBytes(STREAM, VAL, LEN) Stream_getBytes((STREAM), (VAL), (LEN)) +#if STREAM_GET_BYTES_REVERSE + #define IStream_getBytesReverse(STREAM, VAL, LEN) Stream_getBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)); + #define IStream_get(STREAM, VAL, LEN) Stream_get(&((STREAM)->Buffer), (VAL), (LEN)) +#else + #define IStream_get(STREAM, VAL, LEN) IStream_getBytes((STREAM), (VAL), (LEN)) +#endif +/* ------------------------------------ Get Value Safe APIs ---------------------------------- */ +#define IStream_getCharSafe(STREAM, VAL) Stream_getCharSafe(&((STREAM)->Buffer), (VAL)) +#define IStream_getUInt8Safe(STREAM, VAL) Stream_getUInt8Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getInt8Safe(STREAM, VAL) Stream_getInt8Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getUInt16Safe(STREAM, VAL) Stream_getUInt16Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getInt16Safe(STREAM, VAL) Stream_getInt16Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getUInt32Safe(STREAM, VAL) Stream_getUInt32Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getInt32Safe(STREAM, VAL) Stream_getInt32Safe(&((STREAM)->Buffer), (VAL)) +#define IStream_getFloatSafe(STREAM, VAL) Stream_getFloatSafe(&((STREAM)->Buffer), (VAL)) +#if STREAM_UINT64 + #define IStream_getUInt64Safe(STREAM, VAL) Stream_getUInt64Safe(&((STREAM)->Buffer), (VAL)) + #define IStream_getInt64Safe(STREAM, VAL) Stream_getInt64Safe(&((STREAM)->Buffer), (VAL)) +#endif // STREAM_UINT64 +#if STREAM_DOUBLE + #define IStream_getDoubleSafe(STREAM, VAL) Stream_getDoubleSafe(&((STREAM)->Buffer), (VAL)) +#endif // STREAM_DOUBLE +/* ------------------------------------ Get Value APIs ---------------------------------- */ +#define IStream_getChar(STREAM) Stream_getChar(&((STREAM)->Buffer)) +#define IStream_getUInt8(STREAM) Stream_getUInt8(&((STREAM)->Buffer)) +#define IStream_getInt8(STREAM) Stream_getInt8(&((STREAM)->Buffer)) +#define IStream_getUInt16(STREAM) Stream_getUInt16(&((STREAM)->Buffer)) +#define IStream_getInt16(STREAM) Stream_getInt16(&((STREAM)->Buffer)) +#define IStream_getUInt32(STREAM) Stream_getUInt32(&((STREAM)->Buffer)) +#define IStream_getInt32(STREAM) Stream_getInt32(&((STREAM)->Buffer)) +#define IStream_getFloat(STREAM) Stream_getFloat(&((STREAM)->Buffer)) +#if STREAM_UINT64 + #define IStream_getUInt64(STREAM) Stream_getUInt64(&((STREAM)->Buffer)) + #define IStream_getInt64(STREAM) Stream_getInt64(&((STREAM)->Buffer)) +#endif // STREAM_UINT64 +#if STREAM_DOUBLE + #define IStream_getDouble(STREAM) Stream_getDouble(&((STREAM)->Buffer)) +#endif // STREAM_DOUBLE +/* ------------------------------------ Get Value Array APIs ---------------------------------- */ +#if STREAM_GET_ARRAY +#define IStream_getArray(STREAM, VAL, ITEM_LEN, LEN) Stream_getArray(&((STREAM)->Buffer), (VAL), (ITEM_LEN), (LEN)) +#define IStream_getCharArray(STREAM, VAL, LEN) Stream_getCharArray(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getUInt8Array(STREAM, VAL, LEN) Stream_getUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getInt8Array(STREAM, VAL, LEN) Stream_getInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getUInt16Array(STREAM, VAL, LEN) Stream_getUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getInt16Array(STREAM, VAL, LEN) Stream_getInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getUInt32Array(STREAM, VAL, LEN) Stream_getUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getInt32Array(STREAM, VAL, LEN) Stream_getInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) +#define IStream_getFloatArray(STREAM, VAL, LEN) Stream_getFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) +#if STREAM_UINT64 + #define IStream_getUInt64Array(STREAM,VAL,LEN) Stream_getUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define IStream_getInt64Array(STREAM,VAL,LEN) Stream_getInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) +#endif // STREAM_UINT64 +#if STREAM_DOUBLE + #define IStream_getDoubleArray(STREAM,VAL,LEN) Stream_getDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) +#endif // STREAM_DOUBLE +#endif // STREAM_GET_ARRAY +#endif // STREAM_GET_AT_FUNCTIONS && STREAM_GET_FUNCTIONS /* ------------------------------------ General Find At APIs ---------------------------------- */ +#if STREAM_FIND_AT_FUNCTIONS + #define IStream_findValueAt(STREAM, OFFSET, VAL, LEN) Stream_findValueAt(&((STREAM)->Buffer), (OFFSET), (VAL), (LEN)) #define IStream_findByteAt(STREAM, OFFSET, VAL) Stream_findByteAt(&((STREAM)->Buffer), (OFFSET), (VAL)) #define IStream_findPatternAt(STREAM, OFFSET, PAT, PAT_LEN) Stream_findPatternAt(&((STREAM)->Buffer), (OFFSET), (PAT), (PAT_LEN)) + #define IStream_findCharAt(STREAM, OFFSET, VAL) Stream_findCharAt(&((STREAM)->Buffer), (OFFSET), (VAL)) #define IStream_findUInt8At(STREAM, OFFSET, VAL) Stream_findUInt8At(&((STREAM)->Buffer), (OFFSET), (VAL)) #define IStream_findInt8At(STREAM, OFFSET, VAL) Stream_findInt8At(&((STREAM)->Buffer), (OFFSET), (VAL)) #define IStream_findUInt16At(STREAM, OFFSET, VAL) Stream_findUInt16At(&((STREAM)->Buffer), (OFFSET), (VAL)) @@ -288,15 +347,15 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #if STREAM_UINT64 #define IStream_findUInt64At(STREAM, OFFSET, VAL) Stream_findUInt64At(&((STREAM)->Buffer), (OFFSET), (VAL)) #define IStream_findInt64At(STREAM, OFFSET, VAL) Stream_findInt64At(&((STREAM)->Buffer), (OFFSET), (VAL)) -#endif +#endif // STREAM_UINT64 #define IStream_findFloatAt(STREAM, OFFSET, VAL) Stream_findFloatAt(&((STREAM)->Buffer), (OFFSET), (VAL)) #if STREAM_DOUBLE #define IStream_findDoubleAt(STREAM, OFFSET, VAL) Stream_findDoubleAt(&((STREAM)->Buffer), (OFFSET), (VAL)) -#endif - #define IStream_readBytesUntilAt(STREAM, OFFSET, END, VAL, LEN) Stream_readBytesUntilAt(&((STREAM)->Buffer), (OFFSET), (END), (VAL), (LEN)) - #define IStream_readBytesUntilPatternAt(STREAM, OFFSET, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPatternAt(&((STREAM)->Buffer), (OFFSET), (PAT), (PAT_LEN), (VAL), (LEN)) +#endif // STREAM_DOUBLE +#endif // STREAM_FIND_AT_FUNCTIONS /* ------------------------------------ General Find APIs ---------------------------------- */ -#if STREAM_FIND_FUNCTIONS +#if STREAM_FIND_FUNCTIONS && STREAM_FIND_AT_FUNCTIONS + #define IStream_findValue(STREAM, VAL, LEN) Stream_findValue(&((STREAM)->Buffer), (VAL), (LEN)) #define IStream_findByte(STREAM, VAL) Stream_findByte(&((STREAM)->Buffer), (VAL)) #define IStream_findPattern(STREAM, PAT, PAT_LEN) Stream_findPattern(&((STREAM)->Buffer), (PAT), (PAT_LEN)) @@ -309,16 +368,23 @@ Stream_LenType IStream_incomingBytes(IStream* stream); #if STREAM_UINT64 #define IStream_findUInt64(STREAM, VAL) Stream_findUInt64(&((STREAM)->Buffer), (VAL)) #define IStream_findInt64(STREAM, VAL) Stream_findInt64(&((STREAM)->Buffer), (VAL)) -#endif +#endif // STREAM_UINT64 #define IStream_findFloat(STREAM, VAL) Stream_findFloat(&((STREAM)->Buffer), (VAL)) #if STREAM_DOUBLE #define IStream_findDouble(STREAM, VAL) Stream_findDouble(&((STREAM)->Buffer), (VAL)) -#endif - #define IStream_readBytesUntil(STREAM, END, VAL, LEN) Stream_readBytesUntil(&((STREAM)->Buffer), (END), (VAL), (LEN)) - #define IStream_readBytesUntilPattern(STREAM, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPattern(&((STREAM)->Buffer), (PAT), (PAT_LEN), (VAL), (VAL_LEN)) -#endif // STREAM_FIND_FUNCTIONS -#endif // STREAM_FIND_AT_FUNCTIONS - +#endif // STREAM_DOUBLE +#endif // STREAM_FIND_FUNCTIONS && STREAM_FIND_AT_FUNCTIONS +/* ------------------------------------ Read Bytes Until At APIs ---------------------------------- */ +#if STREAM_READ_UNTIL_AT +#define IStream_readBytesUntilAt(STREAM, OFFSET, END, VAL, LEN) Stream_readBytesUntilAt(&((STREAM)->Buffer), (OFFSET), (END), (VAL), (LEN)) +#define IStream_readBytesUntilPatternAt(STREAM, OFFSET, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPatternAt(&((STREAM)->Buffer), (OFFSET), (PAT), (PAT_LEN), (VAL), (LEN)) +#endif // STREAM_READ_UNTIL_AT +/* ------------------------------------ Read Bytes Until APIs ---------------------------------- */ +#if STREAM_READ_UNTIL +#define IStream_readBytesUntil(STREAM, END, VAL, LEN) Stream_readBytesUntil(&((STREAM)->Buffer), (END), (VAL), (LEN)) +#define IStream_readBytesUntilPattern(STREAM, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPattern(&((STREAM)->Buffer), (PAT), (PAT_LEN), (VAL), (VAL_LEN)) +#endif // STREAM_READ_UNTIL +/* ------------------------------------ Compare APIs ---------------------------------- */ #define IStream_compare(STREAM, VAL, LEN) Stream_compareAt(&((STREAM)->Buffer), (VAL), (LEN)) #define IStream_compareAt(STREAM, IDX, VAL, LEN) Stream_compareAt(&((STREAM)->Buffer), (IDX), (VAL), (LEN)) diff --git a/Src/OutputStream.h b/Src/OutputStream.h index c5b4f41..65501d6 100644 --- a/Src/OutputStream.h +++ b/Src/OutputStream.h @@ -16,7 +16,7 @@ extern "C" { #endif #define OSTREAM_VER_MAJOR 0 -#define OSTREAM_VER_MINOR 6 +#define OSTREAM_VER_MINOR 7 #define OSTREAM_VER_FIX 0 #include "StreamBuffer.h" @@ -172,14 +172,23 @@ Stream_LenType OStream_outgoingBytes(OStream* stream); #endif #define OStream_ignore(STREAM, LEN) Stream_moveWritePos(&((STREAM)->Buffer), (LEN)) - +/* ------------------------------------ General Write APIs ---------------------------------- */ #define OStream_writeBytes(STREAM, VAL, LEN) Stream_writeBytes(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeBytesReverse(STREAM, VAL, LEN) Stream_writeBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_write(STREAM, VAL, LEN) Stream_write(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeStream(OUT, IN, LEN) Stream_writeStream(&((OUT)->Buffer), &((IN)->Buffer), (LEN)) -#define OStream_writePadding(STREAM, VAL, LEN) Stream_writePadding(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeChar(STREAM, VAL) Stream_writeChar(&((STREAM)->Buffer), (VAL)) +#if STREAM_WRITE_REVERSE + #define OStream_writeBytesReverse(STREAM, VAL, LEN) Stream_writeBytesReverse(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_write(STREAM, VAL, LEN) Stream_write(&((STREAM)->Buffer), (VAL), (LEN)) +#else + #define OStream_write(STREAM, VAL, LEN) OStream_writeBytes((STREAM), (VAL), (LEN)) +#endif +#if STREAM_WRITE_STREAM + #define OStream_writeStream(OUT, IN, LEN) Stream_writeStream(&((OUT)->Buffer), &((IN)->Buffer), (LEN)) +#endif +#if STREAM_WRITE_PADDING + #define OStream_writePadding(STREAM, VAL, LEN) Stream_writePadding(&((STREAM)->Buffer), (VAL), (LEN)) +#endif +/* ------------------------------------ Write Value APIs ---------------------------------- */ #define OStream_writeStr(STREAM, VAL) Stream_writeStr(&((STREAM)->Buffer), (VAL)) +#define OStream_writeChar(STREAM, VAL) Stream_writeChar(&((STREAM)->Buffer), (VAL)) #define OStream_writeUInt8(STREAM, VAL) Stream_writeUInt8(&((STREAM)->Buffer), (VAL)) #define OStream_writeInt8(STREAM, VAL) Stream_writeInt8(&((STREAM)->Buffer), (VAL)) #define OStream_writeUInt16(STREAM, VAL) Stream_writeUInt16(&((STREAM)->Buffer), (VAL)) @@ -194,22 +203,25 @@ Stream_LenType OStream_outgoingBytes(OStream* stream); #if STREAM_DOUBLE #define OStream_writeDouble(STREAM, VAL) Stream_writeDouble(&((STREAM)->Buffer), (VAL)) #endif // STREAM_DOUBLE - -#define OStream_writeCharArray(STREAM, VAL, LEN) Stream_writeCharArray(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeUInt8Array(STREAM, VAL, LEN) Stream_writeUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeInt8Array(STREAM, VAL, LEN) Stream_writeInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeUInt16Array(STREAM, VAL, LEN) Stream_writeUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeInt16Array(STREAM, VAL, LEN) Stream_writeInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeUInt32Array(STREAM, VAL, LEN) Stream_writeUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeInt32Array(STREAM, VAL, LEN) Stream_writeInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeFloatArray(STREAM, VAL, LEN) Stream_writeFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) +/* ------------------------------------ Write Value Array APIs ---------------------------------- */ +#if STREAM_WRITE_ARRAY + #define OStream_writeArray(STREAM, VAL, ITEM_LEN, LEN) Stream_writeArray(&((STREAM)->Buffer), (VAL), (ITEM_LEN), (LEN)) + #define OStream_writeCharArray(STREAM, VAL, LEN) Stream_writeCharArray(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeUInt8Array(STREAM, VAL, LEN) Stream_writeUInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeInt8Array(STREAM, VAL, LEN) Stream_writeInt8Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeUInt16Array(STREAM, VAL, LEN) Stream_writeUInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeInt16Array(STREAM, VAL, LEN) Stream_writeInt16Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeUInt32Array(STREAM, VAL, LEN) Stream_writeUInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeInt32Array(STREAM, VAL, LEN) Stream_writeInt32Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeFloatArray(STREAM, VAL, LEN) Stream_writeFloatArray(&((STREAM)->Buffer), (VAL), (LEN)) #if STREAM_UINT64 -#define OStream_writeUInt64Array(STREAM, VAL, LEN) Stream_writeUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) -#define OStream_writeInt64Array(STREAM, VAL, LEN) Stream_writeInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeUInt64Array(STREAM, VAL, LEN) Stream_writeUInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeInt64Array(STREAM, VAL, LEN) Stream_writeInt64Array(&((STREAM)->Buffer), (VAL), (LEN)) #endif // STREAM_UINT64 #if STREAM_DOUBLE -#define OStream_writeDoubleArray(STREAM, VAL, LEN) Stream_writeDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) + #define OStream_writeDoubleArray(STREAM, VAL, LEN) Stream_writeDoubleArray(&((STREAM)->Buffer), (VAL), (LEN)) #endif // STREAM_DOUBLE +#endif // STREAM_WRITE_ARRAY #ifdef __cplusplus }; diff --git a/Src/StreamBuffer.c b/Src/StreamBuffer.c index 562fa9f..0d6428f 100644 --- a/Src/StreamBuffer.c +++ b/Src/StreamBuffer.c @@ -46,24 +46,19 @@ static const Stream_GetBytesFn getBytesAt[2] = { #define __readBytes(STREAM, VAL, LEN) readBytes[STREAM->OrderFn]((STREAM), (VAL), (LEN)) #define __getBytesAt(STREAM, INDEX, VAL, LEN) getBytesAt[STREAM->OrderFn]((STREAM), (INDEX), (VAL), (LEN)) - #define __checkReverseOn(STREAM, VAL) if (STREAM->OrderFn) {__memReverse((STREAM), &VAL, sizeof(VAL));} + #define __checkReverse(STREAM, VAL, LEN) if (STREAM->OrderFn) {__memReverse((STREAM), &VAL, LEN);} + #define __checkReverseOn(STREAM, VAL) __checkReverse(STREAM, VAL, sizeof(VAL)) #else #define __writeBytes(STREAM, VAL, LEN) Stream_writeBytes((STREAM), (VAL), (LEN)) #define __readBytes(STREAM, VAL, LEN) Stream_readBytes((STREAM), (VAL), (LEN)) #define __getBytesAt(STREAM, INDEX, VAL, LEN) Stream_getBytesAt((STREAM), (INDEX), (VAL), (LEN)) + #define __checkReverse(STREAM, VAL, LEN) #define __checkReverseOn(STREAM, VAL) #endif // STREAM_BYTE_ORDER #define __checkReverseOff(STREAM, VAL) -#define __readValue(TY, VAL_TY) \ -VAL_TY Stream_read ##TY(StreamBuffer* stream) { \ - VAL_TY val = STREAM_READ_DEFAULT_VALUE; \ - __readBytes(stream, (uint8_t*) &val, sizeof(val)); \ - return val; \ -} - #define __getValueAt(TY, VAL_TY) \ VAL_TY Stream_get ##TY ##At(StreamBuffer* stream, Stream_LenType index) { \ VAL_TY val = STREAM_READ_DEFAULT_VALUE; \ @@ -977,6 +972,11 @@ Stream_Result Stream_readStream(StreamBuffer* in, StreamBuffer* out, Stream_LenT /* ------------------------------------ General GetAt APIs ---------------------------------- */ #if STREAM_GET_AT_FUNCTIONS +Stream_Value Stream_getValueAt(StreamBuffer* stream, Stream_LenType index, Stream_LenType len) { + Stream_Value val = {0}; + __getBytesAt(stream, index, (uint8_t*) &val, len); + return val; +} Stream_Result Stream_getBytesAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len) { #if STREAM_CHECK_ZERO_LEN if (len == 0) { @@ -1003,6 +1003,7 @@ Stream_Result Stream_getBytesAt(StreamBuffer* stream, Stream_LenType index, uint return Stream_Ok; } +#if STREAM_GET_AT_BYTES_REVERSE Stream_Result Stream_getBytesReverseAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len) { #if STREAM_CHECK_ZERO_LEN if (len == 0) { @@ -1032,23 +1033,9 @@ Stream_Result Stream_getBytesReverseAt(StreamBuffer* stream, Stream_LenType inde Stream_Result Stream_getAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len) { return __getBytesAt(stream, index, val, len); } +#endif // STREAM_GET_AT_BYTES_REVERSE /* ------------------------------------ GetAt Value Array APIs ---------------------------------- */ -__getValueAt(Char, char) -__getValueAt(UInt8, uint8_t) -__getValueAt(Int8, int8_t) -__getValueAt(UInt16, uint16_t) -__getValueAt(Int16, int16_t) -__getValueAt(UInt32, uint32_t) -__getValueAt(Int32, int32_t) -__getValueAt(Float, float) -#if STREAM_UINT64 - __getValueAt(UInt64, uint64_t) - __getValueAt(Int64, int64_t) -#endif // STREAM_UINT64 -#if STREAM_DOUBLE - __getValueAt(Double, double) -#endif // STREAM_DOUBLE -/* ------------------------------------ GetAt Value Array APIs ---------------------------------- */ +#if STREAM_GET_AT_ARRAY Stream_Result Stream_getArrayAt(StreamBuffer* stream, Stream_LenType index, void* val, Stream_LenType itemLen, Stream_LenType len) { Stream_Result result; #if STREAM_CHECK_ZERO_LEN @@ -1069,6 +1056,7 @@ Stream_Result Stream_getArrayAt(StreamBuffer* stream, Stream_LenType index, void } return Stream_Ok; } +#endif // STREAM_GET_AT_ARRAY #endif // STREAM_GET_AT_FUNCTIONS /* ------------------------------------ Write Value Array APIs ---------------------------------- */ #if STREAM_WRITE_ARRAY @@ -1252,6 +1240,10 @@ void Stream_unlockReadIgnore(StreamBuffer* stream) { #endif // STREAM_READ_LOCK #if STREAM_FIND_AT_FUNCTIONS +Stream_LenType Stream_findValueAt(StreamBuffer* stream, Stream_LenType offset, Stream_Value val, Stream_LenType len) { + __checkReverse(stream, val, len); + return Stream_findPatternAt(stream, offset, (uint8_t*) &val, len); +} Stream_LenType Stream_findByteAt(StreamBuffer* stream, Stream_LenType offset, uint8_t val) { Stream_LenType tmpLen = 0; uint8_t* pStart = Stream_getReadPtrAt(stream, offset); @@ -1318,22 +1310,6 @@ Stream_LenType Stream_readBytesUntilPatternAt(StreamBuffer* stream, Stream_LenTy return 0; } - -__findValueAt(Char, char, Off) -__findValueAt(UInt8, uint8_t, Off) -__findValueAt(Int8, int8_t, Off) -__findValueAt(UInt16, uint16_t, On) -__findValueAt(Int16, int16_t, On) -__findValueAt(UInt32, uint32_t, On) -__findValueAt(Int32, int32_t, On) -__findValueAt(Float, float, On) -#if STREAM_UINT64 - __findValueAt(UInt64, uint64_t, On) - __findValueAt(Int64, int64_t, On) -#endif // STREAM_UINT64 -#if STREAM_DOUBLE - __findValueAt(Double, double, On) -#endif // STREAM_DOUBLE #endif // STREAM_FIND_AT_FUNCTIONS /** * @brief compare a given bytes at index with available bytes in stream diff --git a/Src/StreamBuffer.h b/Src/StreamBuffer.h index 01c86cc..ba8e017 100644 --- a/Src/StreamBuffer.h +++ b/Src/StreamBuffer.h @@ -18,7 +18,7 @@ extern "C" { #include #define STREAM_VER_MAJOR 0 -#define STREAM_VER_MINOR 7 +#define STREAM_VER_MINOR 8 #define STREAM_VER_FIX 0 /************************************************************************/ @@ -103,10 +103,26 @@ extern "C" { * @brief enable getAt functions */ #define STREAM_GET_AT_FUNCTIONS 1 +/** + * @brief enable getBytesReverseAt functions + */ +#define STREAM_GET_AT_BYTES_REVERSE 1 +/** + * @brief enable getAtArray functions + */ +#define STREAM_GET_AT_ARRAY 1 /** * @brief enable get functions */ #define STREAM_GET_FUNCTIONS 1 +/** + * @brief enable getBytesReverse functions + */ +#define STREAM_GET_BYTES_REVERSE 1 +/** + * @brief enable getArray functions + */ +#define STREAM_GET_ARRAY 1 /** * @brief enable findAt functions */ @@ -115,6 +131,14 @@ extern "C" { * @brief enable find functions */ #define STREAM_FIND_FUNCTIONS 1 +/** + * @brief enable readBytesUntilAt functions + */ +#define STREAM_READ_UNTIL_AT 1 +/** + * @brief enable readBytesUntil functions + */ +#define STREAM_READ_UNTIL 1 /** * @brief enable cursor object for check how many bytes read or write */ @@ -415,7 +439,6 @@ Stream_Result Stream_writeBytes(StreamBuffer* stream, uint8_t* val, Stream_LenTy Stream_Result Stream_writePadding(StreamBuffer* stream, uint8_t val, Stream_LenType len); #endif /* ------------------------------------ Write Value APIs ---------------------------------- */ -//Stream_Result Stream_writeStr(StreamBuffer* stream, const char* val); #define Stream_writeStr(STREAM, VAL) Stream_writeBytes((STREAM), (uint8_t*) VAL, strlen(VAL)) #define Stream_writeChar(STREAM, VAL) Stream_write((STREAM), (uint8_t*) &(char) { VAL }, sizeof(char)) #define Stream_writeUInt8(STREAM, VAL) Stream_write((STREAM), (uint8_t*) &(uint8_t) { VAL }, sizeof(uint8_t)) @@ -452,8 +475,8 @@ Stream_Result Stream_writeArray(StreamBuffer* stream, void* val, Stream_LenType #endif // STREAM_DOUBLE #endif // STREAM_WRITE_ARRAY /* ------------------------------------ General Read APIs ---------------------------------- */ -Stream_Result Stream_readBytes(StreamBuffer* stream, uint8_t* val, Stream_LenType len); Stream_Value Stream_readValue(StreamBuffer* stream, Stream_LenType len); +Stream_Result Stream_readBytes(StreamBuffer* stream, uint8_t* val, Stream_LenType len); #if STREAM_READ_REVERSE Stream_Result Stream_readBytesReverse(StreamBuffer* stream, uint8_t* val, Stream_LenType len); Stream_Result Stream_read(StreamBuffer* stream, uint8_t* val, Stream_LenType len); @@ -472,7 +495,6 @@ Stream_Value Stream_readValue(StreamBuffer* stream, Stream_LenType len); #define Stream_readUInt32Safe(STREAM, VAL) Stream_read((STREAM), (uint8_t*) &VAL, sizeof(VAL)) #define Stream_readInt32Safe(STREAM, VAL) Stream_read((STREAM), (uint8_t*) &VAL, sizeof(VAL)) #define Stream_readFloatSafe(STREAM, VAL) Stream_read((STREAM), (uint8_t*) &VAL, sizeof(VAL)) - #if STREAM_UINT64 #define Stream_readUInt64Safe(STREAM, VAL) Stream_read((STREAM), (uint8_t*) &VAL, sizeof(VAL)) #define Stream_readInt64Safe(STREAM, VAL) Stream_read((STREAM), (uint8_t*) &VAL, sizeof(VAL)) @@ -497,6 +519,7 @@ Stream_Value Stream_readValue(StreamBuffer* stream, Stream_LenType len); #define Stream_readDouble(STREAM) Stream_readValue((STREAM), sizeof(double)).Double #endif // STREAM_DOUBLE /* ------------------------------------ Read Value Array APIs ---------------------------------- */ +#if STREAM_READ_ARRAY Stream_Result Stream_readArray(StreamBuffer* stream, void* val, Stream_LenType itemLen, Stream_LenType len); #define Stream_readCharArray(STREAM, VAL, LEN) Stream_readArray((STREAM), VAL, sizeof(char), LEN) #define Stream_readUInt8Array(STREAM, VAL, LEN) Stream_readArray((STREAM), VAL, sizeof(uint8_t), LEN) @@ -513,11 +536,17 @@ Stream_Result Stream_readArray(StreamBuffer* stream, void* val, Stream_LenType i #if STREAM_DOUBLE #define Stream_readDoubleArray(STREAM, VAL, LEN) Stream_readArray((STREAM), VAL, sizeof(double), LEN) #endif // STREAM_DOUBLE +#endif // STREAM_READ_ARRAY /* ------------------------------------ General GetAt APIs ---------------------------------- */ #if STREAM_GET_AT_FUNCTIONS +Stream_Value Stream_getValueAt(StreamBuffer* stream, Stream_LenType index, Stream_LenType len); Stream_Result Stream_getBytesAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len); -Stream_Result Stream_getBytesReverseAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len); -Stream_Result Stream_getAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len); +#if STREAM_GET_AT_BYTES_REVERSE + Stream_Result Stream_getBytesReverseAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len); + Stream_Result Stream_getAt(StreamBuffer* stream, Stream_LenType index, uint8_t* val, Stream_LenType len); +#else + #define Stream_getAt(STREAM, IDX, VAL, LEN) Stream_getBytesAt((STREAM), (IDX), (VAL), (LEN)) +#endif /* ------------------------------------ GetAt Value Safe APIs ---------------------------------- */ #define Stream_getCharAtSafe(STREAM, IDX, VAL) Stream_getAt((STREAM), (IDX), (uint8_t*) &VAL, sizeof(VAL)) #define Stream_getUInt8AtSafe(STREAM, IDX, VAL) Stream_getAt((STREAM), (IDX), (uint8_t*) &VAL, sizeof(VAL)) @@ -535,44 +564,65 @@ Stream_Result Stream_getAt(StreamBuffer* stream, Stream_LenType index, uint8_t* #define Stream_getDoubleAtSafe(STREAM, IDX, VAL) Stream_getAt((STREAM), (IDX), (uint8_t*) &VAL, sizeof(VAL)) #endif // STREAM_DOUBLE /* ------------------------------------ GetAt Value APIs ---------------------------------- */ -char Stream_getCharAt(StreamBuffer* stream, Stream_LenType index); -uint8_t Stream_getUInt8At(StreamBuffer* stream, Stream_LenType index); -int8_t Stream_getInt8At(StreamBuffer* stream, Stream_LenType index); -uint16_t Stream_getUInt16At(StreamBuffer* stream, Stream_LenType index); -int16_t Stream_getInt16At(StreamBuffer* stream, Stream_LenType index); -uint32_t Stream_getUInt32At(StreamBuffer* stream, Stream_LenType index); -int32_t Stream_getInt32At(StreamBuffer* stream, Stream_LenType index); -float Stream_getFloatAt(StreamBuffer* stream, Stream_LenType index); +#define Stream_getCharAt(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(char)).Char +#define Stream_getUInt8At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(uint8_t)).UInt8 +#define Stream_getInt8At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(int8_t)).Int8 +#define Stream_getUInt16At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(uint16_t)).UInt16 +#define Stream_getInt16At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(int16_t)).Int16 +#define Stream_getUInt32At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(uint32_t)).UInt32 +#define Stream_getInt32At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(int32_t)).Int32 +#define Stream_getFloatAt(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(float)).Float #if STREAM_UINT64 - uint64_t Stream_getUInt64At(StreamBuffer* stream, Stream_LenType index); - int64_t Stream_getInt64At(StreamBuffer* stream, Stream_LenType index); + #define Stream_getUInt64At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(uint64_t)).UInt64 + #define Stream_getInt64At(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(int64_t)).Int64 #endif // STREAM_UINT64 #if STREAM_DOUBLE - double Stream_getDoubleAt(StreamBuffer* stream, Stream_LenType index); + #define Stream_getDoubleAt(STREAM, IDX) Stream_getValueAt((STREAM), (IDX), sizeof(double)).Double #endif // STREAM_DOUBLE /* ------------------------------------ GetAt Value Array APIs ---------------------------------- */ +#if STREAM_GET_AT_ARRAY Stream_Result Stream_getArrayAt(StreamBuffer* stream, Stream_LenType index, void* val, Stream_LenType itemLen, Stream_LenType len); -#define Stream_getCharArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(char), (LEN)) -#define Stream_getUInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint8_t), (LEN)) -#define Stream_getInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int8_t), (LEN)) -#define Stream_getUInt16ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint16_t), (LEN)) -#define Stream_getInt16ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int16_t), (LEN)) -#define Stream_getUInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint32_t), (LEN)) -#define Stream_getInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int32_t), (LEN)) -#define Stream_getFloatArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(float), (LEN)) +#define Stream_getCharArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(char), (LEN)) +#define Stream_getUInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint8_t), (LEN)) +#define Stream_getInt8ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int8_t), (LEN)) +#define Stream_getUInt16ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint16_t), (LEN)) +#define Stream_getInt16ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int16_t), (LEN)) +#define Stream_getUInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint32_t), (LEN)) +#define Stream_getInt32ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int32_t), (LEN)) +#define Stream_getFloatArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(float), (LEN)) #if STREAM_UINT64 - #define Stream_getUInt64ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint64_t), (LEN)) - #define Stream_getInt64ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int64_t), (LEN)) + #define Stream_getUInt64ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(uint64_t), (LEN)) + #define Stream_getInt64ArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(int64_t), (LEN)) #endif // STREAM_UINT64 #if STREAM_DOUBLE - #define Stream_getDoubleArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(double), (LEN)) + #define Stream_getDoubleArrayAt(STREAM, IDX, VAL, LEN) Stream_getArrayAt((STREAM), (IDX), (VAL), sizeof(double), (LEN)) #endif // STREAM_DOUBLE +#endif // STREAM_GET_AT_ARRAY #endif // STREAM_GET_AT_FUNCTION /* ------------------------------------ General Get APIs ---------------------------------- */ #if STREAM_GET_AT_FUNCTIONS && STREAM_GET_FUNCTIONS -#define Stream_getBytes(STREAM, VAL, LEN) Stream_getBytesAt((STREAM), 0, (VAL), (LEN)) -#define Stream_getBytesReverse(STREAM, VAL, LEN) Stream_getBytesReverseAt((STREAM), 0, (VAL), (LEN)) -#define Stream_get(STREAM, VAL, LEN) Stream_getAt((STREAM), 0, (VAL), (LEN)) +#define Stream_getValue(STREAM, LEN, IDX) Stream_getValueAt((STREAM), (LEN), (IDX)) +#define Stream_getBytes(STREAM, VAL, LEN) Stream_getBytesAt((STREAM), 0, (VAL), (LEN)) +#if STREAM_GET_BYTES_REVERSE + #define Stream_getBytesReverse(STREAM, VAL, LEN) Stream_getBytesReverseAt((STREAM), 0, (VAL), (LEN)) + #define Stream_get(STREAM, VAL, LEN) Stream_getAt((STREAM), 0, (VAL), (LEN)) +#endif +/* ------------------------------------ Get Value Safe APIs ---------------------------------- */ +#define Stream_getCharSafe(STREAM, VAL) Stream_getCharAtSafe((STREAM), 0, VAL) +#define Stream_getUInt8Safe(STREAM, VAL) Stream_getUInt8AtSafe((STREAM), 0, VAL) +#define Stream_getInt8Safe(STREAM, VAL) Stream_getInt8AtSafe((STREAM), 0, VAL) +#define Stream_getUInt16Safe(STREAM, VAL) Stream_getUInt16AtSafe((STREAM), 0, VAL) +#define Stream_getInt16Safe(STREAM, VAL) Stream_getInt16AtSafe((STREAM), 0, VAL) +#define Stream_getUInt32Safe(STREAM, VAL) Stream_getUInt32AtSafe((STREAM), 0, VAL) +#define Stream_getInt32Safe(STREAM, VAL) Stream_getInt32AtSafe((STREAM), 0, VAL) +#define Stream_getFloatSafe(STREAM, VAL) Stream_getFloatAtSafe((STREAM), 0, VAL) +#if STREAM_UINT64 + #define Stream_getUInt64Safe(STREAM, VAL) Stream_getUInt64AtSafe((STREAM), 0, VAL) + #define Stream_getInt64Safe(STREAM, VAL) Stream_getInt64AtSafe((STREAM), 0, VAL) +#endif // STREAM_UINT64 +#if STREAM_DOUBLE + #define Stream_getDoubleSafe(STREAM, VAL) Stream_getDoubleAtSafe((STREAM), 0, VAL) +#endif // STREAM_DOUBLE /* ------------------------------------ Get Value APIs ---------------------------------- */ #define Stream_getChar(STREAM) Stream_getCharAt((STREAM), 0) #define Stream_getUInt8(STREAM) Stream_getUInt8At((STREAM), 0) @@ -590,6 +640,8 @@ Stream_Result Stream_getArrayAt(StreamBuffer* stream, Stream_LenType index, void #define Stream_getDouble(STREAM) Stream_getDoubleAt((STREAM), 0) #endif // STREAM_DOUBLE /* ------------------------------------ Get Value Array APIs ---------------------------------- */ +#if STREAM_GET_ARRAY +#define Stream_getArray(STREAM, VAL, ITEM_LEN, LEN) Stream_getArrayAt((STREAM), 0, (VAL), (ITEM_LEN), (LEN)) #define Stream_getCharArray(STREAM, VAL, LEN) Stream_getCharArrayAt((STREAM), 0, (VAL), (LEN)) #define Stream_getUInt8Array(STREAM, VAL, LEN) Stream_getUInt8ArrayAt((STREAM), 0, (VAL), (LEN)) #define Stream_getInt8Array(STREAM, VAL, LEN) Stream_getInt8ArrayAt((STREAM), 0, (VAL), (LEN)) @@ -605,54 +657,62 @@ Stream_Result Stream_getArrayAt(StreamBuffer* stream, Stream_LenType index, void #if STREAM_DOUBLE #define Stream_getDoubleArray(STREAM, VAL, LEN) Stream_getDoubleArrayAt((STREAM), 0, (VAL), (LEN)) #endif // STREAM_DOUBLE -#endif // STREAM_GET_FUNCTIONS -/* ------------------------------------ Find APIs ---------------------------------- */ -#if STREAM_FIND_AT_FUNCTIONS +#endif // STREAM_GET_ARRAY +#endif // STREAM_GET_FUNCTIONS && STREAM_GET_AT_FUNCTIONS /* ------------------------------------ General Find At APIs ---------------------------------- */ - Stream_LenType Stream_findByteAt(StreamBuffer* stream, Stream_LenType offset, uint8_t val); - Stream_LenType Stream_findPatternAt(StreamBuffer* stream, Stream_LenType offset, const uint8_t* pat, Stream_LenType patLen); - - Stream_LenType Stream_findCharAt(StreamBuffer* stream, Stream_LenType offset, char val); - Stream_LenType Stream_findUInt8At(StreamBuffer* stream, Stream_LenType offset, uint8_t val); - Stream_LenType Stream_findInt8At(StreamBuffer* stream, Stream_LenType offset, int8_t val); - Stream_LenType Stream_findUInt16At(StreamBuffer* stream, Stream_LenType offset, uint16_t val); - Stream_LenType Stream_findInt16At(StreamBuffer* stream, Stream_LenType offset, int16_t val); - Stream_LenType Stream_findUInt32At(StreamBuffer* stream, Stream_LenType offset, uint32_t val); - Stream_LenType Stream_findInt32At(StreamBuffer* stream, Stream_LenType offset, int32_t val); +#if STREAM_FIND_AT_FUNCTIONS +Stream_LenType Stream_findValueAt(StreamBuffer* stream, Stream_LenType offset, Stream_Value val, Stream_LenType len); +Stream_LenType Stream_findByteAt(StreamBuffer* stream, Stream_LenType offset, uint8_t val); +Stream_LenType Stream_findPatternAt(StreamBuffer* stream, Stream_LenType offset, const uint8_t* pat, Stream_LenType patLen); + + #define Stream_findCharAt(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Char = (VAL) }, sizeof(char)) + #define Stream_findUInt8At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .UInt8 = (VAL) }, sizeof(uint8_t)) + #define Stream_findInt8At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Int8 = (VAL) }, sizeof(int8_t)) + #define Stream_findUInt16At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .UInt16 = (VAL) }, sizeof(uint16_t)) + #define Stream_findInt16At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Int16 = (VAL) }, sizeof(int16_t)) + #define Stream_findUInt32At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .UInt32 = (VAL) }, sizeof(uint32_t)) + #define Stream_findInt32At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Int32 = (VAL) }, sizeof(int32_t)) + #define Stream_findFloatAt(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Float = (VAL) }, sizeof(float)) #if STREAM_UINT64 - Stream_LenType Stream_findUInt64At(StreamBuffer* stream, Stream_LenType offset, uint64_t val); - Stream_LenType Stream_findInt64At(StreamBuffer* stream, Stream_LenType offset, int64_t val); -#endif - Stream_LenType Stream_findFloatAt(StreamBuffer* stream, Stream_LenType offset, float val); + #define Stream_findUInt64At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .UInt64 = (VAL) }, sizeof(uint64_t)) + #define Stream_findInt64At(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Int64 = (VAL) }, sizeof(int64_t)) +#endif // STREAM_UINT64 #if STREAM_DOUBLE - Stream_LenType Stream_findDoubleAt(StreamBuffer* stream, Stream_LenType offset, double val); -#endif - Stream_LenType Stream_readBytesUntilAt(StreamBuffer* stream, Stream_LenType offset, uint8_t end, uint8_t* val, Stream_LenType len); - Stream_LenType Stream_readBytesUntilPatternAt(StreamBuffer* stream, Stream_LenType offset, const uint8_t* pat, Stream_LenType patLen, uint8_t* val, Stream_LenType len); + #define Stream_findDoubleAt(STREAM, IDX, VAL) Stream_findValueAt((STREAM), IDX, (Stream_Value) { .Double = (VAL) }, sizeof(double)) +#endif // STREAM_DOUBLE +#endif // STREAM_FIND_AT_FUNCTIONS /* ------------------------------------ General Find APIs ---------------------------------- */ -#if STREAM_FIND_FUNCTIONS - #define Stream_findByte(STREAM, VAL) Stream_findByteAt((STREAM), 0, (VAL)) - #define Stream_findPattern(STREAM, PAT, PAT_LEN) Stream_findPatternAt((STREAM), 0, (PAT), (PAT_LEN)) - - #define Stream_findChar(STREAM, VAL) Stream_findCharAt((STREAM), 0, (VAL)) - #define Stream_findUInt8(STREAM, VAL) Stream_findUInt8At((STREAM), 0, (VAL)) - #define Stream_findInt8(STREAM, VAL) Stream_findInt8At((STREAM), 0, (VAL)) - #define Stream_findUInt16(STREAM, VAL) Stream_findUInt16At((STREAM), 0, (VAL)) - #define Stream_findInt16(STREAM, VAL) Stream_findInt16At((STREAM), 0, (VAL)) - #define Stream_findUInt32(STREAM, VAL) Stream_findUInt32At((STREAM), 0, (VAL)) - #define Stream_findInt32(STREAM, VAL) Stream_findInt32At((STREAM), 0, (VAL)) +#if STREAM_FIND_FUNCTIONS && STREAM_FIND_AT_FUNCTIONS + #define Stream_findValue(STREAM, VAL, LEN) Stream_findValueAt((STREAM), 0, (VAL), (LEN)) + #define Stream_findByte(STREAM, VAL) Stream_findByteAt((STREAM), 0, (VAL)) + #define Stream_findPattern(STREAM, PAT, PAT_LEN) Stream_findPatternAt((STREAM), 0, (PAT), (PAT_LEN)) + + #define Stream_findChar(STREAM, VAL) Stream_findCharAt((STREAM), 0, (VAL)) + #define Stream_findUInt8(STREAM, VAL) Stream_findUInt8At((STREAM), 0, (VAL)) + #define Stream_findInt8(STREAM, VAL) Stream_findInt8At((STREAM), 0, (VAL)) + #define Stream_findUInt16(STREAM, VAL) Stream_findUInt16At((STREAM), 0, (VAL)) + #define Stream_findInt16(STREAM, VAL) Stream_findInt16At((STREAM), 0, (VAL)) + #define Stream_findUInt32(STREAM, VAL) Stream_findUInt32At((STREAM), 0, (VAL)) + #define Stream_findInt32(STREAM, VAL) Stream_findInt32At((STREAM), 0, (VAL)) #if STREAM_UINT64 - #define Stream_findUInt64(STREAM, VAL) Stream_findUInt64At((STREAM), 0, (VAL)) - #define Stream_findInt64(STREAM, VAL) Stream_findInt64At((STREAM), 0, (VAL)) -#endif - #define Stream_findFloat(STREAM, VAL) Stream_findFloatAt((STREAM), 0, (VAL)) + #define Stream_findUInt64(STREAM, VAL) Stream_findUInt64At((STREAM), 0, (VAL)) + #define Stream_findInt64(STREAM, VAL) Stream_findInt64At((STREAM), 0, (VAL)) +#endif // STREAM_UINT64 + #define Stream_findFloat(STREAM, VAL) Stream_findFloatAt((STREAM), 0, (VAL)) #if STREAM_DOUBLE - #define Stream_findDouble(STREAM, VAL) Stream_findDoubleAt((STREAM), 0, (VAL)) -#endif - #define Stream_readBytesUntil(STREAM, END, VAL, LEN) Stream_readBytesUntilAt((STREAM), 0, (END), (VAL), (LEN)) - #define Stream_readBytesUntilPattern(STREAM, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPatternAt((STREAM), 0, (PAT), (PAT_LEN), (VAL), (VAL_LEN)) -#endif // STREAM_FIND_FUNCTIONS -#endif // STREAM_FIND_AT_FUNCTIONS + #define Stream_findDouble(STREAM, VAL) Stream_findDoubleAt((STREAM), 0, (VAL)) +#endif // STREAM_DOUBLE +#endif // STREAM_FIND_AT_FUNCTIONS && STREAM_FIND_FUNCTIONS +/* ------------------------------------ Read Bytes Until At APIs ---------------------------------- */ +#if STREAM_READ_UNTIL_AT && STREAM_FIND_AT_FUNCTIONS +Stream_LenType Stream_readBytesUntilAt(StreamBuffer* stream, Stream_LenType offset, uint8_t end, uint8_t* val, Stream_LenType len); +Stream_LenType Stream_readBytesUntilPatternAt(StreamBuffer* stream, Stream_LenType offset, const uint8_t* pat, Stream_LenType patLen, uint8_t* val, Stream_LenType len); +#endif // STREAM_READ_UNTIL_AT +/* ------------------------------------ Read Bytes Until APIs ---------------------------------- */ +#if STREAM_READ_UNTIL && STREAM_FIND_AT_FUNCTIONS +#define Stream_readBytesUntil(STREAM, END, VAL, LEN) Stream_readBytesUntilAt((STREAM), 0, (END), (VAL), (LEN)) +#define Stream_readBytesUntilPattern(STREAM, PAT, PAT_LEN, VAL, LEN) Stream_readBytesUntilPatternAt((STREAM), 0, (PAT), (PAT_LEN), (VAL), (VAL_LEN)) +#endif // STREAM_READ_UNTIL /* ------------------------------------ Compare APIs ---------------------------------- */ int8_t Stream_compareAt(StreamBuffer* stream, Stream_LenType index, const uint8_t* val, Stream_LenType len); #define Stream_compare(STREAM, VAL, LEN) Stream_compareAt((STREAM), 0, (VAL), (LEN))