~stub/ubuntu/trusty/avro-c/trunk

« back to all changes in this revision

Viewing changes to src/datum.h

  • Committer: Stuart Bishop
  • Date: 2015-05-14 11:53:53 UTC
  • Revision ID: stuart@stuartbishop.net-20150514115353-0cvnrcyohcq5l7yj
Tags: upstream-1.7.7
ImportĀ upstreamĀ versionĀ 1.7.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to you under the Apache License, Version 2.0 
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 * http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
14
 * implied.  See the License for the specific language governing
 
15
 * permissions and limitations under the License. 
 
16
 */
 
17
 
 
18
#ifndef AVRO_DATUM_H
 
19
#define AVRO_DATUM_H
 
20
#include <avro/platform.h>
 
21
#include "avro/basics.h"
 
22
#include "avro/data.h"
 
23
#include "avro/legacy.h"
 
24
#include "avro/schema.h"
 
25
#include "avro_private.h"
 
26
#include "st.h"
 
27
 
 
28
struct avro_string_datum_t {
 
29
        struct avro_obj_t obj;
 
30
        char *s;
 
31
        int64_t size;
 
32
        avro_free_func_t  free;
 
33
};
 
34
 
 
35
struct avro_bytes_datum_t {
 
36
        struct avro_obj_t obj;
 
37
        char *bytes;
 
38
        int64_t size;
 
39
        avro_free_func_t  free;
 
40
};
 
41
 
 
42
struct avro_int32_datum_t {
 
43
        struct avro_obj_t obj;
 
44
        int32_t i32;
 
45
};
 
46
 
 
47
struct avro_int64_datum_t {
 
48
        struct avro_obj_t obj;
 
49
        int64_t i64;
 
50
};
 
51
 
 
52
struct avro_float_datum_t {
 
53
        struct avro_obj_t obj;
 
54
        float f;
 
55
};
 
56
 
 
57
struct avro_double_datum_t {
 
58
        struct avro_obj_t obj;
 
59
        double d;
 
60
};
 
61
 
 
62
struct avro_boolean_datum_t {
 
63
        struct avro_obj_t obj;
 
64
        int8_t i;
 
65
};
 
66
 
 
67
struct avro_fixed_datum_t {
 
68
        struct avro_obj_t obj;
 
69
        avro_schema_t schema;
 
70
        char *bytes;
 
71
        int64_t size;
 
72
        avro_free_func_t  free;
 
73
};
 
74
 
 
75
struct avro_map_datum_t {
 
76
        struct avro_obj_t obj;
 
77
        avro_schema_t schema;
 
78
        st_table *map;
 
79
        st_table *indices_by_key;
 
80
        st_table *keys_by_index;
 
81
};
 
82
 
 
83
struct avro_record_datum_t {
 
84
        struct avro_obj_t obj;
 
85
        avro_schema_t schema;
 
86
        st_table *field_order;
 
87
        st_table *fields_byname;
 
88
};
 
89
 
 
90
struct avro_enum_datum_t {
 
91
        struct avro_obj_t obj;
 
92
        avro_schema_t schema;
 
93
        int value;
 
94
};
 
95
 
 
96
struct avro_array_datum_t {
 
97
        struct avro_obj_t obj;
 
98
        avro_schema_t schema;
 
99
        st_table *els;
 
100
};
 
101
 
 
102
struct avro_union_datum_t {
 
103
        struct avro_obj_t obj;
 
104
        avro_schema_t schema;
 
105
        int64_t discriminant;
 
106
        avro_datum_t value;
 
107
};
 
108
 
 
109
#define avro_datum_to_string(datum_)    (container_of(datum_, struct avro_string_datum_t, obj))
 
110
#define avro_datum_to_bytes(datum_)     (container_of(datum_, struct avro_bytes_datum_t, obj))
 
111
#define avro_datum_to_int32(datum_)     (container_of(datum_, struct avro_int32_datum_t, obj))
 
112
#define avro_datum_to_int64(datum_)     (container_of(datum_, struct avro_int64_datum_t, obj))
 
113
#define avro_datum_to_float(datum_)     (container_of(datum_, struct avro_float_datum_t, obj))
 
114
#define avro_datum_to_double(datum_)    (container_of(datum_, struct avro_double_datum_t, obj))
 
115
#define avro_datum_to_boolean(datum_)   (container_of(datum_, struct avro_boolean_datum_t, obj))
 
116
#define avro_datum_to_fixed(datum_)     (container_of(datum_, struct avro_fixed_datum_t, obj))
 
117
#define avro_datum_to_map(datum_)       (container_of(datum_, struct avro_map_datum_t, obj))
 
118
#define avro_datum_to_record(datum_)    (container_of(datum_, struct avro_record_datum_t, obj))
 
119
#define avro_datum_to_enum(datum_)      (container_of(datum_, struct avro_enum_datum_t, obj))
 
120
#define avro_datum_to_array(datum_)     (container_of(datum_, struct avro_array_datum_t, obj))
 
121
#define avro_datum_to_union(datum_)     (container_of(datum_, struct avro_union_datum_t, obj))
 
122
 
 
123
#endif