summaryrefslogtreecommitdiff
path: root/source/kit/input_stream.h
blob: 213d2cad2c2f838ea2d8279cf0c0dff50e6484f1 (plain)
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
#ifndef KIT_INPUT_STREAM_H
#define KIT_INPUT_STREAM_H

#include "allocator.h"
#include "string_ref.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef ptrdiff_t (*kit_is_read_fn)(void         *state,
                                    kit_out_str_t destination);

typedef struct {
  void          *state;
  kit_is_read_fn read;
} kit_is_handle_t;

kit_is_handle_t kit_is_wrap_string(kit_str_t       string,
                                   kit_allocator_t alloc);

void kit_is_destroy(kit_is_handle_t in);

#define KIT_IS_WRAP_STRING(string) \
  kit_is_wrap_string((string), kit_alloc_default())

#define KIT_IS_READ(in, destination) \
  (in).read((in).state, (destination))

#ifndef KIT_DISABLE_SHORT_NAMES
#  define is_read_fn kit_is_read_fn
#  define is_handle_t kit_is_handle_t
#  define is_wrap_string kit_is_wrap_string
#  define is_destroy kit_is_destroy

#  define IS_WRAP_STRING KIT_IS_WRAP_STRING
#  define IS_READ KIT_IS_READ
#endif

#ifdef __cplusplus
}
#endif

#endif