All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_cdt_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2023 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 #pragma once
18 
19 #include <aerospike/as_msgpack.h>
20 #include <aerospike/as_cdt_ctx.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /******************************************************************************
28  * MACROS
29  *****************************************************************************/
30 
31 #define as_cdt_begin() \
32  {0};\
33  while (true) {
34 
35 #define as_cdt_end(pk) \
36  if (!(pk)->buffer) {\
37  (pk)->buffer = cf_malloc((pk)->offset);\
38  (pk)->capacity = (pk)->offset;\
39  (pk)->offset = 0;\
40  (pk)->head = NULL;\
41  (pk)->tail = NULL;\
42  continue;\
43  }\
44  break;\
45  }
46 
47 /******************************************************************************
48  * FUNCTIONS
49  *****************************************************************************/
50 
51 void
52 as_cdt_pack_header(as_packer* pk, as_cdt_ctx* ctx, uint16_t command, uint32_t count);
53 
54 void
55 as_cdt_pack_header_flag(as_packer* pk, as_cdt_ctx* ctx, uint16_t command, uint32_t count, uint32_t flag);
56 
57 void
59 
60 uint32_t
61 as_cdt_ctx_pack(const as_cdt_ctx* ctx, as_packer* pk);
62 
63 bool
64 as_cdt_add_packed(as_packer* pk, as_operations* ops, const char* name, as_operator op_type);
65 
66 bool
68 
69 static inline void
70 as_pack_string(as_packer* pk, const char* s)
71 {
72  uint32_t len = (uint32_t)strlen(s);
73  as_pack_str(pk, (uint8_t*)s, len);
74 }
75 
76 static inline void
77 as_pack_byte_string(as_packer* pk, const uint8_t* b, uint32_t len)
78 {
79  as_pack_str(pk, b, len);
80 }
81 
82 bool
83 as_unpack_str_init(as_unpacker* pk, char* str, uint32_t max);
84 
85 bool
86 as_unpack_str_new(as_unpacker* pk, char** str, uint32_t max);
87 
88 bool
89 as_unpack_bytes_init(as_unpacker* pk, uint8_t* b, uint32_t max);
90 
91 bool
92 as_unpack_bytes_new(as_unpacker* pk, uint8_t** bytes, uint32_t* bytes_size, uint32_t max);
93 
94 #define as_cmp_error() \
95  printf("Line %d\n", __LINE__);\
96  return false;
97 
98 bool
99 as_val_compare(as_val* v1, as_val* v2);
100 
101 #ifdef __cplusplus
102 } // end extern "C"
103 #endif
bool as_unpack_str_new(as_unpacker *pk, char **str, uint32_t max)
void as_cdt_pack_ctx(as_packer *pk, as_cdt_ctx *ctx)
static void as_pack_string(as_packer *pk, const char *s)
bool as_cdt_ctx_from_unpacker(as_cdt_ctx *ctx, as_unpacker *pk)
bool as_cdt_add_packed(as_packer *pk, as_operations *ops, const char *name, as_operator op_type)
Definition: as_val.h:61
bool as_unpack_bytes_init(as_unpacker *pk, uint8_t *b, uint32_t max)
as_operator
Definition: as_operations.h:32
bool as_unpack_bytes_new(as_unpacker *pk, uint8_t **bytes, uint32_t *bytes_size, uint32_t max)
int as_pack_str(as_packer *pk, const uint8_t *buf, uint32_t sz)
static void as_pack_byte_string(as_packer *pk, const uint8_t *b, uint32_t len)
void as_cdt_pack_header_flag(as_packer *pk, as_cdt_ctx *ctx, uint16_t command, uint32_t count, uint32_t flag)
uint32_t as_cdt_ctx_pack(const as_cdt_ctx *ctx, as_packer *pk)
void as_cdt_pack_header(as_packer *pk, as_cdt_ctx *ctx, uint16_t command, uint32_t count)
bool as_val_compare(as_val *v1, as_val *v2)
bool as_unpack_str_init(as_unpacker *pk, char *str, uint32_t max)