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