| 1 |
#ifndef _PROTON_DATA_H |
| 2 |
#define _PROTON_DATA_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/codec.h> |
| 26 |
#include "buffer.h" |
| 27 |
#include "decoder.h" |
| 28 |
#include "encoder.h" |
| 29 |
|
| 30 |
typedef uint16_t pni_nid_t; |
| 31 |
#define PNI_NID_MAX ((pni_nid_t)-1) |
| 32 |
#define PNI_INTERN_MINSIZE 64 |
| 33 |
|
| 34 |
typedef struct { |
| 35 |
size_t start; |
| 36 |
size_t data_offset; |
| 37 |
size_t data_size; |
| 38 |
pn_atom_t atom; |
| 39 |
pn_type_t type; |
| 40 |
pni_nid_t next; |
| 41 |
pni_nid_t prev; |
| 42 |
pni_nid_t down; |
| 43 |
pni_nid_t parent; |
| 44 |
pni_nid_t children; |
| 45 |
// for arrays |
| 46 |
bool described; |
| 47 |
bool data; |
| 48 |
bool small; |
| 49 |
} pni_node_t; |
| 50 |
|
| 51 |
struct pn_data_t { |
| 52 |
pni_node_t *nodes; |
| 53 |
pn_buffer_t *buf; |
| 54 |
pn_error_t *error; |
| 55 |
pni_nid_t capacity; |
| 56 |
pni_nid_t size; |
| 57 |
pni_nid_t parent; |
| 58 |
pni_nid_t current; |
| 59 |
pni_nid_t base_parent; |
| 60 |
pni_nid_t base_current; |
| 61 |
}; |
| 62 |
|
| 63 |
static inline pni_node_t * pn_data_node(pn_data_t *data, pni_nid_t nd) |
| 64 |
{ |
| 65 |
return nd ? (data->nodes + nd - 1) : NULL; |
| 66 |
} |
| 67 |
|
| 68 |
int pni_data_traverse(pn_data_t *data, |
| 69 |
int (*enter)(void *ctx, pn_data_t *data, pni_node_t *node), |
| 70 |
int (*exit)(void *ctx, pn_data_t *data, pni_node_t *node), |
| 71 |
void *ctx); |
| 72 |
|
| 73 |
int pni_inspect_atom(pn_atom_t *atom, pn_string_t *str); |
| 74 |
|
| 75 |
#endif /* data.h */ |