Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memdebug
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.conv
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.utf8
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.io.binary
core.iter
core.js
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
main
runtime
runtime.info
runtime.platform
runtime.vars
simd

package core.string

StringPool
StringPool :: struct {
    arena: Arena;
}
Methods
StringPool.add
StringPool.add :: (sp: &StringPool, s: [] u8) -> [] u8
StringPool.flush
StringPool.flush :: (sp: &StringPool) -> void
StringPool.free
StringPool.free :: (sp: &StringPool) -> void
String_Buffer
String_Buffer :: struct {
    data: [&] u8;
    count: u32;
    capacity: u32;
}
as_str
as_str :: (s: [&] u8) -> [] u8
as_str :: (bs: &BufferStream) -> [] u8
as_str :: macro (t: $T) -> str
    where HasAsStrMethod(T)

Generic procedure for turning something into a string.

buffer_append
buffer_append :: (buffer: &String_Buffer, end: [] u8) -> bool
buffer_clear
buffer_clear :: (buffer: &String_Buffer) -> void
buffer_delete
buffer_delete :: (buffer: &String_Buffer, position: i32) -> bool
buffer_insert
buffer_insert :: (buffer: &String_Buffer, position: i32, ch: u8) -> bool
buffer_make
buffer_make :: (buffer_memory: [] u8, initial_str: [] u8) -> String_Buffer
buffer_to_str
buffer_to_str :: (buffer: &String_Buffer) -> [] u8
compare
compare :: (str1: [] u8, str2: [] u8) -> i32
from_cstr
from_cstr :: (s: [&] u8) -> [] u8
is_empty
is_empty :: (s: [] u8) -> bool
join
join :: (strs: [] [] u8, sep: [] u8, allocator: Allocator) -> [] u8
length
length :: (s: [] u8) -> u32
length :: (s: [&] u8) -> u32
pool_add
pool_add :: (sp: &StringPool, s: [] u8) -> [] u8
pool_flush
pool_flush :: (sp: &StringPool) -> void
pool_free
pool_free :: (sp: &StringPool) -> void
pool_make
pool_make :: (maximum_string_length: i32, allocator: Allocator) -> StringPool
to_cstr_on_stack
to_cstr_on_stack :: macro (s_: [] u8) -> [&] u8

Converts a str into a cstr by copying the memory of the string to the stack, with an additional byte at the end that is set to 0, to correctly for a C-string.

This only needs to be done when the string does not contain a 0 byte on the end, which is most of the time. If you know that the string has a 0 byte, simply use s.data.