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

« back to all changes in this revision

Viewing changes to src/avro/io.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_IO_H
 
19
#define AVRO_IO_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 <stdio.h>
 
29
 
 
30
#include <avro/basics.h>
 
31
#include <avro/legacy.h>
 
32
#include <avro/schema.h>
 
33
#include <avro/value.h>
 
34
 
 
35
typedef struct avro_reader_t_ *avro_reader_t;
 
36
typedef struct avro_writer_t_ *avro_writer_t;
 
37
 
 
38
/*
 
39
 * io
 
40
 */
 
41
 
 
42
avro_reader_t avro_reader_file(FILE * fp);
 
43
avro_reader_t avro_reader_file_fp(FILE * fp, int should_close);
 
44
avro_writer_t avro_writer_file(FILE * fp);
 
45
avro_writer_t avro_writer_file_fp(FILE * fp, int should_close);
 
46
avro_reader_t avro_reader_memory(const char *buf, int64_t len);
 
47
avro_writer_t avro_writer_memory(const char *buf, int64_t len);
 
48
 
 
49
void
 
50
avro_reader_memory_set_source(avro_reader_t reader, const char *buf, int64_t len);
 
51
 
 
52
void
 
53
avro_writer_memory_set_dest(avro_writer_t writer, const char *buf, int64_t len);
 
54
 
 
55
int avro_read(avro_reader_t reader, void *buf, int64_t len);
 
56
int avro_skip(avro_reader_t reader, int64_t len);
 
57
int avro_write(avro_writer_t writer, void *buf, int64_t len);
 
58
 
 
59
void avro_reader_reset(avro_reader_t reader);
 
60
 
 
61
void avro_writer_reset(avro_writer_t writer);
 
62
int64_t avro_writer_tell(avro_writer_t writer);
 
63
void avro_writer_flush(avro_writer_t writer);
 
64
 
 
65
void avro_writer_dump(avro_writer_t writer, FILE * fp);
 
66
void avro_reader_dump(avro_reader_t reader, FILE * fp);
 
67
 
 
68
int avro_reader_is_eof(avro_reader_t reader);
 
69
 
 
70
void avro_reader_free(avro_reader_t reader);
 
71
void avro_writer_free(avro_writer_t writer);
 
72
 
 
73
int avro_schema_to_json(const avro_schema_t schema, avro_writer_t out);
 
74
 
 
75
/*
 
76
 * Reads a binary-encoded Avro value from the given reader object,
 
77
 * storing the result into dest.
 
78
 */
 
79
 
 
80
int
 
81
avro_value_read(avro_reader_t reader, avro_value_t *dest);
 
82
 
 
83
/*
 
84
 * Writes a binary-encoded Avro value to the given writer object.
 
85
 */
 
86
 
 
87
int
 
88
avro_value_write(avro_writer_t writer, avro_value_t *src);
 
89
 
 
90
/*
 
91
 * Returns the size of the binary encoding of the given Avro value.
 
92
 */
 
93
 
 
94
int
 
95
avro_value_sizeof(avro_value_t *src, size_t *size);
 
96
 
 
97
 
 
98
/* File object container */
 
99
typedef struct avro_file_reader_t_ *avro_file_reader_t;
 
100
typedef struct avro_file_writer_t_ *avro_file_writer_t;
 
101
 
 
102
int avro_file_writer_create(const char *path, avro_schema_t schema,
 
103
                            avro_file_writer_t * writer);
 
104
int avro_file_writer_create_fp(FILE *fp, const char *path, int should_close,
 
105
                                avro_schema_t schema, avro_file_writer_t * writer);
 
106
int avro_file_writer_create_with_codec(const char *path,
 
107
                                avro_schema_t schema, avro_file_writer_t * writer,
 
108
                                const char *codec, size_t block_size);
 
109
int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path, int should_close,
 
110
                                avro_schema_t schema, avro_file_writer_t * writer,
 
111
                                const char *codec, size_t block_size);
 
112
int avro_file_writer_open(const char *path, avro_file_writer_t * writer);
 
113
int avro_file_writer_open_bs(const char *path, avro_file_writer_t * writer, size_t block_size);
 
114
int avro_file_reader(const char *path, avro_file_reader_t * reader);
 
115
int avro_file_reader_fp(FILE *fp, const char *path, int should_close,
 
116
                        avro_file_reader_t * reader);
 
117
 
 
118
avro_schema_t
 
119
avro_file_reader_get_writer_schema(avro_file_reader_t reader);
 
120
 
 
121
int avro_file_writer_sync(avro_file_writer_t writer);
 
122
int avro_file_writer_flush(avro_file_writer_t writer);
 
123
int avro_file_writer_close(avro_file_writer_t writer);
 
124
 
 
125
int avro_file_reader_close(avro_file_reader_t reader);
 
126
 
 
127
int
 
128
avro_file_reader_read_value(avro_file_reader_t reader, avro_value_t *dest);
 
129
 
 
130
int
 
131
avro_file_writer_append_value(avro_file_writer_t writer, avro_value_t *src);
 
132
 
 
133
int
 
134
avro_file_writer_append_encoded(avro_file_writer_t writer,
 
135
                                const void *buf, int64_t len);
 
136
 
 
137
/*
 
138
 * Legacy avro_datum_t API
 
139
 */
 
140
 
 
141
int avro_read_data(avro_reader_t reader,
 
142
                   avro_schema_t writer_schema,
 
143
                   avro_schema_t reader_schema, avro_datum_t * datum);
 
144
int avro_skip_data(avro_reader_t reader, avro_schema_t writer_schema);
 
145
int avro_write_data(avro_writer_t writer,
 
146
                    avro_schema_t writer_schema, avro_datum_t datum);
 
147
int64_t avro_size_data(avro_writer_t writer,
 
148
                       avro_schema_t writer_schema, avro_datum_t datum);
 
149
 
 
150
int avro_file_writer_append(avro_file_writer_t writer, avro_datum_t datum);
 
151
 
 
152
int avro_file_reader_read(avro_file_reader_t reader,
 
153
                          avro_schema_t readers_schema, avro_datum_t * datum);
 
154
 
 
155
CLOSE_EXTERN
 
156
#endif