Debian Codegraph @

include/prism/util/pm_buffer.h

raw symbols SCIP
1 /**
2 * @file pm_buffer.h
3 *
4 * A wrapper around a contiguous block of allocated memory.
5 */
6 #ifndef PRISM_BUFFER_H
7 #define PRISM_BUFFER_Hcxx . . $ `include/prism/util/pm_buffer.h:7:9`!
8
9 #include "prism/defines.h"cxx . . $ `<file>/include/prism/defines.h`/
10 #include "prism/util/pm_char.h"cxx . . $ `<file>/include/prism/util/pm_char.h`/
11
12 #include <assert.h>
13 #include <stdbool.h>
14 #include <stdint.h>
15 #include <stdlib.h>
16 #include <string.h>
17
18 /**
19 * A pm_buffer_t is a simple memory buffer that stores data in a contiguous
20 * block of memory.
21 */
22 typedef structcxx . . $ $anonymous_type_69b4b322e06d2335_0# {
23 /** The length of the buffer in bytes. */
24 size_t lengthcxx . . $ $anonymous_type_69b4b322e06d2335_0#length.;
25
26 /** The capacity of the buffer in bytes that has been allocated. */
27 size_t capacitycxx . . $ $anonymous_type_69b4b322e06d2335_0#capacity.;
28
29 /** A pointer to the start of the buffer. */
30 char *valuecxx . . $ $anonymous_type_69b4b322e06d2335_0#value.;
31 } pm_buffer_tcxx . . $ pm_buffer_t#;
32
33 /**
34 * Return the size of the pm_buffer_t struct.
35 *
36 * @returns The size of the pm_buffer_t struct.
37 */
38 PRISM_EXPORTED_FUNCTIONcxx . . $ `include/prism/defines.h:50:19`! size_t pm_buffer_sizeofcxx . . $ pm_buffer_sizeof(f708dce9a8856c70).(void);
39
40 /**
41 * Initialize a pm_buffer_t with the given capacity.
42 *
43 * @param buffer The buffer to initialize.
44 * @param capacity The capacity of the buffer.
45 * @returns True if the buffer was initialized successfully, false otherwise.
46 */
47 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! pm_buffer_init_capacitycxx . . $ pm_buffer_init_capacity(1a2ef55efe309119).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, size_t capacity);
48
49 /**
50 * Initialize a pm_buffer_t with its default values.
51 *
52 * @param buffer The buffer to initialize.
53 * @returns True if the buffer was initialized successfully, false otherwise.
54 *
55 * \public \memberof pm_buffer_t
56 */
57 PRISM_EXPORTED_FUNCTIONcxx . . $ `include/prism/defines.h:50:19`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! pm_buffer_initcxx . . $ pm_buffer_init(8fa664c130f95cdd).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
58
59 /**
60 * Return the value of the buffer.
61 *
62 * @param buffer The buffer to get the value of.
63 * @returns The value of the buffer.
64 *
65 * \public \memberof pm_buffer_t
66 */
67 PRISM_EXPORTED_FUNCTIONcxx . . $ `include/prism/defines.h:50:19`! char * pm_buffer_valuecxx . . $ pm_buffer_value(25a2ba5d26423c10).(const pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
68
69 /**
70 * Return the length of the buffer.
71 *
72 * @param buffer The buffer to get the length of.
73 * @returns The length of the buffer.
74 *
75 * \public \memberof pm_buffer_t
76 */
77 PRISM_EXPORTED_FUNCTIONcxx . . $ `include/prism/defines.h:50:19`! size_t pm_buffer_lengthcxx . . $ pm_buffer_length(ca208804fbc970c8).(const pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
78
79 /**
80 * Append the given amount of space as zeroes to the buffer.
81 *
82 * @param buffer The buffer to append to.
83 * @param length The amount of space to append and zero.
84 */
85 void pm_buffer_append_zeroescxx . . $ pm_buffer_append_zeroes(46c807d3e55edcf2).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, size_t length);
86
87 /**
88 * Append a formatted string to the buffer.
89 *
90 * @param buffer The buffer to append to.
91 * @param format The format string to append.
92 * @param ... The arguments to the format string.
93 */
94 void pm_buffer_append_formatcxx . . $ pm_buffer_append_format(35b6008a4dc68e20).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const char *format, ...) PRISM_ATTRIBUTE_FORMATcxx . . $ `include/prism/defines.h:67:16`!(2, 3);
95
96 /**
97 * Append a string to the buffer.
98 *
99 * @param buffer The buffer to append to.
100 * @param value The string to append.
101 * @param length The length of the string to append.
102 */
103 void pm_buffer_append_stringcxx . . $ pm_buffer_append_string(c8459e7237ed13a2).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const char *value, size_t length);
104
105 /**
106 * Append a list of bytes to the buffer.
107 *
108 * @param buffer The buffer to append to.
109 * @param value The bytes to append.
110 * @param length The length of the bytes to append.
111 */
112 void pm_buffer_append_bytescxx . . $ pm_buffer_append_bytes(c708007df6f90224).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const uint8_tcxx . . $ uint8_t# *value, size_t length);
113
114 /**
115 * Append a single byte to the buffer.
116 *
117 * @param buffer The buffer to append to.
118 * @param value The byte to append.
119 */
120 void pm_buffer_append_bytecxx . . $ pm_buffer_append_byte(55d7ca91f770de1b).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, uint8_tcxx . . $ uint8_t# value);
121
122 /**
123 * Append a 32-bit unsigned integer to the buffer as a variable-length integer.
124 *
125 * @param buffer The buffer to append to.
126 * @param value The integer to append.
127 */
128 void pm_buffer_append_varuintcxx . . $ pm_buffer_append_varuint(fc41686c2c0ac3dd).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, uint32_tcxx . . $ uint32_t# value);
129
130 /**
131 * Append a 32-bit signed integer to the buffer as a variable-length integer.
132 *
133 * @param buffer The buffer to append to.
134 * @param value The integer to append.
135 */
136 void pm_buffer_append_varsintcxx . . $ pm_buffer_append_varsint(b81f42764d96001d).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, int32_tcxx . . $ int32_t# value);
137
138 /**
139 * Append a double to the buffer.
140 *
141 * @param buffer The buffer to append to.
142 * @param value The double to append.
143 */
144 void pm_buffer_append_doublecxx . . $ pm_buffer_append_double(fe7600e1c2be42e6).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, double value);
145
146 /**
147 * Append a unicode codepoint to the buffer.
148 *
149 * @param buffer The buffer to append to.
150 * @param value The character to append.
151 * @returns True if the codepoint was valid and appended successfully, false
152 * otherwise.
153 */
154 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! pm_buffer_append_unicode_codepointcxx . . $ pm_buffer_append_unicode_codepoint(8934a4ab6c61afbc).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, uint32_tcxx . . $ uint32_t# value);
155
156 /**
157 * The different types of escaping that can be performed by the buffer when
158 * appending a slice of Ruby source code.
159 */
160 typedef enumcxx . . $ $anonymous_type_69b4b322e06d2335_1# {
161 PM_BUFFER_ESCAPING_RUBYcxx . . $ PM_BUFFER_ESCAPING_RUBY.,
162 PM_BUFFER_ESCAPING_JSONcxx . . $ PM_BUFFER_ESCAPING_JSON.
163 } pm_buffer_escaping_tcxx . . $ pm_buffer_escaping_t#;
164
165 /**
166 * Append a slice of source code to the buffer.
167 *
168 * @param buffer The buffer to append to.
169 * @param source The source code to append.
170 * @param length The length of the source code to append.
171 * @param escaping The type of escaping to perform.
172 */
173 void pm_buffer_append_sourcecxx . . $ pm_buffer_append_source(8150e178a152d1cc).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const uint8_tcxx . . $ uint8_t# *source, size_t length, pm_buffer_escaping_tcxx . . $ pm_buffer_escaping_t# escaping);
174
175 /**
176 * Prepend the given string to the buffer.
177 *
178 * @param buffer The buffer to prepend to.
179 * @param value The string to prepend.
180 * @param length The length of the string to prepend.
181 */
182 void pm_buffer_prepend_stringcxx . . $ pm_buffer_prepend_string(c8459e7237ed13a2).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const char *value, size_t length);
183
184 /**
185 * Concatenate one buffer onto another.
186 *
187 * @param destination The buffer to concatenate onto.
188 * @param source The buffer to concatenate.
189 */
190 void pm_buffer_concatcxx . . $ pm_buffer_concat(81b29c7c73814310).(pm_buffer_tcxx . . $ pm_buffer_t# *destination, const pm_buffer_tcxx . . $ pm_buffer_t# *source);
191
192 /**
193 * Clear the buffer by reducing its size to 0. This does not free the allocated
194 * memory, but it does allow the buffer to be reused.
195 *
196 * @param buffer The buffer to clear.
197 */
198 void pm_buffer_clearcxx . . $ pm_buffer_clear(3b0ae34314d6dc9f).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
199
200 /**
201 * Strip the whitespace from the end of the buffer.
202 *
203 * @param buffer The buffer to strip.
204 */
205 void pm_buffer_rstripcxx . . $ pm_buffer_rstrip(3b0ae34314d6dc9f).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
206
207 /**
208 * Checks if the buffer includes the given value.
209 *
210 * @param buffer The buffer to check.
211 * @param value The value to check for.
212 * @returns The index of the first occurrence of the value in the buffer, or
213 * SIZE_MAX if the value is not found.
214 */
215 size_t pm_buffer_indexcxx . . $ pm_buffer_index(44ef8fde7718cd5e).(const pm_buffer_tcxx . . $ pm_buffer_t# *buffer, char value);
216
217 /**
218 * Insert the given string into the buffer at the given index.
219 *
220 * @param buffer The buffer to insert into.
221 * @param index The index to insert at.
222 * @param value The string to insert.
223 * @param length The length of the string to insert.
224 */
225 void pm_buffer_insertcxx . . $ pm_buffer_insert(5ca98b04945ec8ca).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, size_t index, const char *value, size_t length);
226
227 /**
228 * Free the memory associated with the buffer.
229 *
230 * @param buffer The buffer to free.
231 *
232 * \public \memberof pm_buffer_t
233 */
234 PRISM_EXPORTED_FUNCTIONcxx . . $ `include/prism/defines.h:50:19`! void pm_buffer_freecxx . . $ pm_buffer_free(3b0ae34314d6dc9f).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer);
235
236 #endif