Kaa client C SDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
encoding.h
Go to the documentation of this file.
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 #ifndef AVRO_ENCODING_H
18 #define AVRO_ENCODING_H
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include "avro/platform.h"
24 #include "avro/io.h"
25 
26 /*
27  * TODO: this will need more functions when JSON encoding is added
28  */
30  const char *description;
31  /*
32  * string
33  */
34  int (*read_string) (avro_reader_t reader, char **s, int64_t *len);
35  int (*write_string) (avro_writer_t writer, const char *s);
36  /*
37  * bytes
38  */
39  int (*read_bytes) (avro_reader_t reader, char **bytes, int64_t * len);
40  int (*write_bytes) (avro_writer_t writer,
41  const char *bytes, const int64_t len);
42  /*
43  * int
44  */
45  int (*read_int) (avro_reader_t reader, int32_t * i);
46  int (*write_int) (avro_writer_t writer, const int32_t i);
47  /*
48  * long
49  */
50  int (*read_long) (avro_reader_t reader, int64_t * l);
51  int (*write_long) (avro_writer_t writer, const int64_t l);
52  /*
53  * float
54  */
55  int (*read_float) (avro_reader_t reader, float *f);
56  int (*write_float) (avro_writer_t writer, const float f);
57  /*
58  * double
59  */
60  int (*read_double) (avro_reader_t reader, double *d);
61  int (*write_double) (avro_writer_t writer, const double d);
62  /*
63  * boolean
64  */
65  int (*read_boolean) (avro_reader_t reader, int8_t * b);
66  int (*write_boolean) (avro_writer_t writer, const int8_t b);
67  /*
68  * null
69  */
70  int (*read_null) (avro_reader_t reader);
71  int (*write_null) (avro_writer_t writer);
72 };
74 
75 #define AVRO_WRITE(writer, buf, len) \
76 { int rval = avro_write( writer, buf, len ); if(rval) return rval; }
77 #define AVRO_READ(reader, buf, len) \
78 { int rval = avro_read( reader, buf, len ); if(rval) return rval; }
79 
80 extern const avro_encoding_t avro_binary_encoding; /* in
81  * encoding_binary
82  */
83 #ifdef __cplusplus
84 } // extern "C"
85 #endif
86 #endif
const char * description
Definition: encoding.h:30
int(* read_bytes)(avro_reader_t reader, char **bytes, int64_t *len)
Definition: encoding.h:39
int(* write_int)(avro_writer_t writer, const int32_t i)
Definition: encoding.h:46
int(* write_double)(avro_writer_t writer, const double d)
Definition: encoding.h:61
int(* read_int)(avro_reader_t reader, int32_t *i)
Definition: encoding.h:45
int(* read_long)(avro_reader_t reader, int64_t *l)
Definition: encoding.h:50
int(* write_string)(avro_writer_t writer, const char *s)
Definition: encoding.h:35
Definition: encoding.h:29
int(* read_double)(avro_reader_t reader, double *d)
Definition: encoding.h:60
int(* write_null)(avro_writer_t writer)
Definition: encoding.h:71
const avro_encoding_t avro_binary_encoding
int(* read_boolean)(avro_reader_t reader, int8_t *b)
Definition: encoding.h:65
Definition: io.h:33
int(* write_bytes)(avro_writer_t writer, const char *bytes, const int64_t len)
Definition: encoding.h:40
int(* read_null)(avro_reader_t reader)
Definition: encoding.h:70
int(* write_float)(avro_writer_t writer, const float f)
Definition: encoding.h:56
int(* write_boolean)(avro_writer_t writer, const int8_t b)
Definition: encoding.h:66
int(* read_float)(avro_reader_t reader, float *f)
Definition: encoding.h:55
Definition: io.h:27
int(* write_long)(avro_writer_t writer, const int64_t l)
Definition: encoding.h:51
int(* read_string)(avro_reader_t reader, char **s, int64_t *len)
Definition: encoding.h:34