Callisto4Bootloader: ARK/platform_encoder.h Source File

Callisto4Bootloader

platform_encoder.h
Go to the documentation of this file.
1 /*
2 * platform_encoder.h
3 *
4 * Created on: 27 Jul 2020
5 * Author: Nick Pelling
6 */
7
8 #ifndef PLATFORM_ENCODER_H_
9 #define PLATFORM_ENCODER_H_
10
11 #include <stdint.h>
12 #include <stdbool.h>
13
14 typedef struct
15 {
16 uint8_t u8OwnerIndex; // OBJECTOWNERINDEX_PLATFORM, OBJECTOWNERINDEX_PLUGIN(N), etc
17 const char * pachTypeName;
18 } stFoundType_t;
19
20 typedef struct
21 {
22 uint8_t * pau8Buffer;
23 uint32_t uiBufferLen;
24 uint32_t uiBufferSize;
25 bool bWasMalloced;
26
27 stFoundType_t * pastFoundTypes;
28 uint32_t uiFoundTypesNum;
29 uint32_t uiFoundTypesAlloced;
30 } stPayloadBuffer_t;
31
32 typedef struct
33 {
34 // Encoder virtual methods
35 void (*pfn_EncodeStructStart)(stPayloadBuffer_t * pstPayload);
36 void (*pfn_EncodeStructEnd)(stPayloadBuffer_t * pstPayload);
37 void (*pfn_EncodeArrayStart)(stPayloadBuffer_t * pstPayload);
38 void (*pfn_EncodeArraySeparator)(stPayloadBuffer_t * pstPayload);
39 void (*pfn_EncodeArrayEnd)(stPayloadBuffer_t * pstPayload);
40 void (*pfn_EncodeFieldName)(stPayloadBuffer_t * pstPayload, const uint8_t *pau8FieldName);
41 void (*pfn_EncodeFieldSeparator)(stPayloadBuffer_t * pstPayload);
42 void (*pfn_EncodeBoolean)(stPayloadBuffer_t * pstPayload, bool bValue);
43 void (*pfn_EncodeSignedInt)(stPayloadBuffer_t * pstPayload, int64_t i64Value);
44 void (*pfn_EncodeUnsignedInt)(stPayloadBuffer_t * pstPayload, uint64_t ui64Value);
45 void (*pfn_EncodeReal)(stPayloadBuffer_t * pstPayload, double dValue);
46 void (*pfn_EncodeString)(stPayloadBuffer_t * pstPayload, const uint8_t * pau8String);
47 } stPayloadEncoder_t;
48
49 typedef struct
50 {
51 // Decoder/Parser virtual methods
52 bool (*pfn_DecodeStructStart)(stPayloadBuffer_t * pstPayload);
53 bool (*pfn_DecodeStructEnd)(stPayloadBuffer_t * pstPayload);
54 bool (*pfn_DecodeArrayStart)(stPayloadBuffer_t * pstPayload);
55 bool (*pfn_DecodeArraySeparator)(stPayloadBuffer_t * pstPayload);
56 bool (*pfn_DecodeArrayEnd)(stPayloadBuffer_t * pstPayload);
57 bool (*pfn_DecodeFieldName)(stPayloadBuffer_t * pstPayload, const uint8_t ** pau8FieldName, uint32_t * puiNameLength);
58 bool (*pfn_DecodeFieldSeparator)(stPayloadBuffer_t * pstPayload);
59 bool (*pfn_DecodeBoolean)(stPayloadBuffer_t * pstPayload, bool * pbValue);
60 bool (*pfn_DecodeSignedInt)(stPayloadBuffer_t * pstPayload, int64_t * pi64Value);
61 bool (*pfn_DecodeUnsignedInt)(stPayloadBuffer_t * pstPayload, uint64_t * pui64Value);
62 bool (*pfn_DecodeReal)(stPayloadBuffer_t * pstPayload, double * pdValue);
63 bool (*pfn_DecodeString)(stPayloadBuffer_t * pstPayload, const uint8_t ** ppau8String, uint32_t *puiStringLength);
64 } stPayloadDecoder_t;
65
66 // Defined in platform_json_encoder.c
67 extern const stPayloadEncoder_t stJSONEncoder;
68 extern const stPayloadDecoder_t stJSONDecoder;
69
70 // Defined in platform_cbor_encoder.c
71 extern const stPayloadEncoder_t stCBOREncoder;
72 extern const stPayloadDecoder_t stCBORDecoder;
73
74 const stPayloadEncoder_t * PayloadEncoder_Get(uint16_t ui16MediaType);
75 const stPayloadDecoder_t * PayloadDecoder_Get(uint16_t ui16MediaType);
76
77 #endif /* PLATFORM_ENCODER_H_ */
stPayloadBuffer_t::uiBufferLen
uint32_t uiBufferLen
Definition: platform_encoder.h:23
PayloadDecoder_Get
const stPayloadDecoder_t * PayloadDecoder_Get(uint16_t ui16MediaType)
Definition: platform_encoder.c:40
stCBORDecoder
const stPayloadDecoder_t stCBORDecoder
Definition: platform_encoder_cbor.c:333
stPayloadBuffer_t::bWasMalloced
bool bWasMalloced
Definition: platform_encoder.h:25
stPayloadBuffer_t
Definition: platform_encoder.h:20
stJSONDecoder
const stPayloadDecoder_t stJSONDecoder
Definition: platform_encoder_json.c:533
stPayloadBuffer_t::uiFoundTypesNum
uint32_t uiFoundTypesNum
Definition: platform_encoder.h:28
stFoundType_t::pachTypeName
const char * pachTypeName
Definition: platform_encoder.h:17
stPayloadBuffer_t::uiFoundTypesAlloced
uint32_t uiFoundTypesAlloced
Definition: platform_encoder.h:29
stFoundType_t::u8OwnerIndex
uint8_t u8OwnerIndex
Definition: platform_encoder.h:16
stCBOREncoder
const stPayloadEncoder_t stCBOREncoder
Definition: platform_encoder_cbor.c:316
stFoundType_t
Definition: platform_encoder.h:14
stPayloadBuffer_t::pau8Buffer
uint8_t * pau8Buffer
Definition: platform_encoder.h:22
stPayloadBuffer_t::uiBufferSize
uint32_t uiBufferSize
Definition: platform_encoder.h:24
PayloadEncoder_Get
const stPayloadEncoder_t * PayloadEncoder_Get(uint16_t ui16MediaType)
Definition: platform_encoder.c:18
stPayloadBuffer_t::pastFoundTypes
stFoundType_t * pastFoundTypes
Definition: platform_encoder.h:27
stJSONEncoder
const stPayloadEncoder_t stJSONEncoder
Definition: platform_encoder_json.c:516
stPayloadDecoder_t
Definition: platform_encoder.h:49
stPayloadEncoder_t
Definition: platform_encoder.h:32