-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffer.h
More file actions
112 lines (88 loc) · 3.99 KB
/
buffer.h
File metadata and controls
112 lines (88 loc) · 3.99 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (c) 2019, The Vulkan Developers.
//
// This file is part of Vulkan.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// You should have received a copy of the MIT License
// along with Vulkan. If not, see <https://opensource.org/licenses/MIT>.
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "vulkan.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef enum BufferStringTypes
{
BUFFER_STRING8 = 0,
BUFFER_STRING16,
BUFFER_STRING32,
BUFFER_STRING64
} buffer_string_type_t;
typedef struct Buffer
{
uint8_t *data;
size_t size;
size_t offset;
} buffer_t;
buffer_t* buffer_make(void);
buffer_t* buffer_init_data(size_t offset, const uint8_t *data, size_t size);
buffer_t* buffer_init_size(size_t offset, size_t size);
buffer_t* buffer_init_offset(size_t offset);
buffer_t* buffer_init(void);
int buffer_set_data(buffer_t *buffer, const uint8_t *data, size_t size);
uint8_t* buffer_get_data(buffer_t *buffer);
void buffer_set_size(buffer_t *buffer, size_t size);
size_t buffer_get_size(buffer_t *buffer);
void buffer_set_offset(buffer_t *buffer, size_t offset);
size_t buffer_get_offset(buffer_t *buffer);
int buffer_copy(buffer_t *buffer, buffer_t *other_buffer);
int buffer_compare(buffer_t *buffer, buffer_t *other_buffer);
void buffer_clear(buffer_t *buffer);
void buffer_free(buffer_t *buffer);
int buffer_resize(buffer_t *buffer, size_t size);
int buffer_write(buffer_t *buffer, const uint8_t *data, size_t size);
int buffer_pad_data(buffer_t *buffer, size_t size);
int buffer_write_uint8(buffer_t *buffer, uint8_t value);
int buffer_write_int8(buffer_t *buffer, int8_t value);
int buffer_write_uint16(buffer_t *buffer, uint16_t value);
int buffer_write_int16(buffer_t *buffer, int16_t value);
int buffer_write_uint32(buffer_t *buffer, uint32_t value);
int buffer_write_int32(buffer_t *buffer, int32_t value);
int buffer_write_uint64(buffer_t *buffer, uint64_t value);
int buffer_write_int64(buffer_t *buffer, int64_t value);
int buffer_write_bytes8(buffer_t *buffer, const uint8_t *bytes, uint8_t size);
int buffer_write_string8(buffer_t *buffer, const char *string, uint8_t size);
int buffer_write_bytes16(buffer_t *buffer, const uint8_t *bytes, uint16_t size);
int buffer_write_string16(buffer_t *buffer, const char *string, uint16_t size);
int buffer_write_bytes32(buffer_t *buffer, const uint8_t *bytes, uint32_t size);
int buffer_write_string32(buffer_t *buffer, const char *string, uint32_t size);
int buffer_write_bytes64(buffer_t *buffer, const uint8_t *bytes, uint64_t size);
int buffer_write_string64(buffer_t *buffer, const char *string, uint64_t size);
int buffer_write_bytes(buffer_t *buffer, const uint8_t *bytes, size_t size);
int buffer_write_string(buffer_t *buffer, const char *string, size_t size);
int buffer_write_padded_bytes(buffer_t *buffer, const uint8_t *bytes, size_t size, size_t padded_size);
int buffer_write_padded_string(buffer_t *buffer, const char *string, size_t size, size_t padded_size);
#ifdef __cplusplus
}
#endif