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

« back to all changes in this revision

Viewing changes to src/avro/schema.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_SCHEMA_H
 
19
#define AVRO_SCHEMA_H
 
20
#ifdef __cplusplus
 
21
extern "C" {
 
22
#define CLOSE_EXTERN }
 
23
#else
 
24
#define CLOSE_EXTERN
 
25
#endif
 
26
 
 
27
#include <avro/platform.h>
 
28
#include <stdlib.h>
 
29
 
 
30
#include <avro/basics.h>
 
31
 
 
32
typedef struct avro_obj_t *avro_schema_t;
 
33
 
 
34
avro_schema_t avro_schema_string(void);
 
35
avro_schema_t avro_schema_bytes(void);
 
36
avro_schema_t avro_schema_int(void);
 
37
avro_schema_t avro_schema_long(void);
 
38
avro_schema_t avro_schema_float(void);
 
39
avro_schema_t avro_schema_double(void);
 
40
avro_schema_t avro_schema_boolean(void);
 
41
avro_schema_t avro_schema_null(void);
 
42
 
 
43
avro_schema_t avro_schema_record(const char *name, const char *space);
 
44
avro_schema_t avro_schema_record_field_get(const avro_schema_t
 
45
                                           record, const char *field_name);
 
46
const char *avro_schema_record_field_name(const avro_schema_t schema, int index);
 
47
int avro_schema_record_field_get_index(const avro_schema_t schema,
 
48
                                       const char *field_name);
 
49
avro_schema_t avro_schema_record_field_get_by_index
 
50
(const avro_schema_t record, int index);
 
51
int avro_schema_record_field_append(const avro_schema_t record,
 
52
                                    const char *field_name,
 
53
                                    const avro_schema_t type);
 
54
size_t avro_schema_record_size(const avro_schema_t record);
 
55
 
 
56
avro_schema_t avro_schema_enum(const char *name);
 
57
const char *avro_schema_enum_get(const avro_schema_t enump,
 
58
                                 int index);
 
59
int avro_schema_enum_get_by_name(const avro_schema_t enump,
 
60
                                 const char *symbol_name);
 
61
int avro_schema_enum_symbol_append(const avro_schema_t
 
62
                                   enump, const char *symbol);
 
63
 
 
64
avro_schema_t avro_schema_fixed(const char *name, const int64_t len);
 
65
int64_t avro_schema_fixed_size(const avro_schema_t fixed);
 
66
 
 
67
avro_schema_t avro_schema_map(const avro_schema_t values);
 
68
avro_schema_t avro_schema_map_values(avro_schema_t map);
 
69
 
 
70
avro_schema_t avro_schema_array(const avro_schema_t items);
 
71
avro_schema_t avro_schema_array_items(avro_schema_t array);
 
72
 
 
73
avro_schema_t avro_schema_union(void);
 
74
size_t avro_schema_union_size(const avro_schema_t union_schema);
 
75
int avro_schema_union_append(const avro_schema_t
 
76
                             union_schema, const avro_schema_t schema);
 
77
avro_schema_t avro_schema_union_branch(avro_schema_t union_schema,
 
78
                                       int branch_index);
 
79
avro_schema_t avro_schema_union_branch_by_name
 
80
(avro_schema_t union_schema, int *branch_index, const char *name);
 
81
 
 
82
avro_schema_t avro_schema_link(avro_schema_t schema);
 
83
avro_schema_t avro_schema_link_target(avro_schema_t schema);
 
84
 
 
85
typedef struct avro_schema_error_t_ *avro_schema_error_t;
 
86
 
 
87
int avro_schema_from_json(const char *jsontext, int32_t unused1,
 
88
                          avro_schema_t *schema, avro_schema_error_t *unused2);
 
89
 
 
90
/* jsontext does not need to be NUL terminated.  length must *NOT*
 
91
 * include the NUL terminator, if one is present. */
 
92
int avro_schema_from_json_length(const char *jsontext, size_t length,
 
93
                                 avro_schema_t *schema);
 
94
 
 
95
/* A helper macro for loading a schema from a string literal.  The
 
96
 * literal must be declared as a char[], not a char *, since we use the
 
97
 * sizeof operator to determine its length. */
 
98
#define avro_schema_from_json_literal(json, schema) \
 
99
    (avro_schema_from_json_length((json), sizeof((json))-1, (schema)))
 
100
 
 
101
int avro_schema_to_specific(avro_schema_t schema, const char *prefix);
 
102
 
 
103
avro_schema_t avro_schema_get_subschema(const avro_schema_t schema,
 
104
         const char *name);
 
105
const char *avro_schema_name(const avro_schema_t schema);
 
106
const char *avro_schema_type_name(const avro_schema_t schema);
 
107
avro_schema_t avro_schema_copy(avro_schema_t schema);
 
108
int avro_schema_equal(avro_schema_t a, avro_schema_t b);
 
109
 
 
110
avro_schema_t avro_schema_incref(avro_schema_t schema);
 
111
int avro_schema_decref(avro_schema_t schema);
 
112
 
 
113
int avro_schema_match(avro_schema_t writers_schema,
 
114
                      avro_schema_t readers_schema);
 
115
 
 
116
CLOSE_EXTERN
 
117
#endif