proton  0
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/import_export.h>
26 #include <proton/object.h>
27 #include <proton/types.h>
28 #include <proton/error.h>
29 #include <proton/type_compat.h>
30 #include <stdarg.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /**
37  * @file
38  *
39  * Data API for proton.
40  *
41  * @defgroup data Data
42  * @{
43  */
44 
45 /**
46  * Identifies an AMQP type.
47  */
48 typedef enum {
49 
50  /**
51  * The NULL AMQP type.
52  */
53  PN_NULL = 1,
54 
55  /**
56  * The boolean AMQP type.
57  */
58  PN_BOOL = 2,
59 
60  /**
61  * The unsigned byte AMQP type. An 8 bit unsigned integer.
62  */
63  PN_UBYTE = 3,
64 
65  /**
66  * The byte AMQP type. An 8 bit signed integer.
67  */
68  PN_BYTE = 4,
69 
70  /**
71  * The unsigned short AMQP type. A 16 bit unsigned integer.
72  */
73  PN_USHORT = 5,
74 
75  /**
76  * The short AMQP type. A 16 bit signed integer.
77  */
78  PN_SHORT = 6,
79 
80  /**
81  * The unsigned int AMQP type. A 32 bit unsigned integer.
82  */
83  PN_UINT = 7,
84 
85  /**
86  * The signed int AMQP type. A 32 bit signed integer.
87  */
88  PN_INT = 8,
89 
90  /**
91  * The char AMQP type. A 32 bit unicode character.
92  */
93  PN_CHAR = 9,
94 
95  /**
96  * The ulong AMQP type. An unsigned 32 bit integer.
97  */
98  PN_ULONG = 10,
99 
100  /**
101  * The long AMQP type. A signed 32 bit integer.
102  */
103  PN_LONG = 11,
104 
105  /**
106  * The timestamp AMQP type. A signed 64 bit value measuring
107  * milliseconds since the epoch.
108  */
110 
111  /**
112  * The float AMQP type. A 32 bit floating point value.
113  */
114  PN_FLOAT = 13,
115 
116  /**
117  * The double AMQP type. A 64 bit floating point value.
118  */
119  PN_DOUBLE = 14,
120 
121  /**
122  * The decimal32 AMQP type. A 32 bit decimal floating point value.
123  */
125 
126  /**
127  * The decimal64 AMQP type. A 64 bit decimal floating point value.
128  */
130 
131  /**
132  * The decimal128 AMQP type. A 128 bit decimal floating point value.
133  */
135 
136  /**
137  * The UUID AMQP type. A 16 byte UUID.
138  */
139  PN_UUID = 18,
140 
141  /**
142  * The binary AMQP type. A variable length sequence of bytes.
143  */
144  PN_BINARY = 19,
145 
146  /**
147  * The string AMQP type. A variable length sequence of unicode
148  * characters.
149  */
150  PN_STRING = 20,
151 
152  /**
153  * The symbol AMQP type. A variable length sequence of unicode
154  * characters.
155  */
156  PN_SYMBOL = 21,
157 
158  /**
159  * A described AMQP type.
160  */
162 
163  /**
164  * An AMQP array. A monomorphic sequence of other AMQP values.
165  */
166  PN_ARRAY = 23,
167 
168  /**
169  * An AMQP list. A polymorphic sequence of other AMQP values.
170  */
171  PN_LIST = 24,
172 
173  /**
174  * An AMQP map. A polymorphic container of other AMQP values formed
175  * into key/value pairs.
176  */
177  PN_MAP = 25
178 } pn_type_t;
179 
180 /**
181  * Return a string name for an AMQP type.
182  *
183  * @param type an AMQP type
184  * @return the string name of the given type
185  */
186 PN_EXTERN const char *pn_type_name(pn_type_t type);
187 
188 /**
189  * A descriminated union that holds any scalar AMQP value. The type
190  * field indicates the AMQP type of the value, and the union may be
191  * used to access the value for a given type.
192  */
193 typedef struct {
194  /**
195  * Indicates the type of value the atom is currently pointing to.
196  * See ::pn_type_t for details on AMQP types.
197  */
199  union {
200  /**
201  * Valid when type is ::PN_BOOL.
202  */
203  bool as_bool;
204 
205  /**
206  * Valid when type is ::PN_UBYTE.
207  */
208  uint8_t as_ubyte;
209 
210  /**
211  * Valid when type is ::PN_BYTE.
212  */
213  int8_t as_byte;
214 
215  /**
216  * Valid when type is ::PN_USHORT.
217  */
218  uint16_t as_ushort;
219 
220  /**
221  * Valid when type is ::PN_SHORT.
222  */
223  int16_t as_short;
224 
225  /**
226  * Valid when type is ::PN_UINT.
227  */
228  uint32_t as_uint;
229 
230  /**
231  * Valid when type is ::PN_INT.
232  */
233  int32_t as_int;
234 
235  /**
236  * Valid when type is ::PN_CHAR.
237  */
239 
240  /**
241  * Valid when type is ::PN_ULONG.
242  */
243  uint64_t as_ulong;
244 
245  /**
246  * Valid when type is ::PN_LONG.
247  */
248  int64_t as_long;
249 
250  /**
251  * Valid when type is ::PN_TIMESTAMP.
252  */
254 
255  /**
256  * Valid when type is ::PN_FLOAT.
257  */
258  float as_float;
259 
260  /**
261  * Valid when type is ::PN_DOUBLE.
262  */
263  double as_double;
264 
265  /**
266  * Valid when type is ::PN_DECIMAL32.
267  */
269 
270  /**
271  * Valid when type is ::PN_DECIMAL64.
272  */
274 
275  /**
276  * Valid when type is ::PN_DECIMAL128.
277  */
279 
280  /**
281  * Valid when type is ::PN_UUID.
282  */
284 
285  /**
286  * Valid when type is ::PN_BINARY or ::PN_STRING or ::PN_SYMBOL.
287  * When the type is ::PN_STRING the field will point to utf8
288  * encoded unicode. When the type is ::PN_SYMBOL, the field will
289  * point to 7-bit ASCII. In the latter two cases, the bytes
290  * pointed to are *not* necessarily null terminated.
291  */
293  } u;
294 } pn_atom_t;
295 
296 /**
297  * An AMQP Data object.
298  *
299  * A pn_data_t object provides an interface for decoding, extracting,
300  * creating, and encoding arbitrary AMQP data. A pn_data_t object
301  * contains a tree of AMQP values. Leaf nodes in this tree correspond
302  * to scalars in the AMQP type system such as @link ::PN_INT ints
303  * @endlink or @link ::PN_STRING strings @endlink. Non-leaf nodes in
304  * this tree correspond to compound values in the AMQP type system
305  * such as @link ::PN_LIST lists @endlink, @link ::PN_MAP maps
306  * @endlink, @link ::PN_ARRAY arrays @endlink, or @link ::PN_DESCRIBED
307  * described @endlink values. The root node of the tree is the
308  * pn_data_t object itself and can have an arbitrary number of
309  * children.
310  *
311  * A pn_data_t object maintains the notion of the current node and the
312  * current parent node. Siblings are ordered within their parent.
313  * Values are accessed and/or added by using the ::pn_data_next(),
314  * ::pn_data_prev(), ::pn_data_enter(), and ::pn_data_exit()
315  * operations to navigate to the desired location in the tree and
316  * using the supplied variety of pn_data_put_* / pn_data_get_*
317  * operations to access or add a value of the desired type.
318  *
319  * The pn_data_put_* operations will always add a value _after_ the
320  * current node in the tree. If the current node has a next sibling
321  * the pn_data_put_* operations will overwrite the value on this node.
322  * If there is no current node or the current node has no next sibling
323  * then one will be added. The pn_data_put_* operations always set the
324  * added/modified node to the current node. The pn_data_get_*
325  * operations read the value of the current node and do not change
326  * which node is current.
327  *
328  * The following types of scalar values are supported:
329  *
330  * - ::PN_NULL
331  * - ::PN_BOOL
332  * - ::PN_UBYTE
333  * - ::PN_USHORT
334  * - ::PN_SHORT
335  * - ::PN_UINT
336  * - ::PN_INT
337  * - ::PN_ULONG
338  * - ::PN_LONG
339  * - ::PN_FLOAT
340  * - ::PN_DOUBLE
341  * - ::PN_BINARY
342  * - ::PN_STRING
343  * - ::PN_SYMBOL
344  *
345  * The following types of compound values are supported:
346  *
347  * - ::PN_DESCRIBED
348  * - ::PN_ARRAY
349  * - ::PN_LIST
350  * - ::PN_MAP
351  */
352 typedef struct pn_data_t pn_data_t;
353 
354 /**
355  * Construct a pn_data_t object with the supplied initial capacity. A
356  * pn_data_t will grow automatically as needed, so an initial capacity
357  * of 0 is permitted.
358  *
359  * @param capacity the initial capacity
360  * @return the newly constructed pn_data_t
361  */
362 PN_EXTERN pn_data_t *pn_data(size_t capacity);
363 
364 /**
365  * Free a pn_data_t object.
366  *
367  * @param data a pn_data_t object or NULL
368  */
369 PN_EXTERN void pn_data_free(pn_data_t *data);
370 
371 /**
372  * Access the current error code for a given pn_data_t.
373  *
374  * @param data a pn_data_t object
375  * @return the current error code
376  */
378 
379 /**
380  * Access the current error for a givn pn_data_t.
381  *
382  * Every pn_data_t has an error descriptor that is created with the
383  * pn_data_t and dies with the pn_data_t. The error descriptor is
384  * updated whenever an operation fails. The ::pn_data_error() function
385  * may be used to access a pn_data_t's error descriptor.
386  *
387  * @param data a pn_data_t object
388  * @return a pointer to the pn_data_t's error descriptor
389  */
391 
392 PN_EXTERN int pn_data_vfill(pn_data_t *data, const char *fmt, va_list ap);
393 PN_EXTERN int pn_data_fill(pn_data_t *data, const char *fmt, ...);
394 PN_EXTERN int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap);
395 PN_EXTERN int pn_data_scan(pn_data_t *data, const char *fmt, ...);
396 
397 /**
398  * Clears a pn_data_t object.
399  *
400  * A cleared pn_data_t object is equivalent to a newly constructed
401  * one.
402  *
403  * @param data the pn_data_t object to clear
404  */
405 PN_EXTERN void pn_data_clear(pn_data_t *data);
406 
407 /**
408  * Returns the total number of nodes contained in a pn_data_t object.
409  * This includes all parents, children, siblings, grandchildren, etc.
410  * In other words the count of all ancesters and descendents of the
411  * current node, along with the current node if there is one.
412  *
413  * @param data a pn_data_t object
414  * @return the total number of nodes in the pn_data_t object
415  */
416 PN_EXTERN size_t pn_data_size(pn_data_t *data);
417 
418 /**
419  * Clears current node pointer and sets the parent to the root node.
420  * Clearing the current node sets it _before_ the first node, calling
421  * ::pn_data_next() will advance to the first node.
422  */
424 
425 /**
426  * Advances the current node to its next sibling and returns true. If
427  * there is no next sibling the current node remains unchanged and
428  * false is returned.
429  *
430  * @param data a pn_data_t object
431  * @return true iff the current node was changed
432  */
433 PN_EXTERN bool pn_data_next(pn_data_t *data);
434 
435 /**
436  * Moves the current node to its previous sibling and returns true. If
437  * there is no previous sibling the current node remains unchanged and
438  * false is returned.
439  *
440  * @param data a pn_data_t object
441  * @return true iff the current node was changed
442  */
443 PN_EXTERN bool pn_data_prev(pn_data_t *data);
444 
445 /**
446  * Sets the parent node to the current node and clears the current
447  * node. Clearing the current node sets it _before_ the first child,
448  * calling ::pn_data_next() advances to the first child. This
449  * operation will return false if there is no current node or if the
450  * current node is not a compound type.
451  *
452  * @param data a pn_data_object
453  * @return true iff the pointers to the current/parent nodes are changed
454  */
455 PN_EXTERN bool pn_data_enter(pn_data_t *data);
456 
457 /**
458  * Sets the current node to the parent node and the parent node to its
459  * own parent. This operation will return false if there is no current
460  * node or parent node.
461  *
462  * @param data a pn_data object
463  * @return true iff the pointers to the current/parent nodes are
464  * changed
465  */
466 PN_EXTERN bool pn_data_exit(pn_data_t *data);
467 
468 PN_EXTERN bool pn_data_lookup(pn_data_t *data, const char *name);
469 
470 /**
471  * Access the type of the current node. Returns an undefined value if
472  * there is no current node.
473  *
474  * @param data a data object
475  * @return the type of the current node
476  */
478 
479 /**
480  * Prints the contents of a pn_data_t object using ::pn_data_format()
481  * to stdout.
482  *
483  * @param data a pn_data_t object
484  * @return zero on success or an error on failure
485  */
487 
488 /**
489  * Formats the contents of a pn_data_t object in a human readable way
490  * and writes them to the indicated location. The size pointer must
491  * hold the amount of free space following the bytes pointer, and upon
492  * success will be updated to indicate how much space has been used.
493  *
494  * @param data a pn_data_t object
495  * @param bytes a buffer to write the output to
496  * @param size a pointer to the size of the buffer
497  * @return zero on succes, or an error on failure
498  */
499 PN_EXTERN int pn_data_format(pn_data_t *data, char *bytes, size_t *size);
500 
501 /**
502  * Writes the contents of a data object to the given buffer as an AMQP
503  * data stream.
504  *
505  * @param data the data object to encode
506  * @param bytes the buffer for encoded data
507  * @param size the size of the buffer
508  *
509  * @param ssize_t returns the size of the encoded data on success or
510  * an error code on failure
511  */
512 PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size);
513 
514 /**
515  * Decodes a single value from the contents of the AMQP data stream
516  * into the current data object. Note that if the pn_data_t object is
517  * pointing to a current node, the decoded value will overwrite the
518  * current one. If the pn_data_t object has no current node then a
519  * node will be appended to the current parent. If there is no current
520  * parent then a node will be appended to the pn_data_t itself.
521  *
522  * Upon success, this operation returns the number of bytes consumed
523  * from the AMQP data stream. Upon failure, this operation returns an
524  * error code.
525  *
526  * @param data a pn_data_t object
527  * @param bytes a pointer to an encoded AMQP data stream
528  * @param size the size of the encoded AMQP data stream
529  * @return the number of bytes consumed from the AMQP data stream or an error code
530  */
531 PN_EXTERN ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size);
532 
533 /**
534  * Puts an empty list value into a pn_data_t. Elements may be filled
535  * by entering the list node using ::pn_data_enter() and using
536  * ::pn_data_put_* to add the desired contents. Once done,
537  * ::pn_data_exit() may be used to return to the current level in the
538  * tree and put more values.
539  *
540  * @code
541  * pn_data_t *data = pn_data(0);
542  * ...
543  * pn_data_put_list(data);
544  * pn_data_enter(data);
545  * pn_data_put_int(data, 1);
546  * pn_data_put_int(data, 2);
547  * pn_data_put_int(data, 3);
548  * pn_data_exit(data);
549  * ...
550  * @endcode
551  *
552  * @param data a pn_data_t object
553  * @return zero on success or an error code on failure
554  */
556 
557 /**
558  * Puts an empty map value into a pn_data_t. Elements may be filled by
559  * entering the map node and putting alternating key value pairs.
560  *
561  * @code
562  * pn_data_t *data = pn_data(0);
563  * ...
564  * pn_data_put_map(data);
565  * pn_data_enter(data);
566  * pn_data_put_string(data, pn_bytes(3, "key"));
567  * pn_data_put_string(data, pn_bytes(5, "value"));
568  * pn_data_exit(data);
569  * ...
570  * @endcode
571  *
572  * @param data a pn_data_t object
573  * @return zero on success or an error code on failure
574  */
576 
577 /**
578  * Puts an empty array value into a pn_data_t. Elements may be filled
579  * by entering the array node and putting the element values. The
580  * values must all be of the specified array element type. If an array
581  * is described then the first child value of the array is the
582  * descriptor and may be of any type.
583  *
584  * @code
585  * pn_data_t *data = pn_data(0);
586  * ...
587  * pn_data_put_array(data, false, PN_INT);
588  * pn_data_enter(data);
589  * pn_data_put_int(data, 1);
590  * pn_data_put_int(data, 2);
591  * pn_data_put_int(data, 3);
592  * pn_data_exit(data);
593  * ...
594  * pn_data_put_array(data, True, Data.DOUBLE);
595  * pn_data_enter(data);
596  * pn_data_put_symbol(data, "array-descriptor");
597  * pn_data_put_double(data, 1.1);
598  * pn_data_put_double(data, 1.2);
599  * pn_data_put_double(data, 1.3);
600  * pn_data_exit(data);
601  * ...
602  * @endcode
603  *
604  * @param data a pn_data_t object
605  * @param described specifies whether the array is described
606  * @param type the type of the array
607  *
608  * @return zero on success or an error code on failure
609  */
610 PN_EXTERN int pn_data_put_array(pn_data_t *data, bool described, pn_type_t type);
611 
612 /**
613  * Puts a described value into a pn_data_t object. A described node
614  * has two children, the descriptor and the value. These are specified
615  * by entering the node and putting the desired values.
616  *
617  * @code
618  * pn_data_t *data = pn_data(0);
619  * ...
620  * pn_data_put_described(data);
621  * pn_data_enter(data);
622  * pn_data_put_symbol(data, pn_bytes(16, "value-descriptor"));
623  * pn_data_put_string(data, pn_bytes(9, "the value"));
624  * pn_data_exit(data);
625  * ...
626  * @endcode
627  *
628  * @param data a pn_data_t object
629  * @return zero on success or an error code on failure
630  */
632 
633 /**
634  * Puts a ::PN_NULL value.
635  *
636  * @param data a pn_data_t object
637  * @return zero on success or an error code on failure
638  */
640 
641 /**
642  * Puts a ::PN_BOOL value.
643  *
644  * @param data a pn_data_t object
645  * @param b the value
646  * @return zero on success or an error code on failure
647  */
648 PN_EXTERN int pn_data_put_bool(pn_data_t *data, bool b);
649 
650 /**
651  * Puts a ::PN_UBYTE value.
652  *
653  * @param data a pn_data_t object
654  * @param ub the value
655  * @return zero on success or an error code on failure
656  */
657 PN_EXTERN int pn_data_put_ubyte(pn_data_t *data, uint8_t ub);
658 
659 /**
660  * Puts a ::PN_BYTE value.
661  *
662  * @param data a pn_data_t object
663  * @param b the value
664  * @return zero on success or an error code on failure
665  */
666 PN_EXTERN int pn_data_put_byte(pn_data_t *data, int8_t b);
667 
668 /**
669  * Puts a ::PN_USHORT value.
670  *
671  * @param data a pn_data_t object
672  * @param us the value
673  * @return zero on success or an error code on failure
674  */
675 PN_EXTERN int pn_data_put_ushort(pn_data_t *data, uint16_t us);
676 
677 /**
678  * Puts a ::PN_SHORT value.
679  *
680  * @param data a pn_data_t object
681  * @param s the value
682  * @return zero on success or an error code on failure
683  */
684 PN_EXTERN int pn_data_put_short(pn_data_t *data, int16_t s);
685 
686 /**
687  * Puts a ::PN_UINT value.
688  *
689  * @param data a pn_data_t object
690  * @param ui the value
691  * @return zero on success or an error code on failure
692  */
693 PN_EXTERN int pn_data_put_uint(pn_data_t *data, uint32_t ui);
694 
695 /**
696  * Puts a ::PN_INT value.
697  *
698  * @param data a pn_data_t object
699  * @param i the value
700  * @return zero on success or an error code on failure
701  */
702 PN_EXTERN int pn_data_put_int(pn_data_t *data, int32_t i);
703 
704 /**
705  * Puts a ::PN_CHAR value.
706  *
707  * @param data a pn_data_t object
708  * @param c the value
709  * @return zero on success or an error code on failure
710  */
712 
713 /**
714  * Puts a ::PN_ULONG value.
715  *
716  * @param data a pn_data_t object
717  * @param ul the value
718  * @return zero on success or an error code on failure
719  */
720 PN_EXTERN int pn_data_put_ulong(pn_data_t *data, uint64_t ul);
721 
722 /**
723  * Puts a ::PN_LONG value.
724  *
725  * @param data a pn_data_t object
726  * @param l the value
727  * @return zero on success or an error code on failure
728  */
729 PN_EXTERN int pn_data_put_long(pn_data_t *data, int64_t l);
730 
731 /**
732  * Puts a ::PN_TIMESTAMP value.
733  *
734  * @param data a pn_data_t object
735  * @param t the value
736  * @return zero on success or an error code on failure
737  */
739 
740 /**
741  * Puts a ::PN_FLOAT value.
742  *
743  * @param data a pn_data_t object
744  * @param f the value
745  * @return zero on success or an error code on failure
746  */
747 PN_EXTERN int pn_data_put_float(pn_data_t *data, float f);
748 
749 /**
750  * Puts a ::PN_DOUBLE value.
751  *
752  * @param data a pn_data_t object
753  * @param d the value
754  * @return zero on success or an error code on failure
755  */
756 PN_EXTERN int pn_data_put_double(pn_data_t *data, double d);
757 
758 /**
759  * Puts a ::PN_DECIMAL32 value.
760  *
761  * @param data a pn_data_t object
762  * @param d the value
763  * @return zero on success or an error code on failure
764  */
766 
767 /**
768  * Puts a ::PN_DECIMAL64 value.
769  *
770  * @param data a pn_data_t object
771  * @param d the value
772  * @return zero on success or an error code on failure
773  */
775 
776 /**
777  * Puts a ::PN_DECIMAL128 value.
778  *
779  * @param data a pn_data_t object
780  * @param d the value
781  * @return zero on success or an error code on failure
782  */
784 
785 /**
786  * Puts a ::PN_UUID value.
787  *
788  * @param data a pn_data_t object
789  * @param u the value
790  * @return zero on success or an error code on failure
791  */
793 
794 /**
795  * Puts a ::PN_BINARY value. The bytes referenced by the pn_bytes_t
796  * argument are copied and stored inside the pn_data_t object.
797  *
798  * @param data a pn_data_t object
799  * @param bytes the value
800  * @return zero on success or an error code on failure
801  */
803 
804 /**
805  * Puts a ::PN_STRING value. The bytes referenced by the pn_bytes_t
806  * argument are copied and stored inside the pn_data_t object.
807  *
808  * @param data a pn_data_t object
809  * @param string utf8 encoded unicode
810  * @return zero on success or an error code on failure
811  */
813 
814 /**
815  * Puts a ::PN_SYMBOL value. The bytes referenced by the pn_bytes_t
816  * argument are copied and stored inside the pn_data_t object.
817  *
818  * @param data a pn_data_t object
819  * @param symbol ascii encoded symbol
820  * @return zero on success or an error code on failure
821  */
823 
824 /**
825  * Puts any scalar value value.
826  *
827  * @param data a pn_data_t object
828  * @param atom the value
829  * @return zero on success or an error code on failure
830  */
832 
833 /**
834  * If the current node is a list, return the number of elements,
835  * otherwise return zero. List elements can be accessed by entering
836  * the list.
837  *
838  * @code
839  * ...
840  * size_t count = pn_data_get_list(data);
841  * pn_data_enter(data);
842  * for (size_t i = 0; i < count; i++) {
843  * if (pn_data_next(data)) {
844  * switch (pn_data_type(data)) {
845  * case PN_STRING:
846  * ...
847  * break;
848  * case PN_INT:
849  * ...
850  * break;
851  * }
852  * }
853  * pn_data_exit(data);
854  * ...
855  * @endcode
856 .*
857  * @param data a pn_data_t object
858  * @return the size of a list node
859  */
860 PN_EXTERN size_t pn_data_get_list(pn_data_t *data);
861 
862 /**
863  * If the current node is a map, return the number of child elements,
864  * otherwise return zero. Key value pairs can be accessed by entering
865  * the map.
866  *
867  * @code
868  * ...
869  * size_t count = pn_data_get_map(data);
870  * pn_data_enter(data);
871  * for (size_t i = 0; i < count/2; i++) {
872  * // read key
873  * if (pn_data_next(data)) {
874  * switch (pn_data_type(data)) {
875  * case PN_STRING:
876  * ...
877  * break;
878  * ...
879  * }
880  * }
881  * ...
882  * // read value
883  * if (pn_data_next(data)) {
884  * switch (pn_data_type(data)) {
885  * case PN_INT:
886  * ...
887  * break;
888  * ...
889  * }
890  * }
891  * ...
892  * }
893  * pn_data_exit(data);
894  * ...
895  * @endcode
896  *
897  * @param data a pn_data_t object
898  * @return the number of child elements of a map node
899  */
900 PN_EXTERN size_t pn_data_get_map(pn_data_t *data);
901 
902 /**
903  * If the current node is an array, return the number of elements in
904  * the array, otherwise return 0. Array data can be accessed by
905  * entering the array. If the array is described, the first child node
906  * will be the descriptor, and the remaining @var count child nodes
907  * will be the elements of the array.
908  *
909  * @code
910  * ...
911  * size_t count = pn_data_get_array(data);
912  * bool described = pn_data_is_array_described(data);
913  * pn_type_t type = pn_data_get_array_type(data);
914  *
915  * pn_data_enter(data);
916  *
917  * if (described && pn_data_next(data)) {
918  * // the descriptor could be another type, but let's assume it's a symbol
919  * pn_bytes_t descriptor = pn_data_get_symbol(data);
920  * }
921  *
922  * for (size_t i = 0; i < count; i++) {
923  * if (pn_data_next(data)) {
924  * // all elements will be values of the array type retrieved above
925  * ...
926  * }
927  * }
928  * pn_data_exit(data);
929  * ...
930  * @endcode
931  *
932  * @param data a pn_data_t object
933  * @return the number of elements of an array node
934  */
936 
937 /**
938  * Returns true if the current node points to a described array.
939  *
940  * @param data a pn_data_t object
941  * @return true if the current node points to a described array
942  */
944 
945 /**
946  * Return the array type if the current node points to an array,
947  * undefined otherwise.
948  *
949  * @param data a pn_data_t object
950  * @return the element type of an array node
951  */
953 
954 /**
955  * Checks if the current node is a described value. The descriptor and
956  * value may be accessed by entering the described value node.
957  *
958  * @code
959  * ...
960  * // read a symbolically described string
961  * if (pn_data_is_described(data)) {
962  * pn_data_enter(data);
963  * pn_data_next(data);
964  * assert(pn_data_type(data) == PN_SYMBOL);
965  * pn_bytes_t symbol = pn_data_get_symbol(data);
966  * pn_data_next(data);
967  * assert(pn_data_type(data) == PN_STRING);
968  * pn_bytes_t utf8 = pn_data_get_string(data);
969  * pn_data_exit(data);
970  * }
971  * ...
972  * @endcode
973  *
974  * @param data a pn_data_t object
975  * @return true if the current node is a described type
976  */
978 
979 /**
980  * Checks if the current node is a ::PN_NULL.
981  *
982  * @param data a pn_data_t object
983  * @return true iff the current node is ::PN_NULL
984  */
986 
987 /**
988  * If the current node is a ::PN_BOOL, returns its value.
989  *
990  * @param data a pn_data_t object
991  */
993 
994 /**
995  * If the current node is a ::PN_UBYTE, return its value, otherwise
996  * return 0.
997  *
998  * @param data a pn_data_t object
999  */
1000 PN_EXTERN uint8_t pn_data_get_ubyte(pn_data_t *data);
1001 
1002 /**
1003  * If the current node is a signed byte, returns its value, returns 0
1004  * otherwise.
1005  *
1006  * @param data a pn_data_t object
1007  */
1008 PN_EXTERN int8_t pn_data_get_byte(pn_data_t *data);
1009 
1010 /**
1011  * If the current node is an unsigned short, returns its value,
1012  * returns 0 otherwise.
1013  *
1014  * @param data a pn_data_t object
1015  */
1016 PN_EXTERN uint16_t pn_data_get_ushort(pn_data_t *data);
1017 
1018 /**
1019  * If the current node is a signed short, returns its value, returns 0
1020  * otherwise.
1021  *
1022  * @param data a pn_data_t object
1023  */
1024 PN_EXTERN int16_t pn_data_get_short(pn_data_t *data);
1025 
1026 /**
1027  * If the current node is an unsigned int, returns its value, returns
1028  * 0 otherwise.
1029  *
1030  * @param data a pn_data_t object
1031  */
1032 PN_EXTERN uint32_t pn_data_get_uint(pn_data_t *data);
1033 
1034 /**
1035  * If the current node is a signed int, returns its value, returns 0
1036  * otherwise.
1037  *
1038  * @param data a pn_data_t object
1039  */
1040 PN_EXTERN int32_t pn_data_get_int(pn_data_t *data);
1041 
1042 /**
1043  * If the current node is a char, returns its value, returns 0
1044  * otherwise.
1045  *
1046  * @param data a pn_data_t object
1047  */
1049 
1050 /**
1051  * If the current node is an unsigned long, returns its value, returns
1052  * 0 otherwise.
1053  *
1054  * @param data a pn_data_t object
1055  */
1056 PN_EXTERN uint64_t pn_data_get_ulong(pn_data_t *data);
1057 
1058 /**
1059  * If the current node is an signed long, returns its value, returns 0
1060  * otherwise.
1061  *
1062  * @param data a pn_data_t object
1063  */
1064 PN_EXTERN int64_t pn_data_get_long(pn_data_t *data);
1065 
1066 /**
1067  * If the current node is a timestamp, returns its value, returns 0
1068  * otherwise.
1069  *
1070  * @param data a pn_data_t object
1071  */
1073 
1074 /**
1075  * If the current node is a float, returns its value, raises 0
1076  * otherwise.
1077  *
1078  * @param data a pn_data_t object
1079  */
1081 
1082 /**
1083  * If the current node is a double, returns its value, returns 0
1084  * otherwise.
1085  *
1086  * @param data a pn_data_t object
1087  */
1088 PN_EXTERN double pn_data_get_double(pn_data_t *data);
1089 
1090 /**
1091  * If the current node is a decimal32, returns its value, returns 0
1092  * otherwise.
1093  *
1094  * @param data a pn_data_t object
1095  */
1097 
1098 /**
1099  * If the current node is a decimal64, returns its value, returns 0
1100  * otherwise.
1101  *
1102  * @param data a pn_data_t object
1103  */
1105 
1106 /**
1107  * If the current node is a decimal128, returns its value, returns 0
1108  * otherwise.
1109  *
1110  * @param data a pn_data_t object
1111  */
1113 
1114 /**
1115  * If the current node is a UUID, returns its value, returns None
1116  * otherwise.
1117  *
1118  * @param data a pn_data_t object
1119  * @return a uuid value
1120  */
1122 
1123 /**
1124  * If the current node is binary, returns its value, returns ""
1125  * otherwise. The pn_bytes_t returned will point to memory held inside
1126  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1127  * will be reclaimed.
1128  *
1129  * @param data a pn_data_t object
1130  */
1132 
1133 /**
1134  * If the current node is a string, returns its value, returns ""
1135  * otherwise. The pn_bytes_t returned will point to memory held inside
1136  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1137  * will be reclaimed.
1138  *
1139  * @param data a pn_data_t object
1140  * @return a pn_bytes_t pointing to utf8
1141  */
1143 
1144 /**
1145  * If the current node is a symbol, returns its value, returns ""
1146  * otherwise. The pn_bytes_t returned will point to memory held inside
1147  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1148  * will be reclaimed.
1149  *
1150  * @param data a pn_data_t object
1151  * @return a pn_bytes_t pointing to ascii
1152  */
1154 
1155 /**
1156  * If the current node is a symbol, string, or binary, return the
1157  * bytes representing its value. The pn_bytes_t returned will point to
1158  * memory held inside the pn_data_t. When the pn_data_t is cleared or
1159  * freed, this memory will be reclaimed.
1160  *
1161  * @param data a pn_data_t object
1162  * @return a pn_bytes_t pointing to the node's value
1163  */
1165 
1166 /**
1167  * If the current node is a scalar value, return it as a pn_atom_t.
1168  *
1169  * @param data a pn_data_t object
1170  * @return the value of the current node as pn_atom_t
1171  */
1173 
1174 /**
1175  * Copy the contents of another pn_data_t object. Any values in the
1176  * data object will be lost.
1177  *
1178  * @param data a pn_data_t object
1179  * @param src the sourc pn_data_t to copy from
1180  * @return zero on success or an error code on failure
1181  */
1182 PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src);
1183 
1184 /**
1185  * Append the contents of another pn_data_t object.
1186  *
1187  * @param data a pn_data_t object
1188  * @param src the sourc pn_data_t to append from
1189  * @return zero on success or an error code on failure
1190  */
1191 PN_EXTERN int pn_data_append(pn_data_t *data, pn_data_t *src);
1192 
1193 /**
1194  * Append up to _n_ values from the contents of another pn_data_t
1195  * object.
1196  *
1197  * @param data a pn_data_t object
1198  * @param src the sourc pn_data_t to append from
1199  * @param limit the maximum number of values to append
1200  * @return zero on success or an error code on failure
1201  */
1202 PN_EXTERN int pn_data_appendn(pn_data_t *data, pn_data_t *src, int limit);
1203 
1204 /**
1205  * Modify a pn_data_t object to behave as if the current node is the
1206  * root node of the tree. This impacts the behaviour of
1207  * ::pn_data_rewind(), ::pn_data_next(), ::pn_data_prev(), and
1208  * anything else that depends on the navigational state of the
1209  * pn_data_t object. Use ::pn_data_widen() to reverse the effect of
1210  * this operation.
1211  *
1212  * @param data a pn_data_t object
1213  */
1214 PN_EXTERN void pn_data_narrow(pn_data_t *data);
1215 
1216 /**
1217  * Reverse the effect of ::pn_data_narrow().
1218  *
1219  * @param data a pn_data_t object
1220  */
1221 PN_EXTERN void pn_data_widen(pn_data_t *data);
1222 
1223 /**
1224  * Returns a handle for the current navigational state of a pn_data_t
1225  * so that it can be later restored using ::pn_data_restore().
1226  *
1227  * @param data a pn_data_t object
1228  * @return a handle for the current navigational state
1229  */
1231 
1232 /**
1233  * Restores a prior navigational state that was saved using
1234  * ::pn_data_point(). If the data object has been modified in such a
1235  * way that the prior navigational state cannot be restored, then this
1236  * will return false and the navigational state will remain unchanged,
1237  * otherwise it will return true.
1238  *
1239  * @param data a pn_data_t object
1240  * @param handle a handle referencing the saved navigational state
1241  * @return true iff the prior navigational state was restored
1242  */
1243 PN_EXTERN bool pn_data_restore(pn_data_t *data, pn_handle_t point);
1244 
1245 /**
1246  * Dumps a debug representation of the internal state of the pn_data_t
1247  * object that includes its navigational state to stdout for debugging
1248  * purposes.
1249  *
1250  * @param data a pn_data_t object that is behaving in a confusing way
1251  */
1252 PN_EXTERN void pn_data_dump(pn_data_t *data);
1253 
1254 /** @}
1255  */
1256 
1257 #ifdef __cplusplus
1258 }
1259 #endif
1260 
1261 #endif /* codec.h */
PN_EXTERN bool pn_data_next(pn_data_t *data)
Advances the current node to its next sibling and returns true.
PN_EXTERN int pn_data_put_int(pn_data_t *data, int32_t i)
Puts a PN_INT value.
PN_EXTERN pn_bytes_t pn_data_get_string(pn_data_t *data)
If the current node is a string, returns its value, returns "" otherwise.
PN_EXTERN pn_decimal32_t pn_data_get_decimal32(pn_data_t *data)
If the current node is a decimal32, returns its value, returns 0 otherwise.
The binary AMQP type.
Definition: codec.h:144
PN_EXTERN const char * pn_type_name(pn_type_t type)
Return a string name for an AMQP type.
uint16_t as_ushort
Valid when type is PN_USHORT.
Definition: codec.h:218
pn_decimal64_t as_decimal64
Valid when type is PN_DECIMAL64.
Definition: codec.h:273
PN_EXTERN pn_atom_t pn_data_get_atom(pn_data_t *data)
If the current node is a scalar value, return it as a pn_atom_t.
PN_EXTERN int pn_data_put_ubyte(pn_data_t *data, uint8_t ub)
Puts a PN_UBYTE value.
PN_EXTERN pn_timestamp_t pn_data_get_timestamp(pn_data_t *data)
If the current node is a timestamp, returns its value, returns 0 otherwise.
PN_EXTERN int pn_data_errno(pn_data_t *data)
Access the current error code for a given pn_data_t.
uint32_t as_uint
Valid when type is PN_UINT.
Definition: codec.h:228
double as_double
Valid when type is PN_DOUBLE.
Definition: codec.h:263
PN_EXTERN int pn_data_put_string(pn_data_t *data, pn_bytes_t string)
Puts a PN_STRING value.
struct pn_error_t pn_error_t
Definition: error.h:32
PN_EXTERN int pn_data_put_binary(pn_data_t *data, pn_bytes_t bytes)
Puts a PN_BINARY value.
PN_EXTERN float pn_data_get_float(pn_data_t *data)
If the current node is a float, returns its value, raises 0 otherwise.
PN_EXTERN int pn_data_put_decimal128(pn_data_t *data, pn_decimal128_t d)
Puts a PN_DECIMAL128 value.
The timestamp AMQP type.
Definition: codec.h:109
pn_decimal32_t as_decimal32
Valid when type is PN_DECIMAL32.
Definition: codec.h:268
PN_EXTERN int64_t pn_data_get_long(pn_data_t *data)
If the current node is an signed long, returns its value, returns 0 otherwise.
PN_EXTERN int pn_data_put_uint(pn_data_t *data, uint32_t ui)
Puts a PN_UINT value.
PN_EXTERN pn_uuid_t pn_data_get_uuid(pn_data_t *data)
If the current node is a UUID, returns its value, returns None otherwise.
PN_EXTERN bool pn_data_prev(pn_data_t *data)
Moves the current node to its previous sibling and returns true.
PN_EXTERN int8_t pn_data_get_byte(pn_data_t *data)
If the current node is a signed byte, returns its value, returns 0 otherwise.
A descriminated union that holds any scalar AMQP value.
Definition: codec.h:193
The symbol AMQP type.
Definition: codec.h:156
The short AMQP type.
Definition: codec.h:78
uintptr_t pn_handle_t
Definition: object.h:36
int32_t as_int
Valid when type is PN_INT.
Definition: codec.h:233
PN_EXTERN bool pn_data_lookup(pn_data_t *data, const char *name)
PN_EXTERN int pn_data_put_timestamp(pn_data_t *data, pn_timestamp_t t)
Puts a PN_TIMESTAMP value.
PN_EXTERN int pn_data_put_float(pn_data_t *data, float f)
Puts a PN_FLOAT value.
PN_EXTERN void pn_data_dump(pn_data_t *data)
Dumps a debug representation of the internal state of the pn_data_t object that includes its navigati...
The ulong AMQP type.
Definition: codec.h:98
pn_type_t type
Indicates the type of value the atom is currently pointing to.
Definition: codec.h:198
int64_t pn_timestamp_t
Definition: types.h:50
The string AMQP type.
Definition: codec.h:150
struct pn_data_t pn_data_t
An AMQP Data object.
Definition: codec.h:352
PN_EXTERN size_t pn_data_size(pn_data_t *data)
Returns the total number of nodes contained in a pn_data_t object.
pn_decimal128_t as_decimal128
Valid when type is PN_DECIMAL128.
Definition: codec.h:278
PN_EXTERN bool pn_data_get_bool(pn_data_t *data)
If the current node is a PN_BOOL, returns its value.
PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src)
Copy the contents of another pn_data_t object.
PN_EXTERN int pn_data_appendn(pn_data_t *data, pn_data_t *src, int limit)
Append up to n values from the contents of another pn_data_t object.
PN_EXTERN int pn_data_format(pn_data_t *data, char *bytes, size_t *size)
Formats the contents of a pn_data_t object in a human readable way and writes them to the indicated l...
The double AMQP type.
Definition: codec.h:119
PN_EXTERN size_t pn_data_get_map(pn_data_t *data)
If the current node is a map, return the number of child elements, otherwise return zero...
An AMQP list.
Definition: codec.h:171
Definition: types.h:57
The signed int AMQP type.
Definition: codec.h:88
pn_bytes_t as_bytes
Valid when type is PN_BINARY or PN_STRING or PN_SYMBOL.
Definition: codec.h:292
PN_EXTERN int pn_data_put_map(pn_data_t *data)
Puts an empty map value into a pn_data_t.
PN_EXTERN int pn_data_vfill(pn_data_t *data, const char *fmt, va_list ap)
uint32_t pn_decimal32_t
Definition: types.h:52
The boolean AMQP type.
Definition: codec.h:58
PN_EXTERN int pn_data_put_short(pn_data_t *data, int16_t s)
Puts a PN_SHORT value.
pn_uuid_t as_uuid
Valid when type is PN_UUID.
Definition: codec.h:283
An AMQP map.
Definition: codec.h:177
PN_EXTERN double pn_data_get_double(pn_data_t *data)
If the current node is a double, returns its value, returns 0 otherwise.
PN_EXTERN bool pn_data_restore(pn_data_t *data, pn_handle_t point)
Restores a prior navigational state that was saved using pn_data_point().
PN_EXTERN int pn_data_put_byte(pn_data_t *data, int8_t b)
Puts a PN_BYTE value.
#define PN_EXTERN
Definition: import_export.h:53
PN_EXTERN pn_bytes_t pn_data_get_bytes(pn_data_t *data)
If the current node is a symbol, string, or binary, return the bytes representing its value...
PN_EXTERN bool pn_data_is_described(pn_data_t *data)
Checks if the current node is a described value.
The unsigned short AMQP type.
Definition: codec.h:73
PN_EXTERN int pn_data_put_uuid(pn_data_t *data, pn_uuid_t u)
Puts a PN_UUID value.
PN_EXTERN bool pn_data_exit(pn_data_t *data)
Sets the current node to the parent node and the parent node to its own parent.
PN_EXTERN int pn_data_put_symbol(pn_data_t *data, pn_bytes_t symbol)
Puts a PN_SYMBOL value.
PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t size)
Writes the contents of a data object to the given buffer as an AMQP data stream.
PN_EXTERN int pn_data_put_decimal32(pn_data_t *data, pn_decimal32_t d)
Puts a PN_DECIMAL32 value.
The float AMQP type.
Definition: codec.h:114
PN_EXTERN pn_data_t * pn_data(size_t capacity)
Construct a pn_data_t object with the supplied initial capacity.
PN_EXTERN bool pn_data_is_null(pn_data_t *data)
Checks if the current node is a PN_NULL.
PN_EXTERN int pn_data_print(pn_data_t *data)
Prints the contents of a pn_data_t object using pn_data_format() to stdout.
PN_EXTERN pn_decimal64_t pn_data_get_decimal64(pn_data_t *data)
If the current node is a decimal64, returns its value, returns 0 otherwise.
PN_EXTERN pn_bytes_t pn_data_get_symbol(pn_data_t *data)
If the current node is a symbol, returns its value, returns "" otherwise.
The decimal32 AMQP type.
Definition: codec.h:124
The decimal64 AMQP type.
Definition: codec.h:129
PN_EXTERN pn_handle_t pn_data_point(pn_data_t *data)
Returns a handle for the current navigational state of a pn_data_t so that it can be later restored u...
PN_EXTERN int pn_data_append(pn_data_t *data, pn_data_t *src)
Append the contents of another pn_data_t object.
int64_t as_long
Valid when type is PN_LONG.
Definition: codec.h:248
PN_EXTERN void pn_data_clear(pn_data_t *data)
Clears a pn_data_t object.
PN_EXTERN void pn_data_free(pn_data_t *data)
Free a pn_data_t object.
PN_EXTERN pn_type_t pn_data_get_array_type(pn_data_t *data)
Return the array type if the current node points to an array, undefined otherwise.
PN_EXTERN pn_error_t * pn_data_error(pn_data_t *data)
Access the current error for a givn pn_data_t.
PN_EXTERN bool pn_data_is_array_described(pn_data_t *data)
Returns true if the current node points to a described array.
An AMQP array.
Definition: codec.h:166
The unsigned int AMQP type.
Definition: codec.h:83
PN_EXTERN uint8_t pn_data_get_ubyte(pn_data_t *data)
If the current node is a PN_UBYTE, return its value, otherwise return 0.
PN_EXTERN pn_char_t pn_data_get_char(pn_data_t *data)
If the current node is a char, returns its value, returns 0 otherwise.
The long AMQP type.
Definition: codec.h:103
The byte AMQP type.
Definition: codec.h:68
The UUID AMQP type.
Definition: codec.h:139
PN_EXTERN uint16_t pn_data_get_ushort(pn_data_t *data)
If the current node is an unsigned short, returns its value, returns 0 otherwise. ...
PN_EXTERN int pn_data_put_bool(pn_data_t *data, bool b)
Puts a PN_BOOL value.
int8_t as_byte
Valid when type is PN_BYTE.
Definition: codec.h:213
PN_EXTERN uint64_t pn_data_get_ulong(pn_data_t *data)
If the current node is an unsigned long, returns its value, returns 0 otherwise.
PN_EXTERN void pn_data_narrow(pn_data_t *data)
Modify a pn_data_t object to behave as if the current node is the root node of the tree...
PN_EXTERN int pn_data_put_ushort(pn_data_t *data, uint16_t us)
Puts a PN_USHORT value.
PN_EXTERN void pn_data_widen(pn_data_t *data)
Reverse the effect of pn_data_narrow().
PN_EXTERN pn_decimal128_t pn_data_get_decimal128(pn_data_t *data)
If the current node is a decimal128, returns its value, returns 0 otherwise.
uint32_t pn_char_t
Definition: types.h:51
PN_EXTERN int32_t pn_data_get_int(pn_data_t *data)
If the current node is a signed int, returns its value, returns 0 otherwise.
PN_EXTERN int pn_data_put_null(pn_data_t *data)
Puts a PN_NULL value.
PN_EXTERN int pn_data_put_char(pn_data_t *data, pn_char_t c)
Puts a PN_CHAR value.
PN_EXTERN int pn_data_put_double(pn_data_t *data, double d)
Puts a PN_DOUBLE value.
uint64_t as_ulong
Valid when type is PN_ULONG.
Definition: codec.h:243
PN_EXTERN int pn_data_put_long(pn_data_t *data, int64_t l)
Puts a PN_LONG value.
PN_EXTERN int16_t pn_data_get_short(pn_data_t *data)
If the current node is a signed short, returns its value, returns 0 otherwise.
PN_EXTERN int pn_data_put_list(pn_data_t *data)
Puts an empty list value into a pn_data_t.
PN_EXTERN int pn_data_put_described(pn_data_t *data)
Puts a described value into a pn_data_t object.
pn_timestamp_t as_timestamp
Valid when type is PN_TIMESTAMP.
Definition: codec.h:253
uint64_t pn_decimal64_t
Definition: types.h:53
The unsigned byte AMQP type.
Definition: codec.h:63
pn_type_t
Identifies an AMQP type.
Definition: codec.h:48
uint8_t as_ubyte
Valid when type is PN_UBYTE.
Definition: codec.h:208
PN_EXTERN int pn_data_put_ulong(pn_data_t *data, uint64_t ul)
Puts a PN_ULONG value.
PN_EXTERN size_t pn_data_get_list(pn_data_t *data)
If the current node is a list, return the number of elements, otherwise return zero.
int16_t as_short
Valid when type is PN_SHORT.
Definition: codec.h:223
PN_EXTERN ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size)
Decodes a single value from the contents of the AMQP data stream into the current data object...
PN_EXTERN int pn_data_fill(pn_data_t *data, const char *fmt,...)
The decimal128 AMQP type.
Definition: codec.h:134
PN_EXTERN int pn_data_put_decimal64(pn_data_t *data, pn_decimal64_t d)
Puts a PN_DECIMAL64 value.
float as_float
Valid when type is PN_FLOAT.
Definition: codec.h:258
PN_EXTERN void pn_data_rewind(pn_data_t *data)
Clears current node pointer and sets the parent to the root node.
Definition: types.h:54
PN_EXTERN bool pn_data_enter(pn_data_t *data)
Sets the parent node to the current node and clears the current node.
PN_EXTERN int pn_data_put_atom(pn_data_t *data, pn_atom_t atom)
Puts any scalar value value.
The char AMQP type.
Definition: codec.h:93
Definition: types.h:61
PN_EXTERN int pn_data_scan(pn_data_t *data, const char *fmt,...)
PN_EXTERN int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap)
PN_EXTERN pn_bytes_t pn_data_get_binary(pn_data_t *data)
If the current node is binary, returns its value, returns "" otherwise.
PN_EXTERN uint32_t pn_data_get_uint(pn_data_t *data)
If the current node is an unsigned int, returns its value, returns 0 otherwise.
PN_EXTERN size_t pn_data_get_array(pn_data_t *data)
PN_EXTERN int pn_data_put_array(pn_data_t *data, bool described, pn_type_t type)
Puts an empty array value into a pn_data_t.
The NULL AMQP type.
Definition: codec.h:53
A described AMQP type.
Definition: codec.h:161
pn_char_t as_char
Valid when type is PN_CHAR.
Definition: codec.h:238
bool as_bool
Valid when type is PN_BOOL.
Definition: codec.h:203
PN_EXTERN pn_type_t pn_data_type(pn_data_t *data)
Access the type of the current node.