1- // Copyright © 2025 GlacieTeam. All rights reserved.
2- //
3- // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
4- // distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5- //
6- // SPDX-License-Identifier: MPL-2.0
7-
8- #pragma once
9- #include <binarystream-c/Macros.h>
10- #include <stddef.h>
11- #include <stdint.h>
12-
13- #ifdef __cplusplus
14- extern "C" {
15- #endif
16-
17- struct stream_buffer {
18- uint8_t * data ;
19- size_t size ;
20- };
21- BSAPI void stream_buffer_destroy (stream_buffer * buffer );
22-
23- BSAPI void * read_only_binary_stream_create (const uint8_t * data , size_t size , bool copy_data , bool big_endian );
24- BSAPI void read_only_binary_stream_destroy (void * stream );
25-
26- BSAPI size_t read_only_binary_stream_size (void * stream );
27- BSAPI size_t read_only_binary_stream_get_position (void * stream );
28- BSAPI void read_only_binary_stream_set_position (void * stream , size_t position );
29- BSAPI void read_only_binary_stream_reset_position (void * stream );
30- BSAPI bool read_only_binary_stream_overflowed (void * stream );
31- BSAPI bool read_only_binary_stream_has_data_left (void * stream );
32-
33- BSAPI stream_buffer read_only_binary_stream_get_left_buffer (void * stream );
34-
35- BSAPI void read_only_binary_stream_ignore_bytes (void * stream , size_t length );
36-
37- BSAPI size_t read_only_binary_stream_get_bytes (void * stream , uint8_t * buffer , size_t buffer_size );
38- BSAPI bool read_only_binary_stream_get_bool (void * stream );
39- BSAPI uint8_t read_only_binary_stream_get_unsigned_char (void * stream );
40- BSAPI uint16_t read_only_binary_stream_get_unsigned_short (void * stream );
41- BSAPI int16_t read_only_binary_stream_get_signed_short (void * stream );
42- BSAPI uint32_t read_only_binary_stream_get_unsigned_int24 (void * stream );
43- BSAPI uint32_t read_only_binary_stream_get_unsigned_int (void * stream );
44- BSAPI int32_t read_only_binary_stream_get_signed_int (void * stream );
45- BSAPI uint64_t read_only_binary_stream_get_unsigned_int64 (void * stream );
46- BSAPI int64_t read_only_binary_stream_get_signed_int64 (void * stream );
47- BSAPI float read_only_binary_stream_get_float (void * stream );
48- BSAPI double read_only_binary_stream_get_double (void * stream );
49- BSAPI uint32_t read_only_binary_stream_get_unsigned_varint (void * stream );
50- BSAPI int32_t read_only_binary_stream_get_varint (void * stream );
51- BSAPI uint64_t read_only_binary_stream_get_unsigned_varint64 (void * stream );
52- BSAPI int64_t read_only_binary_stream_get_varint64 (void * stream );
53- BSAPI int32_t read_only_binary_stream_get_signed_big_endian_int (void * stream );
54-
55- BSAPI stream_buffer read_only_binary_stream_get_string (void * stream );
56-
57- BSAPI size_t read_only_binary_stream_get_raw_bytes (void * stream , uint8_t * buffer , size_t length );
58-
59- #ifdef __cplusplus
60- }
1+ // Copyright © 2025 GlacieTeam. All rights reserved.
2+ //
3+ // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
4+ // distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5+ //
6+ // SPDX-License-Identifier: MPL-2.0
7+
8+ #pragma once
9+ #include <binarystream-c/Macros.h>
10+ #include <stddef.h>
11+ #include <stdint.h>
12+
13+ #ifdef __cplusplus
14+ extern "C" {
15+ #endif
16+
17+ struct stream_buffer {
18+ uint8_t * data ;
19+ size_t size ;
20+ };
21+ BSAPI void stream_buffer_destroy (stream_buffer * buffer );
22+
23+ // ReadOnlyBinaryStream
24+ BSAPI void * read_only_binary_stream_create (const uint8_t * data , size_t size , bool copy_data , bool big_endian );
25+ BSAPI void read_only_binary_stream_destroy (void * stream );
26+
27+ BSAPI size_t read_only_binary_stream_size (void * stream );
28+ BSAPI size_t read_only_binary_stream_get_position (void * stream );
29+ BSAPI void read_only_binary_stream_set_position (void * stream , size_t position );
30+ BSAPI void read_only_binary_stream_reset_position (void * stream );
31+ BSAPI bool read_only_binary_stream_overflowed (void * stream );
32+ BSAPI bool read_only_binary_stream_has_data_left (void * stream );
33+
34+ BSAPI stream_buffer * read_only_binary_stream_get_left_buffer (void * stream );
35+
36+ BSAPI void read_only_binary_stream_ignore_bytes (void * stream , size_t length );
37+
38+ BSAPI size_t read_only_binary_stream_get_bytes (void * stream , uint8_t * buffer , size_t buffer_size );
39+ BSAPI bool read_only_binary_stream_get_bool (void * stream );
40+ BSAPI uint8_t read_only_binary_stream_get_unsigned_char (void * stream );
41+ BSAPI uint16_t read_only_binary_stream_get_unsigned_short (void * stream );
42+ BSAPI int16_t read_only_binary_stream_get_signed_short (void * stream );
43+ BSAPI uint32_t read_only_binary_stream_get_unsigned_int24 (void * stream );
44+ BSAPI uint32_t read_only_binary_stream_get_unsigned_int (void * stream );
45+ BSAPI int32_t read_only_binary_stream_get_signed_int (void * stream );
46+ BSAPI uint64_t read_only_binary_stream_get_unsigned_int64 (void * stream );
47+ BSAPI int64_t read_only_binary_stream_get_signed_int64 (void * stream );
48+ BSAPI float read_only_binary_stream_get_float (void * stream );
49+ BSAPI double read_only_binary_stream_get_double (void * stream );
50+ BSAPI uint32_t read_only_binary_stream_get_unsigned_varint (void * stream );
51+ BSAPI int32_t read_only_binary_stream_get_varint (void * stream );
52+ BSAPI uint64_t read_only_binary_stream_get_unsigned_varint64 (void * stream );
53+ BSAPI int64_t read_only_binary_stream_get_varint64 (void * stream );
54+ BSAPI int32_t read_only_binary_stream_get_signed_big_endian_int (void * stream );
55+
56+ BSAPI stream_buffer * read_only_binary_stream_get_string (void * stream );
57+
58+ BSAPI size_t read_only_binary_stream_get_raw_bytes (void * stream , uint8_t * buffer , size_t length );
59+
60+
61+ // BinaryStream
62+ // C++ class BinaryStream : public ReadOnlyBinaryStream
63+ // BinaryStream handle can use functions in ReadOnlyBinaryStream
64+ BSAPI void * binary_stream_create (bool big_endian );
65+ BSAPI void * binary_stream_create_with_buffer (const uint8_t * data , size_t size , bool copy_data , bool big_endian );
66+ BSAPI void binary_stream_destroy (void * stream );
67+ BSAPI void binary_stream_reset (void * stream );
68+
69+ BSAPI void binary_stream_write_bytes (void * stream , const uint8_t * data , size_t size );
70+ BSAPI void binary_stream_write_bool (void * stream , bool value );
71+ BSAPI void binary_stream_write_unsigned_char (void * stream , uint8_t value );
72+ BSAPI void binary_stream_write_unsigned_short (void * stream , uint16_t value );
73+ BSAPI void binary_stream_write_signed_short (void * stream , int16_t value );
74+ BSAPI void binary_stream_write_unsigned_int24 (void * stream , uint32_t value );
75+ BSAPI void binary_stream_write_unsigned_int (void * stream , uint32_t value );
76+ BSAPI void binary_stream_write_signed_int (void * stream , int32_t value );
77+ BSAPI void binary_stream_write_unsigned_int64 (void * stream , uint64_t value );
78+ BSAPI void binary_stream_write_signed_int64 (void * stream , int64_t value );
79+ BSAPI void binary_stream_write_float (void * stream , float value );
80+ BSAPI void binary_stream_write_double (void * stream , double value );
81+ BSAPI void binary_stream_write_unsigned_varint (void * stream , uint32_t value );
82+ BSAPI void binary_stream_write_varint (void * stream , int32_t value );
83+ BSAPI void binary_stream_write_unsigned_varint64 (void * stream , uint64_t value );
84+ BSAPI void binary_stream_write_varint64 (void * stream , int64_t value );
85+ BSAPI void binary_stream_write_string (void * stream , const char * str , size_t length );
86+ BSAPI void binary_stream_write_signed_big_endian_int (void * stream , int32_t value );
87+
88+ BSAPI stream_buffer * binary_stream_get_buffer (void * stream );
89+
90+ #ifdef __cplusplus
91+ }
6192#endif
0 commit comments