summaryrefslogtreecommitdiff
path: root/source/kit/input_stream.h
blob: c59a7200ba3e7c314cb22863d5ef55b70af3784b (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
#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 (*is_read_fn)(void *state, out_str destination);

struct is_handle {
  void      *state;
  is_read_fn read;
};

struct is_handle is_wrap_string(cstr                 string,
                                struct kit_allocator alloc);

void is_destroy(struct is_handle in);

#define IS_WRAP_STRING(string) \
  is_wrap_string((string), kit_alloc_default())

#define IS_READ(in, destination) (in).read((in).state, (destination))

#ifdef __cplusplus
}
#endif

#endif