1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#pragma once
#include <library/cpp/yson_pull/cyson_enums.h>
#include <util/system/types.h>
#include <stddef.h>
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct yson_string {
const char* ptr;
size_t length;
} yson_string;
typedef yson_input_stream_result (*yson_input_stream_func)(
void* ctx,
const char** ptr,
size_t* length);
typedef yson_output_stream_result (*yson_output_stream_func)(
void* ctx,
const char* ptr,
size_t length);
/* Abstract types */
typedef struct yson_input_stream yson_input_stream;
typedef struct yson_output_stream yson_output_stream;
typedef struct yson_reader yson_reader;
typedef struct yson_writer yson_writer;
/* Input stream */
yson_input_stream*
yson_input_stream_from_string(const char* ptr, size_t length);
yson_input_stream*
yson_input_stream_from_file(FILE* file, size_t buffer_size);
yson_input_stream*
yson_input_stream_from_fd(int fd, size_t buffer_size);
yson_input_stream*
yson_input_stream_new(void* ctx, yson_input_stream_func callback);
void yson_input_stream_delete(yson_input_stream* stream);
/* Output stream */
yson_output_stream*
yson_output_stream_from_file(FILE* file, size_t buffer_size);
yson_output_stream*
yson_output_stream_from_fd(int fd, size_t buffer_size);
yson_output_stream*
yson_output_stream_new(void* ctx, yson_output_stream_func callback, size_t buffer_size);
void yson_output_stream_delete(yson_output_stream* stream);
/* Reader */
yson_reader*
yson_reader_new(yson_input_stream* stream, yson_stream_type mode);
void yson_reader_delete(yson_reader* reader);
yson_event_type
yson_reader_get_next_event(yson_reader* reader);
const char*
yson_reader_get_error_message(yson_reader* reader);
yson_scalar_type
yson_reader_get_scalar_type(yson_reader* reader);
int yson_reader_get_boolean(yson_reader* reader);
i64 yson_reader_get_int64(yson_reader* reader);
ui64 yson_reader_get_uint64(yson_reader* reader);
double
yson_reader_get_float64(yson_reader* reader);
const yson_string*
yson_reader_get_string(yson_reader* reader);
/* Writer */
yson_writer*
yson_writer_new_binary(
yson_output_stream* stream,
yson_stream_type mode);
yson_writer*
yson_writer_new_text(
yson_output_stream* stream,
yson_stream_type mode);
yson_writer*
yson_writer_new_pretty_text(
yson_output_stream* stream,
yson_stream_type mode,
size_t indent);
void yson_writer_delete(yson_writer* writer);
const char*
yson_writer_get_error_message(yson_writer* writer);
yson_writer_result
yson_writer_write_begin_stream(yson_writer* writer);
yson_writer_result
yson_writer_write_end_stream(yson_writer* writer);
yson_writer_result
yson_writer_write_begin_list(yson_writer* writer);
yson_writer_result
yson_writer_write_end_list(yson_writer* writer);
yson_writer_result
yson_writer_write_begin_map(yson_writer* writer);
yson_writer_result
yson_writer_write_end_map(yson_writer* writer);
yson_writer_result
yson_writer_write_begin_attributes(yson_writer* writer);
yson_writer_result
yson_writer_write_end_attributes(yson_writer* writer);
yson_writer_result
yson_writer_write_entity(yson_writer* writer);
yson_writer_result
yson_writer_write_key(yson_writer* writer, const char* ptr, size_t length);
yson_writer_result
yson_writer_write_string(yson_writer* writer, const char* ptr, size_t length);
yson_writer_result
yson_writer_write_int64(yson_writer* writer, i64 value);
yson_writer_result
yson_writer_write_uint64(yson_writer* writer, ui64 value);
yson_writer_result
yson_writer_write_boolean(yson_writer* writer, int value);
yson_writer_result
yson_writer_write_float64(yson_writer* writer, double value);
#ifdef __cplusplus
} /* extern "C" */
#endif
|