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 pathbytes.hpp
More file actions
62 lines (48 loc) · 1.4 KB
/
bytes.hpp
File metadata and controls
62 lines (48 loc) · 1.4 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
55
56
57
58
59
60
61
62
#ifndef LIB_RUBY_PARSER_BYTES_HPP
#define LIB_RUBY_PARSER_BYTES_HPP
#include <cstddef>
#include <cstdint>
namespace lib_ruby_parser
{
/// Representation of a Vec<u8>.
/// `capacity` doesn't matter.
class ByteList
{
public:
char *ptr;
size_t capacity;
size_t len;
ByteList() = delete;
ByteList(char *ptr, size_t len, size_t capacity);
ByteList(const ByteList &) = delete;
ByteList &operator=(ByteList const &) = delete;
ByteList(ByteList &&);
ByteList &operator=(ByteList &&);
~ByteList();
/// Constructs an "owned" version of `ByteList`,
/// takes ownership of the given pointer.
static ByteList Owned(char *s, size_t len);
/// Constructs a `ByteList` by copying given pointer
static ByteList Copied(const char *s, size_t len);
};
extern "C"
{
struct ByteListBlob
{
uint8_t bytes[sizeof(ByteList)];
};
}
/// Rerpresentation of `Bytes` struct from lib-ruby-parser.
class Bytes
{
public:
ByteList raw;
Bytes() = delete;
explicit Bytes(ByteList raw);
Bytes(const Bytes &) = delete;
Bytes &operator=(Bytes const &) = delete;
Bytes(Bytes &&) = default;
Bytes &operator=(Bytes &&) = default;
};
} // namespace lib_ruby_parser
#endif // LIB_RUBY_PARSER_BYTES_HPP