summaryrefslogtreecommitdiff
path: root/qpid/extras/dispatch/include/qpid/dispatch/compose.h
blob: 514b450e58d36b3abcafadc02812bc00a865da94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef __dispatch_compose_h__
#define __dispatch_compose_h__ 1
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include <qpid/dispatch/buffer.h>
#include <qpid/dispatch/iterator.h>

typedef struct dx_composed_field_t dx_composed_field_t;

#define DX_PERFORMATIVE_HEADER                  0x70
#define DX_PERFORMATIVE_DELIVERY_ANNOTATIONS    0x71
#define DX_PERFORMATIVE_MESSAGE_ANNOTATIONS     0x72  
#define DX_PERFORMATIVE_PROPERTIES              0x73
#define DX_PERFORMATIVE_APPLICATION_PROPERTIES  0x74
#define DX_PERFORMATIVE_BODY_DATA               0x75
#define DX_PERFORMATIVE_BODY_AMQP_SEQUENCE      0x76
#define DX_PERFORMATIVE_BODY_AMQP_VALUE         0x77
#define DX_PERFORMATIVE_FOOTER                  0x78

/**
 * Begin composing a new field for a message.  The new field can be standalone or
 * appended onto an existing field.
 *
 * @param performative The performative for the message section being composed.
 * @param extend An existing field onto which to append the new field or NULL to
 *        create a standalone field.
 * @return A pointer to the newly created field.
 */
dx_composed_field_t *dx_compose(uint8_t performative, dx_composed_field_t *extend);

/**
 * Free the resources associated with a composed field.
 *
 * @param A field pointer returned by dx_compose.
 */
void dx_compose_free(dx_composed_field_t *field);

/**
 * Begin to compose the elements of a list in the field.  This is called before inserting
 * the first list element.
 *
 * @param field A field created by dx_compose.
 */
void dx_compose_start_list(dx_composed_field_t *field);

/**
 * Complete the composition of a list in the field.  This is called after the last
 * list element has been inserted.
 *
 * @param field A field created by dx_compose.
 */
void dx_compose_end_list(dx_composed_field_t *field);

/**
 * Begin to compose the elements os a map in the field.  This is called before
 * inserting the first element-pair into the map.
 *
 * @param field A field created by dx_compose.
 */
void dx_compose_start_map(dx_composed_field_t *field);

/**
 * Complete the composition of a map in the field.  This is called after the last
 * element-pair has been inserted.
 *
 * @param field A field created by dx_compose.
 */
void dx_compose_end_map(dx_composed_field_t *field);

/**
 * Insert a null element into the field.
 *
 * @param field A field created by dx_compose.
 */
void dx_compose_insert_null(dx_composed_field_t *field);

/**
 * Insert a boolean value into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The boolean (zero or non-zero) value to insert.
 */
void dx_compose_insert_bool(dx_composed_field_t *field, int value);

/**
 * Insert an unsigned integer (up to 32 bits) into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The unsigned integer value to be inserted.
 */
void dx_compose_insert_uint(dx_composed_field_t *field, uint32_t value);

/**
 * Insert a long (64-bit) unsigned value into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The unsigned integer value to be inserted.
 */
void dx_compose_insert_ulong(dx_composed_field_t *field, uint64_t value);

/**
 * Insert a signed integer (up to 32 bits) into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The integer value to be inserted.
 */
void dx_compose_insert_int(dx_composed_field_t *field, int32_t value);

/**
 * Insert a long signed integer (64 bits) into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The integer value to be inserted.
 */
void dx_compose_insert_long(dx_composed_field_t *field, int64_t value);

/**
 * Insert a timestamp into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The timestamp value to be inserted.
 */
void dx_compose_insert_timestamp(dx_composed_field_t *field, uint64_t value);

/**
 * Insert a UUID into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The pointer to the first octet in the UUID to be inserted.
 */
void dx_compose_insert_uuid(dx_composed_field_t *field, const uint8_t *value);

/**
 * Insert a binary blob into the field.
 *
 * @param field A field created by dx_compose.
 * @param value The pointer to the first octet to be inserted.
 * @param len The length, in octets, of the binary blob.
 */
void dx_compose_insert_binary(dx_composed_field_t *field, const uint8_t *value, uint32_t len);

/**
 * Insert a binary blob from a list of buffers.
 *
 * @param field A field created by dx_compose.
 * @param buffers A pointer to a list of buffers to be inserted as binary data.  Note that
 *        the buffer list will be left empty by this function.
 */
void dx_compose_insert_binary_buffers(dx_composed_field_t *field, dx_buffer_list_t *buffers);

/**
 * Insert a null-terminated utf8-encoded string into the field.
 *
 * @param field A field created by dx_compose.
 * @param value A pointer to a null-terminated string.
 */
void dx_compose_insert_string(dx_composed_field_t *field, const char *value);

/**
 * Insert a utf8-encoded string into the field from an iterator
 *
 * @param field A field created by dx_compose.
 * @param value A pointer to a null-terminated string.
 */
void dx_compose_insert_string_iterator(dx_composed_field_t *field, dx_field_iterator_t *iter);

/**
 * Insert a symbol into the field.
 *
 * @param field A field created by dx_compose.
 * @param value A pointer to a null-terminated ASCII string.
 */
void dx_compose_insert_symbol(dx_composed_field_t *field, const char *value);

#endif