1 /*
2  * Copyright 2018 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 struct memiter {
16 	const char *next;
17 	const char *limit;
18 };
19 
20 void memiter_init(struct memiter *it, const void *data, size_t size);
21 bool memiter_parse_uint(struct memiter *it, uint64_t *value);
22 bool memiter_parse_str(struct memiter *it, struct memiter *str);
23 bool memiter_iseq(const struct memiter *it, const char *str);
24 bool memiter_advance(struct memiter *it, size_t v);
25 bool memiter_restrict(struct memiter *it, size_t v);
26 bool memiter_consume(struct memiter *it, size_t v, struct memiter *newit);
27 
28 const void *memiter_base(const struct memiter *it);
29 size_t memiter_size(const struct memiter *it);
30