BSB Developer Docs
Loading...
Searching...
No Matches
slice.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <stddef.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
16typedef struct {
17 const char* first_char;
18 size_t length;
20
26typedef struct {
27 size_t start;
28 size_t end;
30
36void string_slice_reset(StringSlice* instance);
37
46 const StringSlice* instance,
47 StringSliceOffset* offset,
48 const char* source);
49
58 StringSlice* instance,
59 const StringSliceOffset* offset,
60 const char* source);
61
71char* string_slice_to_owned_cstr(const StringSlice* instance);
72
73#ifdef __cplusplus
74}
75#endif
void string_slice_from_offset(StringSlice *instance, const StringSliceOffset *offset, const char *source)
Build a string slice from the source string and offsets.
Definition slice.c:29
void string_slice_to_offset(const StringSlice *instance, StringSliceOffset *offset, const char *source)
Get the offsets from a string slice.
Definition slice.c:11
void string_slice_reset(StringSlice *instance)
Reset the slice so that it represents a valid empty string.
Definition slice.c:5
char * string_slice_to_owned_cstr(const StringSlice *instance)
Copy the slice to a zero-terminated owned string.
Definition slice.c:45
Slice of a character string.
Definition slice.h:16
size_t length
Slice length, in bytes.
Definition slice.h:18
const char * first_char
The beginning of the slice.
Definition slice.h:17
Offsets in a string slice.
Definition slice.h:26
size_t start
Offset of the slice's beginning
Definition slice.h:27
size_t end
Offset of the slice's end.
Definition slice.h:28