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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/// Dynamically sized UTF-8 encoded byte string.
typedef struct NSTDString;
/// Represents an optional value of type `NSTDString`.
NSTDOptional NSTDOptionalString;
/// Creates a new instance of `NSTDString`.
///
/// # Parameters:
///
/// - `const NSTDAllocator *allocator` - The memory allocator.
///
/// # Returns
///
/// `NSTDString string` - The new string.
NSTDAPI NSTDString ;
/// Creates a new string initialized with the given capacity.
///
/// # Parameters:
///
/// - `const NSTDAllocator *allocator` - The memory allocator.
///
/// - `NSTDUInt cap` - The number of bytes to allocate ahead of time.
///
/// # Returns
///
/// `NSTDOptionalString string` - The new string on success, or an uninitialized "none" variant if
/// allocating fails.
NSTDAPI NSTDOptionalString ;
/// Creates an owned version of an unowned string slice.
///
/// # Parameters:
///
/// - `const NSTDAllocator *allocator` - The memory allocator.
///
/// - `const NSTDStr *str` - The unowned string slice.
///
/// # Returns
///
/// `NSTDOptionalString string` - The new owned version of `str` on success, or an uninitialized
/// "none" variant if allocating fails.
///
/// # Safety
///
/// The caller of this function must ensure that `str`'s data is valid for reads.
NSTDAPI NSTDOptionalString ;
/// Creates a new string from owned UTF-8 data.
///
/// # Parameters:
///
/// - `NSTDVec bytes` - The owned UTF-8 encoded buffer to take ownership of.
///
/// # Returns
///
/// `NSTDOptionalString string` - The new UTF-8 encoded string with ownership of `bytes` on success
/// or an uninitialized "none" variant if `bytes` contains invalid UTF-8.
///
/// # Panics
///
/// This operation will panic if `bytes`'s stride is not 1.
NSTDAPI NSTDOptionalString ;
/// Creates a deep copy of a string.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string to create a deep copy of.
///
/// # Returns
///
/// `NSTDOptionalString cloned` - A new deep copy of `string` on success, or an uninitialized
/// "none" variant if allocating fails.
NSTDAPI NSTDOptionalString ;
/// Returns an immutable reference to a string's allocator.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `const NSTDAllocator *allocator` - The string's allocator.
NSTDAPI const NSTDAllocator *;
/// Creates a string slice containing the contents of `string`.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDStr str` - The new string slice.
NSTDAPI NSTDStr ;
/// Creates a string slice containing the contents of `string`.
///
/// # Parameters:
///
/// - `NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDStrMut str` - The new string slice.
NSTDAPI NSTDStrMut ;
/// Returns an immutable byte slice of the string's active data.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDSlice bytes` - The string's active data.
NSTDAPI NSTDSlice ;
/// Returns a raw pointer to a string's memory.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `const NSTDByte *ptr` - A raw pointer to a string's memory.
NSTDAPI const NSTDByte *;
/// Returns ownership of an `NSTDString`'s raw data, taking ownership of said string.
///
/// # Parameters:
///
/// - `NSTDString string` - The string.
///
/// # Returns
///
/// `NSTDVec bytes` - The string's raw data.
NSTDAPI NSTDVec ;
/// Returns the number of Unicode characters in a string.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDUInt len` - The length of the string.
NSTDAPI NSTDUInt ;
/// Returns the number of bytes a string contains.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDUInt byte_len` - The number of bytes in the string.
NSTDAPI NSTDUInt ;
/// Returns a string's capacity.
///
/// This is the max number of *bytes* the string can contain without reallocating.
///
/// # Parameters:
///
/// - `const NSTDString *string` - The string.
///
/// # Returns
///
/// `NSTDUInt cap` - The string's capacity.
NSTDAPI NSTDUInt ;
/// Pushes an `NSTDUnichar` onto the end of a string.
///
/// # Parameters:
///
/// - `NSTDString *string` - The string to append the character to.
///
/// - `NSTDUnichar chr` - The Unicode character to append to the string.
///
/// # Returns
///
/// `NSTDAllocError errc` - The allocation operation error code.
NSTDAPI NSTDAllocError ;
/// Appends a string slice to the end of a string.
///
/// # Parameters:
///
/// - `NSTDString *string` - The string.
///
/// - `const NSTDStr *str` - The string slice to append to the end of `string`.
///
/// # Returns
///
/// `NSTDAllocError errc` - The allocation operation error code.
///
/// # Safety
///
/// This function will cause undefined behavior in the case where `str`'s data is no longer valid.
NSTDAPI NSTDAllocError ;
/// Removes the last character from a string and returns it.
///
/// # Parameters:
///
/// - `NSTDString *string` - The string to pop.
///
/// # Returns
///
/// `NSTDOptionalUnichar chr` - The removed character on success.
NSTDAPI NSTDOptionalUnichar ;
/// Sets a string's length to zero.
///
/// # Parameters:
///
/// - `NSTDString *string` - The string to clear.
NSTDAPI void ;
/// Creates a new `NSTDString` from an `NSTDFloat32`.
///
/// # Parameters:
///
/// - `NSTDFloat32 v` - The 32-bit floating-point value.
///
/// # Returns
///
/// `NSTDString string` - The 32-bit floating-point value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDFloat64`.
///
/// # Parameters:
///
/// - `NSTDFloat64 v` - The 64-bit floating-point value.
///
/// # Returns
///
/// `NSTDString string` - The 64-bit floating-point value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDInt`.
///
/// # Parameters:
///
/// - `NSTDInt v` - The arch-bit signed integer value.
///
/// # Returns
///
/// `NSTDString string` - The arch-bit signed integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDUInt`.
///
/// # Parameters:
///
/// - `NSTDUInt v` - The arch-bit unsigned integer value.
///
/// # Returns
///
/// `NSTDString string` - The arch-bit unsigned integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDInt8`.
///
/// # Parameters:
///
/// - `NSTDInt8 v` - The 8-bit signed integer value.
///
/// # Returns
///
/// `NSTDString string` - The 8-bit signed integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDUInt8`.
///
/// # Parameters:
///
/// - `NSTDUInt8 v` - The 8-bit unsigned integer value.
///
/// # Returns
///
/// `NSTDString string` - The 8-bit unsigned integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDInt16`.
///
/// # Parameters:
///
/// - `NSTDInt16 v` - The 16-bit signed integer value.
///
/// # Returns
///
/// `NSTDString string` - The 16-bit signed integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDUInt16`.
///
/// # Parameters:
///
/// - `NSTDUInt16 v` - The 16-bit unsigned integer value.
///
/// # Returns
///
/// `NSTDString string` - The 16-bit unsigned integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDInt32`.
///
/// # Parameters:
///
/// - `NSTDInt32 v` - The 32-bit signed integer value.
///
/// # Returns
///
/// `NSTDString string` - The 32-bit signed integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDUInt32`.
///
/// # Parameters:
///
/// - `NSTDUInt32 v` - The 32-bit unsigned integer value.
///
/// # Returns
///
/// `NSTDString string` - The 32-bit unsigned integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDInt64`.
///
/// # Parameters:
///
/// - `NSTDInt64 v` - The 64-bit signed integer value.
///
/// # Returns
///
/// `NSTDString string` - The 64-bit signed integer value as a string.
NSTDAPI NSTDString ;
/// Creates a new `NSTDString` from an `NSTDUInt64`.
///
/// # Parameters:
///
/// - `NSTDUInt64 v` - The 64-bit unsigned integer value.
///
/// # Returns
///
/// `NSTDString string` - The 64-bit unsigned integer value as a string.
NSTDAPI NSTDString ;
/// Frees an instance of `NSTDString`.
///
/// # Parameters:
///
/// - `NSTDString string` - The string to free.
NSTDAPI void ;