YAMI4Industry
serialization.h
Go to the documentation of this file.
1 /* Copyright Inspirel Sp. z o.o. 2013-2015.
2  * This file is part of YAMI4.
3  *
4  * YAMI4 is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * YAMI4 is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef YAMI4INDUSTRY_SERIALIZATION_H
19 #define YAMI4INDUSTRY_SERIALIZATION_H
20 
21 #include "common.h"
22 
23 #include <stddef.h>
24 #include <stdint.h>
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif /* __cplusplus */
30 
45 enum yami_result yami_put_type(uint8_t buffer[], size_t buffer_size,
46  size_t * buffer_position,
47  enum yami_parameter_type type);
48 
63 enum yami_result yami_get_type(const uint8_t buffer[], size_t buffer_size,
64  size_t * buffer_position,
65  enum yami_parameter_type * type);
66 
80 enum yami_result yami_put_integer(uint8_t buffer[], size_t buffer_size,
81  size_t * buffer_position,
82  int32_t value);
83 
97 enum yami_result yami_get_integer(const uint8_t buffer[], size_t buffer_size,
98  size_t * buffer_position,
99  int32_t * value);
100 
114 enum yami_result yami_put_long_long(uint8_t buffer[], size_t buffer_size,
115  size_t * buffer_position,
116  int64_t value);
117 
131 enum yami_result yami_get_long_long(const uint8_t buffer[], size_t buffer_size,
132  size_t * buffer_position,
133  int64_t * value);
134 
135 #ifdef YAMI4_WITH_DOUBLE_FLOAT
136 
150 enum yami_result yami_put_double_float(uint8_t buffer[], size_t buffer_size,
151  size_t * buffer_position,
152  double value);
153 
167 enum yami_result yami_get_double_float(const uint8_t buffer[], size_t buffer_size,
168  size_t * buffer_position,
169  double * value);
170 
171 #endif /* YAMI4_WITH_DOUBLE_FLOAT */
172 
190 enum yami_result yami_put_cstring(uint8_t buffer[], size_t buffer_size,
191  size_t * buffer_position,
192  const char value[]);
193 
212 enum yami_result yami_get_raw_cstring(const uint8_t buffer[], size_t buffer_size,
213  size_t * buffer_position,
214  char value[], size_t value_length);
215 
231 enum yami_result yami_put_binary(uint8_t buffer[], size_t buffer_size,
232  size_t * buffer_position,
233  const uint8_t value[], size_t value_length);
234 
252 enum yami_result yami_get_raw_binary(const uint8_t buffer[], size_t buffer_size,
253  size_t * buffer_position,
254  uint8_t value[], size_t value_length);
255 
273 enum yami_result yami_put_boolean_array(uint8_t buffer[], size_t buffer_size,
274  size_t * buffer_position,
275  const int32_t value[], size_t value_length);
276 
295 enum yami_result yami_get_raw_boolean_array(const uint8_t buffer[], size_t buffer_size,
296  size_t * buffer_position,
297  int32_t value[], size_t value_length);
298 
314 enum yami_result yami_put_integer_array(uint8_t buffer[], size_t buffer_size,
315  size_t * buffer_position,
316  const int32_t value[], size_t value_length);
317 
335 enum yami_result yami_get_raw_integer_array(const uint8_t buffer[], size_t buffer_size,
336  size_t * buffer_position,
337  int32_t value[], size_t value_length);
338 
354 enum yami_result yami_put_long_long_array(uint8_t buffer[], size_t buffer_size,
355  size_t * buffer_position,
356  const int64_t value[], size_t value_length);
357 
375 enum yami_result yami_get_raw_long_long_array(const uint8_t buffer[], size_t buffer_size,
376  size_t * buffer_position,
377  int64_t value[], size_t value_length);
378 
379 #ifdef YAMI4_WITH_DOUBLE_FLOAT
380 
396 enum yami_result yami_put_double_float_array(uint8_t buffer[], size_t buffer_size,
397  size_t * buffer_position,
398  const double value[], size_t value_length);
399 
417 enum yami_result yami_get_raw_double_float_array(const uint8_t buffer[], size_t buffer_size,
418  size_t * buffer_position,
419  double value[], size_t value_length);
420 
421 #endif /* YAMI4_WITH_DOUBLE_FLOAT */
422 
436 enum yami_result yami_skip_field(const uint8_t buffer[], size_t buffer_size,
437  size_t * buffer_position,
438  enum yami_parameter_type type);
439 
455 enum yami_result yami_fill_message_header(uint8_t buffer[], size_t buffer_size,
456  size_t * buffer_position,
457  const char object_name[], const char message_name[], int64_t message_id);
458 
473 void yami_fill_reply_header(uint8_t buffer[], size_t buffer_size,
474  size_t * buffer_position,
475  int64_t message_id);
476 
491 enum yami_result yami_fill_exception_header(uint8_t buffer[], size_t buffer_size,
492  size_t * buffer_position,
493  const char reason[], int64_t message_id);
494 
520 enum yami_result yami_parse_message_header(const uint8_t buffer[], size_t buffer_size,
521  size_t * buffer_position,
522  char out_header_type[], size_t header_type_size,
523  char out_object_name[], size_t object_name_size,
524  char out_message_name[], size_t message_name_size,
525  char out_reason[], size_t reason_size,
526  int64_t * out_message_id);
527 
528 void yami_fill_frame_header(uint8_t buffer[],
529  uint32_t message_id, size_t message_header_size, size_t frame_payload_size);
530 
531 enum yami_result yami_parse_frame_header(const uint8_t buffer[], size_t buffer_size,
532  size_t * buffer_position,
533  uint32_t * message_id,
534  size_t * message_header_size, size_t * frame_payload_size);
535 
536 #ifdef __cplusplus
537 }
538 #endif /* __cplusplus */
539 
540 #endif /* YAMI4INDUSTRY_SERIALIZATION_H */
enum yami_result yami_put_binary(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const uint8_t value[], size_t value_length)
Places binary value in the serialization buffer.
Definition: serialization.c:571
yami_parameter_type
Definition: common.h:43
enum yami_result yami_skip_field(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, enum yami_parameter_type type)
Skips the given field in serialization buffer.
Definition: serialization.c:1027
enum yami_result yami_parse_frame_header(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, uint32_t *message_id, size_t *message_header_size, size_t *frame_payload_size)
Definition: serialization.c:1709
void yami_fill_frame_header(uint8_t buffer[], uint32_t message_id, size_t message_header_size, size_t frame_payload_size)
Definition: serialization.c:1691
enum yami_result yami_get_raw_long_long_array(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int64_t value[], size_t value_length)
Reads raw long long array from the serialization buffer.
Definition: serialization.c:912
enum yami_result yami_get_raw_integer_array(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int32_t value[], size_t value_length)
Reads raw integer array from the serialization buffer.
Definition: serialization.c:836
yami_result
Definition: common.h:28
enum yami_result yami_get_raw_binary(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, uint8_t value[], size_t value_length)
Reads raw binary value from the serialization buffer.
Definition: serialization.c:622
enum yami_result yami_put_long_long_array(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const int64_t value[], size_t value_length)
Places long long array in the serialization buffer.
Definition: serialization.c:871
enum yami_result yami_get_type(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, enum yami_parameter_type *type)
Reads type code from the serialization buffer.
Definition: serialization.c:102
enum yami_result yami_put_integer_array(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const int32_t value[], size_t value_length)
Places integer array in the serialization buffer.
Definition: serialization.c:795
enum yami_result yami_parse_message_header(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, char out_header_type[], size_t header_type_size, char out_object_name[], size_t object_name_size, char out_message_name[], size_t message_name_size, char out_reason[], size_t reason_size, int64_t *out_message_id)
Parses message header.
Definition: serialization.c:1355
enum yami_result yami_fill_exception_header(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const char reason[], int64_t message_id)
Places exception header fields in the serialization buffer.
Definition: serialization.c:1281
enum yami_result yami_fill_message_header(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const char object_name[], const char message_name[], int64_t message_id)
Places message header fields in the serialization buffer.
Definition: serialization.c:1157
enum yami_result yami_get_raw_boolean_array(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int32_t value[], size_t value_length)
Reads raw boolean array from the serialization buffer.
Definition: serialization.c:735
enum yami_result yami_put_cstring(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const char value[])
Places string value in the serialization buffer.
Definition: serialization.c:484
enum yami_result yami_put_type(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, enum yami_parameter_type type)
Places type indicator value in the serialization buffer.
Definition: serialization.c:27
enum yami_result yami_put_long_long(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int64_t value)
Places long long value in the serialization buffer.
Definition: serialization.c:287
enum yami_result yami_get_integer(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int32_t *value)
Reads integer value from the serialization buffer.
Definition: serialization.c:236
enum yami_result yami_put_boolean_array(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, const int32_t value[], size_t value_length)
Places boolean array in the serialization buffer.
Definition: serialization.c:654
enum yami_result yami_get_long_long(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int64_t *value)
Reads long long value from the serialization buffer.
Definition: serialization.c:351
void yami_fill_reply_header(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int64_t message_id)
Places reply header fields in the serialization buffer.
Definition: serialization.c:1251
enum yami_result yami_put_integer(uint8_t buffer[], size_t buffer_size, size_t *buffer_position, int32_t value)
Places integer value in the serialization buffer.
Definition: serialization.c:184
enum yami_result yami_get_raw_cstring(const uint8_t buffer[], size_t buffer_size, size_t *buffer_position, char value[], size_t value_length)
Reads raw string value from the serialization buffer.
Definition: serialization.c:537