This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecoder.h
More file actions
54 lines (46 loc) · 1.41 KB
/
decoder.h
File metadata and controls
54 lines (46 loc) · 1.41 KB
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
#ifndef LIB_RUBY_PARSER_DECODER_H
#define LIB_RUBY_PARSER_DECODER_H
#include <stdbool.h>
#include "string.h"
#include "bytes.h"
typedef struct
{
enum
{
LIB_RUBY_PARSER_INPUT_ERROR_UNSUPPORTED_ENCODING,
LIB_RUBY_PARSER_INPUT_ERROR_DECODING_ERROR
} tag;
union
{
LIB_RUBY_PARSER_String unsupported_encoding;
LIB_RUBY_PARSER_String decoding_error;
} as;
} LIB_RUBY_PARSER_InputError;
void LIB_RUBY_PARSER_drop_input_error(LIB_RUBY_PARSER_InputError *input_error);
typedef struct
{
enum
{
LIB_RUBY_PARSER_DECODER_RESULT_OK,
LIB_RUBY_PARSER_DECODER_RESULT_ERR
} tag;
union
{
LIB_RUBY_PARSER_ByteList ok;
LIB_RUBY_PARSER_InputError err;
} as;
} LIB_RUBY_PARSER_DecoderResult;
void LIB_RUBY_PARSER_drop_decoder_result(LIB_RUBY_PARSER_DecoderResult *decoder_result);
typedef LIB_RUBY_PARSER_DecoderResult (*LIB_RUBY_PARSER_Decoder_Function)(void *state, LIB_RUBY_PARSER_String encoding, LIB_RUBY_PARSER_ByteList input);
typedef struct
{
LIB_RUBY_PARSER_Decoder_Function f;
void *state;
} LIB_RUBY_PARSER_Decoder;
typedef struct
{
LIB_RUBY_PARSER_Decoder decoder;
} LIB_RUBY_PARSER_MaybeDecoder;
bool LIB_RUBY_PARSER_maybe_decoder_is_some(const LIB_RUBY_PARSER_MaybeDecoder *maybe_decoder);
bool LIB_RUBY_PARSER_maybe_decoder_is_none(const LIB_RUBY_PARSER_MaybeDecoder *maybe_decoder);
#endif // LIB_RUBY_PARSER_DECODER_H