proton  0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
codec.h
Go to the documentation of this file.
1 #ifndef PROTON_CODEC_H
2 #define PROTON_CODEC_H 1
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include <proton/types.h>
26 #include <stdbool.h>
27 #include <stdint.h>
28 #include <unistd.h>
29 #include <stdarg.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef enum {
61 } pn_type_t;
62 
63 typedef struct {
65  union {
66  bool as_bool;
67  uint8_t as_ubyte;
68  int8_t as_byte;
69  uint16_t as_ushort;
70  int16_t as_short;
71  uint32_t as_uint;
72  int32_t as_int;
74  uint64_t as_ulong;
75  int64_t as_long;
77  float as_float;
78  double as_double;
84  size_t as_count;
85  } u;
86 } pn_atom_t;
87 
88 // data
89 
90 typedef struct pn_data_t pn_data_t;
91 
92 pn_data_t *pn_data(size_t capacity);
93 void pn_data_free(pn_data_t *data);
94 int pn_data_errno(pn_data_t *data);
95 const char *pn_data_error(pn_data_t *data);
96 int pn_data_vfill(pn_data_t *data, const char *fmt, va_list ap);
97 int pn_data_fill(pn_data_t *data, const char *fmt, ...);
98 int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap);
99 int pn_data_scan(pn_data_t *data, const char *fmt, ...);
100 
101 void pn_data_clear(pn_data_t *data);
102 size_t pn_data_size(pn_data_t *data);
103 void pn_data_rewind(pn_data_t *data);
104 bool pn_data_next(pn_data_t *data);
105 bool pn_data_prev(pn_data_t *data);
106 bool pn_data_enter(pn_data_t *data);
107 bool pn_data_exit(pn_data_t *data);
108 
110 
111 int pn_data_print(pn_data_t *data);
112 int pn_data_format(pn_data_t *data, char *bytes, size_t *size);
113 ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size);
114 ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size);
115 
116 int pn_data_put_list(pn_data_t *data);
117 int pn_data_put_map(pn_data_t *data);
118 int pn_data_put_array(pn_data_t *data, bool described, pn_type_t type);
120 int pn_data_put_null(pn_data_t *data);
121 int pn_data_put_bool(pn_data_t *data, bool b);
122 int pn_data_put_ubyte(pn_data_t *data, uint8_t ub);
123 int pn_data_put_byte(pn_data_t *data, int8_t b);
124 int pn_data_put_ushort(pn_data_t *data, uint16_t us);
125 int pn_data_put_short(pn_data_t *data, int16_t s);
126 int pn_data_put_uint(pn_data_t *data, uint32_t ui);
127 int pn_data_put_int(pn_data_t *data, int32_t i);
128 int pn_data_put_char(pn_data_t *data, pn_char_t c);
129 int pn_data_put_ulong(pn_data_t *data, uint64_t ul);
130 int pn_data_put_long(pn_data_t *data, int64_t l);
132 int pn_data_put_float(pn_data_t *data, float f);
133 int pn_data_put_double(pn_data_t *data, double d);
137 int pn_data_put_uuid(pn_data_t *data, pn_uuid_t u);
138 int pn_data_put_binary(pn_data_t *data, pn_bytes_t bytes);
139 int pn_data_put_string(pn_data_t *data, pn_bytes_t string);
140 int pn_data_put_symbol(pn_data_t *data, pn_bytes_t symbol);
141 int pn_data_put_atom(pn_data_t *data, pn_atom_t atom);
142 
143 size_t pn_data_get_list(pn_data_t *data);
144 size_t pn_data_get_map(pn_data_t *data);
145 size_t pn_data_get_array(pn_data_t *data);
148 bool pn_data_is_described(pn_data_t *data);
149 bool pn_data_is_null(pn_data_t *data);
150 bool pn_data_get_bool(pn_data_t *data);
151 uint8_t pn_data_get_ubyte(pn_data_t *data);
152 int8_t pn_data_get_byte(pn_data_t *data);
153 uint16_t pn_data_get_ushort(pn_data_t *data);
154 int16_t pn_data_get_short(pn_data_t *data);
155 uint32_t pn_data_get_uint(pn_data_t *data);
156 int32_t pn_data_get_int(pn_data_t *data);
158 uint64_t pn_data_get_ulong(pn_data_t *data);
159 int64_t pn_data_get_long(pn_data_t *data);
161 float pn_data_get_float(pn_data_t *data);
162 double pn_data_get_double(pn_data_t *data);
172 
173 int pn_data_copy(pn_data_t *data, pn_data_t *src);
174 int pn_data_append(pn_data_t *data, pn_data_t *src);
175 int pn_data_appendn(pn_data_t *data, pn_data_t *src, int limit);
176 void pn_data_narrow(pn_data_t *data);
177 void pn_data_widen(pn_data_t *data);
178 
179 void pn_data_dump(pn_data_t *data);
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif /* codec.h */