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 } 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  * Returns the number of bytes needed to encode a data object.
516  *
517  * @param data the data object
518  *
519  * @param ssize_t returns the size of the encoded data or an error code if data is invalid.
520  */
522 
523 /**
524  * Decodes a single value from the contents of the AMQP data stream
525  * into the current data object. Note that if the pn_data_t object is
526  * pointing to a current node, the decoded value will overwrite the
527  * current one. If the pn_data_t object has no current node then a
528  * node will be appended to the current parent. If there is no current
529  * parent then a node will be appended to the pn_data_t itself.
530  *
531  * Upon success, this operation returns the number of bytes consumed
532  * from the AMQP data stream. Upon failure, this operation returns an
533  * error code.
534  *
535  * @param data a pn_data_t object
536  * @param bytes a pointer to an encoded AMQP data stream
537  * @param size the size of the encoded AMQP data stream
538  * @return the number of bytes consumed from the AMQP data stream or an error code
539  */
540 PN_EXTERN ssize_t pn_data_decode(pn_data_t *data, const char *bytes, size_t size);
541 
542 /**
543  * Puts an empty list value into a pn_data_t. Elements may be filled
544  * by entering the list node using ::pn_data_enter() and using
545  * ::pn_data_put_* to add the desired contents. Once done,
546  * ::pn_data_exit() may be used to return to the current level in the
547  * tree and put more values.
548  *
549  * @code
550  * pn_data_t *data = pn_data(0);
551  * ...
552  * pn_data_put_list(data);
553  * pn_data_enter(data);
554  * pn_data_put_int(data, 1);
555  * pn_data_put_int(data, 2);
556  * pn_data_put_int(data, 3);
557  * pn_data_exit(data);
558  * ...
559  * @endcode
560  *
561  * @param data a pn_data_t object
562  * @return zero on success or an error code on failure
563  */
565 
566 /**
567  * Puts an empty map value into a pn_data_t. Elements may be filled by
568  * entering the map node and putting alternating key value pairs.
569  *
570  * @code
571  * pn_data_t *data = pn_data(0);
572  * ...
573  * pn_data_put_map(data);
574  * pn_data_enter(data);
575  * pn_data_put_string(data, pn_bytes(3, "key"));
576  * pn_data_put_string(data, pn_bytes(5, "value"));
577  * pn_data_exit(data);
578  * ...
579  * @endcode
580  *
581  * @param data a pn_data_t object
582  * @return zero on success or an error code on failure
583  */
585 
586 /**
587  * Puts an empty array value into a pn_data_t. Elements may be filled
588  * by entering the array node and putting the element values. The
589  * values must all be of the specified array element type. If an array
590  * is described then the first child value of the array is the
591  * descriptor and may be of any type.
592  *
593  * @code
594  * pn_data_t *data = pn_data(0);
595  * ...
596  * pn_data_put_array(data, false, PN_INT);
597  * pn_data_enter(data);
598  * pn_data_put_int(data, 1);
599  * pn_data_put_int(data, 2);
600  * pn_data_put_int(data, 3);
601  * pn_data_exit(data);
602  * ...
603  * pn_data_put_array(data, True, Data.DOUBLE);
604  * pn_data_enter(data);
605  * pn_data_put_symbol(data, "array-descriptor");
606  * pn_data_put_double(data, 1.1);
607  * pn_data_put_double(data, 1.2);
608  * pn_data_put_double(data, 1.3);
609  * pn_data_exit(data);
610  * ...
611  * @endcode
612  *
613  * @param data a pn_data_t object
614  * @param described specifies whether the array is described
615  * @param type the type of the array
616  *
617  * @return zero on success or an error code on failure
618  */
619 PN_EXTERN int pn_data_put_array(pn_data_t *data, bool described, pn_type_t type);
620 
621 /**
622  * Puts a described value into a pn_data_t object. A described node
623  * has two children, the descriptor and the value. These are specified
624  * by entering the node and putting the desired values.
625  *
626  * @code
627  * pn_data_t *data = pn_data(0);
628  * ...
629  * pn_data_put_described(data);
630  * pn_data_enter(data);
631  * pn_data_put_symbol(data, pn_bytes(16, "value-descriptor"));
632  * pn_data_put_string(data, pn_bytes(9, "the value"));
633  * pn_data_exit(data);
634  * ...
635  * @endcode
636  *
637  * @param data a pn_data_t object
638  * @return zero on success or an error code on failure
639  */
641 
642 /**
643  * Puts a ::PN_NULL value.
644  *
645  * @param data a pn_data_t object
646  * @return zero on success or an error code on failure
647  */
649 
650 /**
651  * Puts a ::PN_BOOL value.
652  *
653  * @param data a pn_data_t object
654  * @param b the value
655  * @return zero on success or an error code on failure
656  */
657 PN_EXTERN int pn_data_put_bool(pn_data_t *data, bool b);
658 
659 /**
660  * Puts a ::PN_UBYTE value.
661  *
662  * @param data a pn_data_t object
663  * @param ub the value
664  * @return zero on success or an error code on failure
665  */
666 PN_EXTERN int pn_data_put_ubyte(pn_data_t *data, uint8_t ub);
667 
668 /**
669  * Puts a ::PN_BYTE value.
670  *
671  * @param data a pn_data_t object
672  * @param b the value
673  * @return zero on success or an error code on failure
674  */
675 PN_EXTERN int pn_data_put_byte(pn_data_t *data, int8_t b);
676 
677 /**
678  * Puts a ::PN_USHORT value.
679  *
680  * @param data a pn_data_t object
681  * @param us the value
682  * @return zero on success or an error code on failure
683  */
684 PN_EXTERN int pn_data_put_ushort(pn_data_t *data, uint16_t us);
685 
686 /**
687  * Puts a ::PN_SHORT value.
688  *
689  * @param data a pn_data_t object
690  * @param s the value
691  * @return zero on success or an error code on failure
692  */
693 PN_EXTERN int pn_data_put_short(pn_data_t *data, int16_t s);
694 
695 /**
696  * Puts a ::PN_UINT value.
697  *
698  * @param data a pn_data_t object
699  * @param ui the value
700  * @return zero on success or an error code on failure
701  */
702 PN_EXTERN int pn_data_put_uint(pn_data_t *data, uint32_t ui);
703 
704 /**
705  * Puts a ::PN_INT value.
706  *
707  * @param data a pn_data_t object
708  * @param i the value
709  * @return zero on success or an error code on failure
710  */
711 PN_EXTERN int pn_data_put_int(pn_data_t *data, int32_t i);
712 
713 /**
714  * Puts a ::PN_CHAR value.
715  *
716  * @param data a pn_data_t object
717  * @param c the value
718  * @return zero on success or an error code on failure
719  */
721 
722 /**
723  * Puts a ::PN_ULONG value.
724  *
725  * @param data a pn_data_t object
726  * @param ul the value
727  * @return zero on success or an error code on failure
728  */
729 PN_EXTERN int pn_data_put_ulong(pn_data_t *data, uint64_t ul);
730 
731 /**
732  * Puts a ::PN_LONG value.
733  *
734  * @param data a pn_data_t object
735  * @param l the value
736  * @return zero on success or an error code on failure
737  */
738 PN_EXTERN int pn_data_put_long(pn_data_t *data, int64_t l);
739 
740 /**
741  * Puts a ::PN_TIMESTAMP value.
742  *
743  * @param data a pn_data_t object
744  * @param t the value
745  * @return zero on success or an error code on failure
746  */
748 
749 /**
750  * Puts a ::PN_FLOAT value.
751  *
752  * @param data a pn_data_t object
753  * @param f the value
754  * @return zero on success or an error code on failure
755  */
756 PN_EXTERN int pn_data_put_float(pn_data_t *data, float f);
757 
758 /**
759  * Puts a ::PN_DOUBLE 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  */
765 PN_EXTERN int pn_data_put_double(pn_data_t *data, double d);
766 
767 /**
768  * Puts a ::PN_DECIMAL32 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_DECIMAL64 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_DECIMAL128 value.
787  *
788  * @param data a pn_data_t object
789  * @param d the value
790  * @return zero on success or an error code on failure
791  */
793 
794 /**
795  * Puts a ::PN_UUID value.
796  *
797  * @param data a pn_data_t object
798  * @param u the value
799  * @return zero on success or an error code on failure
800  */
802 
803 /**
804  * Puts a ::PN_BINARY value. The bytes referenced by the pn_bytes_t
805  * argument are copied and stored inside the pn_data_t object.
806  *
807  * @param data a pn_data_t object
808  * @param bytes the value
809  * @return zero on success or an error code on failure
810  */
812 
813 /**
814  * Puts a ::PN_STRING value. The bytes referenced by the pn_bytes_t
815  * argument are copied and stored inside the pn_data_t object.
816  *
817  * @param data a pn_data_t object
818  * @param string utf8 encoded unicode
819  * @return zero on success or an error code on failure
820  */
822 
823 /**
824  * Puts a ::PN_SYMBOL value. The bytes referenced by the pn_bytes_t
825  * argument are copied and stored inside the pn_data_t object.
826  *
827  * @param data a pn_data_t object
828  * @param symbol ascii encoded symbol
829  * @return zero on success or an error code on failure
830  */
832 
833 /**
834  * Puts any scalar value value.
835  *
836  * @param data a pn_data_t object
837  * @param atom the value
838  * @return zero on success or an error code on failure
839  */
841 
842 /**
843  * If the current node is a list, return the number of elements,
844  * otherwise return zero. List elements can be accessed by entering
845  * the list.
846  *
847  * @code
848  * ...
849  * size_t count = pn_data_get_list(data);
850  * pn_data_enter(data);
851  * for (size_t i = 0; i < count; i++) {
852  * if (pn_data_next(data)) {
853  * switch (pn_data_type(data)) {
854  * case PN_STRING:
855  * ...
856  * break;
857  * case PN_INT:
858  * ...
859  * break;
860  * }
861  * }
862  * pn_data_exit(data);
863  * ...
864  * @endcode
865 .*
866  * @param data a pn_data_t object
867  * @return the size of a list node
868  */
869 PN_EXTERN size_t pn_data_get_list(pn_data_t *data);
870 
871 /**
872  * If the current node is a map, return the number of child elements,
873  * otherwise return zero. Key value pairs can be accessed by entering
874  * the map.
875  *
876  * @code
877  * ...
878  * size_t count = pn_data_get_map(data);
879  * pn_data_enter(data);
880  * for (size_t i = 0; i < count/2; i++) {
881  * // read key
882  * if (pn_data_next(data)) {
883  * switch (pn_data_type(data)) {
884  * case PN_STRING:
885  * ...
886  * break;
887  * ...
888  * }
889  * }
890  * ...
891  * // read value
892  * if (pn_data_next(data)) {
893  * switch (pn_data_type(data)) {
894  * case PN_INT:
895  * ...
896  * break;
897  * ...
898  * }
899  * }
900  * ...
901  * }
902  * pn_data_exit(data);
903  * ...
904  * @endcode
905  *
906  * @param data a pn_data_t object
907  * @return the number of child elements of a map node
908  */
909 PN_EXTERN size_t pn_data_get_map(pn_data_t *data);
910 
911 /**
912  * If the current node is an array, return the number of elements in
913  * the array, otherwise return 0. Array data can be accessed by
914  * entering the array. If the array is described, the first child node
915  * will be the descriptor, and the remaining @var count child nodes
916  * will be the elements of the array.
917  *
918  * @code
919  * ...
920  * size_t count = pn_data_get_array(data);
921  * bool described = pn_data_is_array_described(data);
922  * pn_type_t type = pn_data_get_array_type(data);
923  *
924  * pn_data_enter(data);
925  *
926  * if (described && pn_data_next(data)) {
927  * // the descriptor could be another type, but let's assume it's a symbol
928  * pn_bytes_t descriptor = pn_data_get_symbol(data);
929  * }
930  *
931  * for (size_t i = 0; i < count; i++) {
932  * if (pn_data_next(data)) {
933  * // all elements will be values of the array type retrieved above
934  * ...
935  * }
936  * }
937  * pn_data_exit(data);
938  * ...
939  * @endcode
940  *
941  * @param data a pn_data_t object
942  * @return the number of elements of an array node
943  */
945 
946 /**
947  * Returns true if the current node points to a described array.
948  *
949  * @param data a pn_data_t object
950  * @return true if the current node points to a described array
951  */
953 
954 /**
955  * Return the array type if the current node points to an array,
956  * undefined otherwise.
957  *
958  * @param data a pn_data_t object
959  * @return the element type of an array node
960  */
962 
963 /**
964  * Checks if the current node is a described value. The descriptor and
965  * value may be accessed by entering the described value node.
966  *
967  * @code
968  * ...
969  * // read a symbolically described string
970  * if (pn_data_is_described(data)) {
971  * pn_data_enter(data);
972  * pn_data_next(data);
973  * assert(pn_data_type(data) == PN_SYMBOL);
974  * pn_bytes_t symbol = pn_data_get_symbol(data);
975  * pn_data_next(data);
976  * assert(pn_data_type(data) == PN_STRING);
977  * pn_bytes_t utf8 = pn_data_get_string(data);
978  * pn_data_exit(data);
979  * }
980  * ...
981  * @endcode
982  *
983  * @param data a pn_data_t object
984  * @return true if the current node is a described type
985  */
987 
988 /**
989  * Checks if the current node is a ::PN_NULL.
990  *
991  * @param data a pn_data_t object
992  * @return true iff the current node is ::PN_NULL
993  */
995 
996 /**
997  * If the current node is a ::PN_BOOL, returns its value.
998  *
999  * @param data a pn_data_t object
1000  */
1002 
1003 /**
1004  * If the current node is a ::PN_UBYTE, return its value, otherwise
1005  * return 0.
1006  *
1007  * @param data a pn_data_t object
1008  */
1009 PN_EXTERN uint8_t pn_data_get_ubyte(pn_data_t *data);
1010 
1011 /**
1012  * If the current node is a signed byte, returns its value, returns 0
1013  * otherwise.
1014  *
1015  * @param data a pn_data_t object
1016  */
1017 PN_EXTERN int8_t pn_data_get_byte(pn_data_t *data);
1018 
1019 /**
1020  * If the current node is an unsigned short, returns its value,
1021  * returns 0 otherwise.
1022  *
1023  * @param data a pn_data_t object
1024  */
1025 PN_EXTERN uint16_t pn_data_get_ushort(pn_data_t *data);
1026 
1027 /**
1028  * If the current node is a signed short, returns its value, returns 0
1029  * otherwise.
1030  *
1031  * @param data a pn_data_t object
1032  */
1033 PN_EXTERN int16_t pn_data_get_short(pn_data_t *data);
1034 
1035 /**
1036  * If the current node is an unsigned int, returns its value, returns
1037  * 0 otherwise.
1038  *
1039  * @param data a pn_data_t object
1040  */
1041 PN_EXTERN uint32_t pn_data_get_uint(pn_data_t *data);
1042 
1043 /**
1044  * If the current node is a signed int, returns its value, returns 0
1045  * otherwise.
1046  *
1047  * @param data a pn_data_t object
1048  */
1049 PN_EXTERN int32_t pn_data_get_int(pn_data_t *data);
1050 
1051 /**
1052  * If the current node is a char, returns its value, returns 0
1053  * otherwise.
1054  *
1055  * @param data a pn_data_t object
1056  */
1058 
1059 /**
1060  * If the current node is an unsigned long, returns its value, returns
1061  * 0 otherwise.
1062  *
1063  * @param data a pn_data_t object
1064  */
1065 PN_EXTERN uint64_t pn_data_get_ulong(pn_data_t *data);
1066 
1067 /**
1068  * If the current node is an signed long, returns its value, returns 0
1069  * otherwise.
1070  *
1071  * @param data a pn_data_t object
1072  */
1073 PN_EXTERN int64_t pn_data_get_long(pn_data_t *data);
1074 
1075 /**
1076  * If the current node is a timestamp, returns its value, returns 0
1077  * otherwise.
1078  *
1079  * @param data a pn_data_t object
1080  */
1082 
1083 /**
1084  * If the current node is a float, returns its value, raises 0
1085  * otherwise.
1086  *
1087  * @param data a pn_data_t object
1088  */
1090 
1091 /**
1092  * If the current node is a double, returns its value, returns 0
1093  * otherwise.
1094  *
1095  * @param data a pn_data_t object
1096  */
1097 PN_EXTERN double pn_data_get_double(pn_data_t *data);
1098 
1099 /**
1100  * If the current node is a decimal32, returns its value, returns 0
1101  * otherwise.
1102  *
1103  * @param data a pn_data_t object
1104  */
1106 
1107 /**
1108  * If the current node is a decimal64, returns its value, returns 0
1109  * otherwise.
1110  *
1111  * @param data a pn_data_t object
1112  */
1114 
1115 /**
1116  * If the current node is a decimal128, returns its value, returns 0
1117  * otherwise.
1118  *
1119  * @param data a pn_data_t object
1120  */
1122 
1123 /**
1124  * If the current node is a UUID, returns its value, returns None
1125  * otherwise.
1126  *
1127  * @param data a pn_data_t object
1128  * @return a uuid value
1129  */
1131 
1132 /**
1133  * If the current node is binary, returns its value, returns ""
1134  * otherwise. The pn_bytes_t returned will point to memory held inside
1135  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1136  * will be reclaimed.
1137  *
1138  * @param data a pn_data_t object
1139  */
1141 
1142 /**
1143  * If the current node is a string, returns its value, returns ""
1144  * otherwise. The pn_bytes_t returned will point to memory held inside
1145  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1146  * will be reclaimed.
1147  *
1148  * @param data a pn_data_t object
1149  * @return a pn_bytes_t pointing to utf8
1150  */
1152 
1153 /**
1154  * If the current node is a symbol, returns its value, returns ""
1155  * otherwise. The pn_bytes_t returned will point to memory held inside
1156  * the pn_data_t. When the pn_data_t is cleared or freed, this memory
1157  * will be reclaimed.
1158  *
1159  * @param data a pn_data_t object
1160  * @return a pn_bytes_t pointing to ascii
1161  */
1163 
1164 /**
1165  * If the current node is a symbol, string, or binary, return the
1166  * bytes representing its value. The pn_bytes_t returned will point to
1167  * memory held inside the pn_data_t. When the pn_data_t is cleared or
1168  * freed, this memory will be reclaimed.
1169  *
1170  * @param data a pn_data_t object
1171  * @return a pn_bytes_t pointing to the node's value
1172  */
1174 
1175 /**
1176  * If the current node is a scalar value, return it as a pn_atom_t.
1177  *
1178  * @param data a pn_data_t object
1179  * @return the value of the current node as pn_atom_t
1180  */
1182 
1183 /**
1184  * Copy the contents of another pn_data_t object. Any values in the
1185  * data object will be lost.
1186  *
1187  * @param data a pn_data_t object
1188  * @param src the sourc pn_data_t to copy from
1189  * @return zero on success or an error code on failure
1190  */
1191 PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src);
1192 
1193 /**
1194  * Append the contents of another pn_data_t object.
1195  *
1196  * @param data a pn_data_t object
1197  * @param src the sourc pn_data_t to append from
1198  * @return zero on success or an error code on failure
1199  */
1200 PN_EXTERN int pn_data_append(pn_data_t *data, pn_data_t *src);
1201 
1202 /**
1203  * Append up to _n_ values from the contents of another pn_data_t
1204  * object.
1205  *
1206  * @param data a pn_data_t object
1207  * @param src the sourc pn_data_t to append from
1208  * @param limit the maximum number of values to append
1209  * @return zero on success or an error code on failure
1210  */
1211 PN_EXTERN int pn_data_appendn(pn_data_t *data, pn_data_t *src, int limit);
1212 
1213 /**
1214  * Modify a pn_data_t object to behave as if the current node is the
1215  * root node of the tree. This impacts the behaviour of
1216  * ::pn_data_rewind(), ::pn_data_next(), ::pn_data_prev(), and
1217  * anything else that depends on the navigational state of the
1218  * pn_data_t object. Use ::pn_data_widen() to reverse the effect of
1219  * this operation.
1220  *
1221  * @param data a pn_data_t object
1222  */
1223 PN_EXTERN void pn_data_narrow(pn_data_t *data);
1224 
1225 /**
1226  * Reverse the effect of ::pn_data_narrow().
1227  *
1228  * @param data a pn_data_t object
1229  */
1230 PN_EXTERN void pn_data_widen(pn_data_t *data);
1231 
1232 /**
1233  * Returns a handle for the current navigational state of a pn_data_t
1234  * so that it can be later restored using ::pn_data_restore().
1235  *
1236  * @param data a pn_data_t object
1237  * @return a handle for the current navigational state
1238  */
1240 
1241 /**
1242  * Restores a prior navigational state that was saved using
1243  * ::pn_data_point(). If the data object has been modified in such a
1244  * way that the prior navigational state cannot be restored, then this
1245  * will return false and the navigational state will remain unchanged,
1246  * otherwise it will return true.
1247  *
1248  * @param data a pn_data_t object
1249  * @param handle a handle referencing the saved navigational state
1250  * @return true iff the prior navigational state was restored
1251  */
1252 PN_EXTERN bool pn_data_restore(pn_data_t *data, pn_handle_t point);
1253 
1254 /**
1255  * Dumps a debug representation of the internal state of the pn_data_t
1256  * object that includes its navigational state to stdout for debugging
1257  * purposes.
1258  *
1259  * @param data a pn_data_t object that is behaving in a confusing way
1260  */
1261 PN_EXTERN void pn_data_dump(pn_data_t *data);
1262 
1263 /** @}
1264  */
1265 
1266 #ifdef __cplusplus
1267 }
1268 #endif
1269 
1270 #endif /* codec.h */
PN_EXTERN bool pn_data_prev(pn_data_t *data)
Moves the current node to its previous sibling and returns true.
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.
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 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_put_decimal64(pn_data_t *data, pn_decimal64_t d)
Puts a PN_DECIMAL64 value.
PN_EXTERN int pn_data_put_float(pn_data_t *data, float f)
Puts a PN_FLOAT value.
The char AMQP type.
Definition: codec.h:93
PN_EXTERN bool pn_data_is_null(pn_data_t *data)
Checks if the current node is a PN_NULL.
uint32_t as_uint
Valid when type is PN_UINT.
Definition: codec.h:228
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.
double as_double
Valid when type is PN_DOUBLE.
Definition: codec.h:263
PN_EXTERN int pn_data_put_int(pn_data_t *data, int32_t i)
Puts a PN_INT value.
struct pn_error_t pn_error_t
Definition: error.h:32
pn_decimal32_t as_decimal32
Valid when type is PN_DECIMAL32.
Definition: codec.h:268
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.
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 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_char(pn_data_t *data, pn_char_t c)
Puts a PN_CHAR value.
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...
The signed int AMQP type.
Definition: codec.h:88
PN_EXTERN pn_type_t pn_data_type(pn_data_t *data)
Access the type of the current node.
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.
A descriminated union that holds any scalar AMQP value.
Definition: codec.h:193
PN_EXTERN bool pn_data_next(pn_data_t *data)
Advances the current node to its next sibling and returns true.
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 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_binary(pn_data_t *data, pn_bytes_t bytes)
Puts a PN_BINARY value.
The boolean AMQP type.
Definition: codec.h:58
PN_EXTERN int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap)
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.
The timestamp AMQP type.
Definition: codec.h:109
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 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
An AMQP array.
Definition: codec.h:166
PN_EXTERN int pn_data_scan(pn_data_t *data, const char *fmt,...)
The float AMQP type.
Definition: codec.h:114
uint64_t pn_decimal64_t
Definition: types.h:52
PN_EXTERN int pn_data_put_map(pn_data_t *data)
Puts an empty map value into a pn_data_t.
uint32_t pn_char_t
Definition: types.h:50
The short AMQP type.
Definition: codec.h:78
PN_EXTERN pn_error_t * pn_data_error(pn_data_t *data)
Access the current error for a givn pn_data_t.
PN_EXTERN int pn_data_put_ushort(pn_data_t *data, uint16_t us)
Puts a PN_USHORT value.
pn_decimal128_t as_decimal128
Valid when type is PN_DECIMAL128.
Definition: codec.h:278
PN_EXTERN void pn_data_free(pn_data_t *data)
Free a pn_data_t object.
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_bool(pn_data_t *data, bool b)
Puts a PN_BOOL value.
PN_EXTERN int pn_data_put_ubyte(pn_data_t *data, uint8_t ub)
Puts a PN_UBYTE value.
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.
The string AMQP type.
Definition: codec.h:150
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 const char * pn_type_name(pn_type_t type)
Return a string name for an AMQP type.
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_atom(pn_data_t *data, pn_atom_t atom)
Puts any scalar value value.
PN_EXTERN bool pn_data_is_array_described(pn_data_t *data)
Returns true if the current node points to a described array.
Definition: types.h:56
An AMQP map.
Definition: codec.h:177
pn_bytes_t as_bytes
Valid when type is PN_BINARY or PN_STRING or PN_SYMBOL.
Definition: codec.h:292
The double AMQP type.
Definition: codec.h:119
The decimal32 AMQP type.
Definition: codec.h:124
The symbol AMQP type.
Definition: codec.h:156
PN_EXTERN int pn_data_vfill(pn_data_t *data, const char *fmt, va_list ap)
pn_uuid_t as_uuid
Valid when type is PN_UUID.
Definition: codec.h:283
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 size_t pn_data_get_array(pn_data_t *data)
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 double pn_data_get_double(pn_data_t *data)
If the current node is a double, returns its value, returns 0 otherwise.
#define PN_EXTERN
Definition: import_export.h:53
The unsigned byte AMQP type.
Definition: codec.h:63
A described AMQP type.
Definition: codec.h:161
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.
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 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_put_symbol(pn_data_t *data, pn_bytes_t symbol)
Puts a PN_SYMBOL value.
PN_EXTERN int pn_data_put_timestamp(pn_data_t *data, pn_timestamp_t t)
Puts a PN_TIMESTAMP value.
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.
PN_EXTERN bool pn_data_is_described(pn_data_t *data)
Checks if the current node is a described value.
PN_EXTERN bool pn_data_lookup(pn_data_t *data, const char *name)
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 pn_bytes_t pn_data_get_string(pn_data_t *data)
If the current node is a string, returns its value, returns "" otherwise.
int64_t as_long
Valid when type is PN_LONG.
Definition: codec.h:248
PN_EXTERN void pn_data_widen(pn_data_t *data)
Reverse the effect of pn_data_narrow().
PN_EXTERN int pn_data_put_described(pn_data_t *data)
Puts a described value into a pn_data_t object.
struct pn_data_t pn_data_t
An AMQP Data object.
Definition: codec.h:352
The decimal64 AMQP type.
Definition: codec.h:129
PN_EXTERN int pn_data_put_uuid(pn_data_t *data, pn_uuid_t u)
Puts a PN_UUID value.
PN_EXTERN int pn_data_put_decimal128(pn_data_t *data, pn_decimal128_t d)
Puts a PN_DECIMAL128 value.
PN_EXTERN void pn_data_clear(pn_data_t *data)
Clears a pn_data_t object.
int8_t as_byte
Valid when type is PN_BYTE.
Definition: codec.h:213
PN_EXTERN int pn_data_put_byte(pn_data_t *data, int8_t b)
Puts a PN_BYTE value.
PN_EXTERN ssize_t pn_data_encoded_size(pn_data_t *data)
Returns the number of bytes needed to encode a data object.
The unsigned short AMQP type.
Definition: codec.h:73
PN_EXTERN int pn_data_errno(pn_data_t *data)
Access the current error code for a given pn_data_t.
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 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 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_enter(pn_data_t *data)
Sets the parent node to the current node and clears the current node.
PN_EXTERN int pn_data_put_null(pn_data_t *data)
Puts a PN_NULL value.
uint64_t as_ulong
Valid when type is PN_ULONG.
Definition: codec.h:243
PN_EXTERN int pn_data_put_decimal32(pn_data_t *data, pn_decimal32_t d)
Puts a PN_DECIMAL32 value.
The binary AMQP type.
Definition: codec.h:144
An AMQP list.
Definition: codec.h:171
PN_EXTERN int pn_data_fill(pn_data_t *data, const char *fmt,...)
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_timestamp_t as_timestamp
Valid when type is PN_TIMESTAMP.
Definition: codec.h:253
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.
The UUID AMQP type.
Definition: codec.h:139
PN_EXTERN int pn_data_copy(pn_data_t *data, pn_data_t *src)
Copy the contents of another pn_data_t object.
The long AMQP type.
Definition: codec.h:103
The decimal128 AMQP type.
Definition: codec.h:134
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.
The unsigned int AMQP type.
Definition: codec.h:83
uint8_t as_ubyte
Valid when type is PN_UBYTE.
Definition: codec.h:208
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_uuid_t pn_data_get_uuid(pn_data_t *data)
If the current node is a UUID, returns its value, returns None otherwise.
int16_t as_short
Valid when type is PN_SHORT.
Definition: codec.h:223
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 int pn_data_put_long(pn_data_t *data, int64_t l)
Puts a PN_LONG value.
PN_EXTERN int pn_data_put_string(pn_data_t *data, pn_bytes_t string)
Puts a PN_STRING value.
int64_t pn_timestamp_t
Definition: types.h:49
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_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 int8_t pn_data_get_byte(pn_data_t *data)
If the current node is a signed byte, returns its value, returns 0 otherwise.
float as_float
Valid when type is PN_FLOAT.
Definition: codec.h:258
PN_EXTERN int pn_data_put_short(pn_data_t *data, int16_t s)
Puts a PN_SHORT value.
The NULL AMQP type.
Definition: codec.h:53
Definition: types.h:53
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_size(pn_data_t *data)
Returns the total number of nodes contained in a pn_data_t object.
uint32_t pn_decimal32_t
Definition: types.h:51
Definition: types.h:60
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 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_double(pn_data_t *data, double d)
Puts a PN_DOUBLE value.
PN_EXTERN pn_data_t * pn_data(size_t capacity)
Construct a pn_data_t object with the supplied initial capacity.
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 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...
The byte AMQP type.
Definition: codec.h:68
pn_type_t
Identifies an AMQP type.
Definition: codec.h:48