| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- File List
- File Members

erpc_basic_codec.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2014, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * Copyright 2021 ACRIOS Systems s.r.o.
5 * All rights reserved.
6 *
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 #ifndef _EMBEDDED_RPC__BASIC_SERIALIZATION_H_
12 #define _EMBEDDED_RPC__BASIC_SERIALIZATION_H_
13
14 #include "erpc_codec.h"
15
16 #include <new>
17
24 // Classes
27
28 namespace erpc {
32 enum _null_flag
33 {
34 kNotNull = 0,
35 kIsNull
36 };
37
43 class BasicCodec : public Codec
44 {
45 public:
46 static const uint8_t kBasicCodecVersion;
48 BasicCodec(void)
49 : Codec()
50 {
51 }
52
54
55
64 virtual void startWriteMessage(message_type_t type, uint32_t service, uint32_t request, uint32_t sequence) override;
65
72 virtual void writeData(const void *value, uint32_t length);
73
79 virtual void write(bool value) override;
80
86 virtual void write(int8_t value) override;
87
93 virtual void write(int16_t value) override;
94
100 virtual void write(int32_t value) override;
101
107 virtual void write(int64_t value) override;
108
114 virtual void write(uint8_t value) override;
115
121 virtual void write(uint16_t value) override;
122
128 virtual void write(uint32_t value) override;
129
135 virtual void write(uint64_t value) override;
136
142 virtual void write(float value) override;
143
149 virtual void write(double value) override;
150
156 virtual void writePtr(uintptr_t value) override;
157
164 virtual void writeString(uint32_t length, const char *value) override;
165
172 virtual void writeBinary(uint32_t length, const uint8_t *value) override;
173
179 virtual void startWriteList(uint32_t length) override;
180
186 virtual void startWriteUnion(int32_t discriminator) override;
187
193 virtual void writeNullFlag(bool isNull) override;
194
202 virtual void writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback) override;
203
210 virtual void writeCallback(funPtr callback1, funPtr callback2) override;
212
214
215
224 virtual void startReadMessage(message_type_t *type, uint32_t *service, uint32_t *request,
225 uint32_t *sequence) override;
226
233 virtual void readData(void *value, uint32_t length);
234
240 virtual void read(bool *value) override;
241
247 virtual void read(int8_t *value) override;
248
254 virtual void read(int16_t *value) override;
255
261 virtual void read(int32_t *value) override;
262
268 virtual void read(int64_t *value) override;
269
275 virtual void read(uint8_t *value) override;
276
282 virtual void read(uint16_t *value) override;
283
289 virtual void read(uint32_t *value) override;
290
296 virtual void read(uint64_t *value) override;
297
303 virtual void read(float *value) override;
304
310 virtual void read(double *value) override;
311
317 virtual void readPtr(uintptr_t *value) override;
318
325 virtual void readString(uint32_t *length, char **value) override;
326
333 virtual void readBinary(uint32_t *length, uint8_t **value) override;
334
340 virtual void startReadList(uint32_t *length) override;
341
347 virtual void startReadUnion(int32_t *discriminator) override;
348
354 virtual void readNullFlag(bool *isNull) override;
355
363 virtual void readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr *callback) override;
364
371 virtual void readCallback(funPtr callbacks1, funPtr *callback2) override;
373 };
374
380 class BasicCodecFactory : public CodecFactory
381 {
382 public:
388 virtual Codec *create(void) override { return new (std::nothrow) BasicCodec; }
389
395 virtual void dispose(Codec *codec) override { delete codec; }
396 };
397
398 } // namespace erpc
399
402 #endif // _EMBEDDED_RPC__BASIC_SERIALIZATION_H_
erpc::BasicCodec::startReadUnion
virtual void startReadUnion(int32_t *discriminator) override
Prototype for start read union.
Definition: erpc_basic_codec.cpp:330
erpc::BasicCodec::readNullFlag
virtual void readNullFlag(bool *isNull) override
Reads a flag indicating whether the next value is null.
Definition: erpc_basic_codec.cpp:336
erpc::BasicCodecFactory::dispose
virtual void dispose(Codec *codec) override
Dispose codec.
Definition: erpc_basic_codec.h:395
erpc::BasicCodec::kBasicCodecVersion
static const uint8_t kBasicCodecVersion
Definition: erpc_basic_codec.h:46
erpc::message_type_t
message_type_t
Types of messages that can be encoded.
Definition: erpc_codec.h:35
erpc::BasicCodec::writePtr
virtual void writePtr(uintptr_t value) override
Prototype for write uintptr value.
Definition: erpc_basic_codec.cpp:105
erpc::BasicCodec::startWriteUnion
virtual void startWriteUnion(int32_t discriminator) override
Prototype for start write union.
Definition: erpc_basic_codec.cpp:134
erpc::BasicCodec::startWriteMessage
virtual void startWriteMessage(message_type_t type, uint32_t service, uint32_t request, uint32_t sequence) override
Prototype for write header of message.
Definition: erpc_basic_codec.cpp:23
erpc::BasicCodec::startWriteList
virtual void startWriteList(uint32_t length) override
Prototype for start write list.
Definition: erpc_basic_codec.cpp:128
erpc::BasicCodec::readPtr
virtual void readPtr(uintptr_t *value) override
Prototype for read uintptr value.
Definition: erpc_basic_codec.cpp:273
erpc::BasicCodec::startReadList
virtual void startReadList(uint32_t *length) override
Prototype for start read list.
Definition: erpc_basic_codec.cpp:319
erpc::Codec
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:53
erpc::_null_flag
_null_flag
Values of the uint8 flag prefixing nullable values.
Definition: erpc_basic_codec.h:32
erpc::BasicCodec::writeCallback
virtual void writeCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr callback) override
Writes an order ID of callback function.
Definition: erpc_basic_codec.cpp:145
erpc_codec.h
erpc::BasicCodec::readCallback
virtual void readCallback(arrayOfFunPtr callbacks, uint8_t callbacksCount, funPtr *callback) override
Read an callback function id and return address of callback function.
Definition: erpc_basic_codec.cpp:347
erpc::CodecFactory
Abstract interface for codec factory.
Definition: erpc_codec.h:441
erpc::BasicCodec::read
virtual void read(bool *value) override
Prototype for read boolean value.
Definition: erpc_basic_codec.cpp:212
erpc::BasicCodec::readData
virtual void readData(void *value, uint32_t length)
Prototype for read data stream.
Definition: erpc_basic_codec.cpp:197
erpc::BasicCodec
Simple binary serialization format.
Definition: erpc_basic_codec.h:43
erpc::BasicCodec::writeBinary
virtual void writeBinary(uint32_t length, const uint8_t *value) override
Prototype for write binary value.
Definition: erpc_basic_codec.cpp:120
erpc
Definition: erpc_arbitrated_client_manager.h:25
erpc::BasicCodecFactory
Basic codec factory implements functions from codec factory.
Definition: erpc_basic_codec.h:380
erpc::BasicCodec::write
virtual void write(bool value) override
Prototype for write boolean value.
Definition: erpc_basic_codec.cpp:47
erpc::BasicCodecFactory::create
virtual Codec * create(void) override
Return created codec.
Definition: erpc_basic_codec.h:388
erpc::BasicCodec::startReadMessage
virtual void startReadMessage(message_type_t *type, uint32_t *service, uint32_t *request, uint32_t *sequence) override
Prototype for read header of message.
Definition: erpc_basic_codec.cpp:176
erpc::BasicCodec::writeData
virtual void writeData(const void *value, uint32_t length)
Prototype for write data stream.
Definition: erpc_basic_codec.cpp:32
erpc::BasicCodec::writeString
virtual void writeString(uint32_t length, const char *value) override
Prototype for write string value.
Definition: erpc_basic_codec.cpp:114
erpc::BasicCodec::readString
virtual void readString(uint32_t *length, char **value) override
Prototype for read string value.
Definition: erpc_basic_codec.cpp:287
erpc::BasicCodec::writeNullFlag
virtual void writeNullFlag(bool isNull) override
Writes a flag indicating whether the next value is null.
Definition: erpc_basic_codec.cpp:140
erpc::BasicCodec::readBinary
virtual void readBinary(uint32_t *length, uint8_t **value) override
Prototype for read binary value.
Definition: erpc_basic_codec.cpp:292