array #

struct array {
	element_size int
pub mut:
	data         voidptr
	len          int
	cap          int

array.repeat #

fn (a array) repeat(count int) array

repeat returns new array with the given array elements repeated given times.

array.sort_with_compare #

fn (mut a array) sort_with_compare(compare voidptr)

array.sort sorts array in-place using given compare function as comparator

array.insert #

fn (mut a array) insert(i int, val voidptr)

TODO array.insert is broken Cannot pass literal or primitive type as it cannot be cast to voidptr. In the current state only that would work: i := 3 a.insert(0, &i)

array.prepend #

fn (mut a array) prepend(val voidptr)

TODO array.prepend is broken It depends on array.insert

array.delete #

fn (mut a array) delete(i int)

array.delete deletes array element at the given index

array.clear #

fn (mut a array) clear()

clears the array without deallocating the allocated data

array.trim #

fn (mut a array) trim(index int)

trims the array length to "index" without modifying the allocated data. If "index" is greater than len nothing will be changed

array.first #

fn (a array) first() voidptr

array.first returns the first element of the array

array.last #

fn (a array) last() voidptr

array.last returns the last element of the array

array.clone #

fn (a &array) clone() array

array.clone returns an independent copy of a given array

array.push_many #

fn (mut a3 array) push_many(val voidptr, size int)

val is array.data TODO make private, right now it's used by strings.Builder

array.reverse #

fn (a array) reverse() array

array.reverse returns a new array with the elements of the original array in reverse order.

array.free #

fn (a &array) free()

array.pointers #

fn (a array) pointers() []voidptr

a.pointers() returns a new array, where each element is the address of the corresponding element in a.

copy #

fn copy(dst, src []byte) int

copy copies the src byte array elements to the dst byte array. The number of the elements copied is the minimum of the length of both arrays. Returns the number of elements copied. TODO: implement for all types

compare_i64 #

fn compare_i64(a, b &i64) int

compare_i64 for []f64 sort_with_compare() sort []i64 with quicksort usage : mut x := [i64(100),10,70,28,92] x.sort_with_compare(compare_i64) println(x) // Sorted i64 Array output: [10, 28, 70, 92, 100]

compare_f64 #

fn compare_f64(a, b &f64) int

compare_f64 for []f64 sort_with_compare() ref. compare_i64(...)

compare_f32 #

fn compare_f32(a, b &f32) int

compare_f32 for []f32 sort_with_compare() ref. compare_i64(...)

exit #

fn exit(code int)

isnil #

fn isnil(v voidptr) bool

isnil returns true if an object is nil (only for C objects).

panic #

fn panic(s string)

eprintln #

fn eprintln(s string)

eprint #

fn eprint(s string)

print #

fn print(s string)

println #

fn println(s string)

malloc #

fn malloc(n int) byteptr

v_realloc #

fn v_realloc(b byteptr, n int) byteptr

v_calloc #

fn v_calloc(n int) byteptr

vcalloc #

fn vcalloc(n int) byteptr

free #

fn free(ptr voidptr)

memdup #

fn memdup(src voidptr, sz int) voidptr

is_atty #

fn is_atty(fd int) int

proc_pidpath #

fn proc_pidpath(arg_1 int, arg_2 voidptr, arg_3 int) int

ptr_str #

fn ptr_str(ptr voidptr) string

----- value to string functions -----

map #

struct map {
	value_bytes     int
	cap             u32
	cached_hashbits byte
	shift           byte
	key_values      DenseArray
	metas           &u32
	extra_metas     u32
pub mut:
	size            int

map.delete #

fn (mut m map) delete(key string)

map.keys #

fn (m &map) keys() []string

TODO: add optimization in case of no deletes

map.clone #

fn (m map) clone() map

map.free #

fn (m &map) free()

error #

fn error(s string) Option

error_with_code #

fn error_with_code(s string, code int) Option

SortedMap #

struct SortedMap {
	value_bytes int
	root        &mapnode
pub mut:
	size        int

SortedMap.delete #

fn (mut m SortedMap) delete(key string)

SortedMap.keys #

fn (m &SortedMap) keys() []string

SortedMap.free #

fn (mut m SortedMap) free()

SortedMap.print #

fn (m SortedMap) print()

string #

struct string {
	str    byteptr
	len    int
	is_lit bool

string.clone #

fn (a string) clone() string

string.replace_once #

fn (s string) replace_once(rep, with string) string

string.replace #

fn (s string) replace(rep, with string) string

string.replace_each #

fn (s string) replace_each(vals []string) string


string.bool #

fn (s string) bool() bool

string.int #

fn (s string) int() int

string.i64 #

fn (s string) i64() i64

string.i8 #

fn (s string) i8() i8

string.i16 #

fn (s string) i16() i16

string.f32 #

fn (s string) f32() f32

string.f64 #

fn (s string) f64() f64

string.u16 #

fn (s string) u16() u16

string.u32 #

fn (s string) u32() u32

string.u64 #

fn (s string) u64() u64

string.split #

fn (s string) split(delim string) []string

string.split_nth #

fn (s string) split_nth(delim string, nth int) []string

string.split_into_lines #

fn (s string) split_into_lines() []string

string.substr #

fn (s string) substr(start, end int) string

string.index_old #

fn (s string) index_old(p string) int

string.index #

fn (s string) index(p string) ?int

string.index_any #

fn (s string) index_any(chars string) int

string.last_index #

fn (s string) last_index(p string) ?int

string.index_after #

fn (s string) index_after(p string, start int) int

string.index_byte #

fn (s string) index_byte(c byte) int

string.last_index_byte #

fn (s string) last_index_byte(c byte) int

string.count #

fn (s string) count(substr string) int

counts occurrences of substr in s

string.contains #

fn (s string) contains(p string) bool

string.starts_with #

fn (s string) starts_with(p string) bool

string.ends_with #

fn (s string) ends_with(p string) bool

string.to_lower #

fn (s string) to_lower() string

TODO only works with ASCII

string.is_lower #

fn (s string) is_lower() bool

string.to_upper #

fn (s string) to_upper() string

string.is_upper #

fn (s string) is_upper() bool

string.capitalize #

fn (s string) capitalize() string

string.is_capital #

fn (s string) is_capital() bool

string.title #

fn (s string) title() string

string.is_title #

fn (s string) is_title() bool

string.find_between #

fn (s string) find_between(start, end string) string

'hey [man] how you doin' find_between('[', ']') == 'man'

string.trim_space #

fn (s string) trim_space() string

string.trim #

fn (s string) trim(cutset string) string

string.trim_left #

fn (s string) trim_left(cutset string) string

string.trim_right #

fn (s string) trim_right(cutset string) string

string.trim_prefix #

fn (s string) trim_prefix(str string) string

string.trim_suffix #

fn (s string) trim_suffix(str string) string

string.str #

fn (s string) str() string

string.ustring #

fn (s string) ustring() ustring

string.ustring_tmp #

fn (s string) ustring_tmp() ustring

string.free #

fn (s &string) free()

string.all_before #

fn (s string) all_before(dot string) string

all_before('23:34:45.234', '.') == '23:34:45'

string.all_before_last #

fn (s string) all_before_last(dot string) string

string.all_after #

fn (s string) all_after(dot string) string

string.all_after_last #

fn (s string) all_after_last(dot string) string

string.after #

fn (s string) after(dot string) string

string.after_char #

fn (s string) after_char(dot byte) string

string.reverse #

fn (s string) reverse() string

reverse will return a new reversed string.

string.limit #

fn (s string) limit(max int) string

limit returns a portion of the string, starting at 0 and extending for a given number of characters afterward. 'hello'.limit(2) => 'he' 'hi'.limit(10) => 'hi'

string.hash #

fn (s string) hash() int

string.bytes #

fn (s string) bytes() []byte

string.repeat #

fn (s string) repeat(count int) string

repeat returns a new string with a specified number of copies of the string it was called on.

string.fields #

fn (s string) fields() []string

string.strip_margin #

fn (s string) strip_margin() string

Allows multi-line strings to be formatted in a way that removes white-space before a delimeter. by default | is used. Note: the delimiter has to be a byte at this time. That means surrounding the value in ``. Example: st := 'Hello there, this is a string, Everything before the first | is removed'.strip_margin() Returns: Hello there, this is a string, Everything before the first | is removed

string.strip_margin_custom #

fn (s string) strip_margin_custom(del byte) string

string.utf32_code #

fn (_rune string) utf32_code() int

Convert utf8 to utf32

string.to_wide #

fn (_str string) to_wide() &u16

ustring #

struct ustring {
pub mut:
	s     string
	runes []int
	len   int

mut: hash_cache int

ustring.str #

fn (s ustring) str() string

ustring.add #

fn (u ustring) add(a ustring) ustring

ustring.index_after #

fn (u ustring) index_after(p ustring, start int) int

ustring.count #

fn (u ustring) count(substr ustring) int

counts occurrences of substr in s

ustring.substr #

fn (u ustring) substr(_start, _end int) string

ustring.left #

fn (u ustring) left(pos int) string

ustring.right #

fn (u ustring) right(pos int) string

ustring.at #

fn (u ustring) at(idx int) string

vstrlen #

fn vstrlen(s byteptr) int

tos #

fn tos(s byteptr, len int) string

Converts a C string to a V string. String data is reused, not copied.

tos_clone #

fn tos_clone(s byteptr) string

tos2 #

fn tos2(s byteptr) string

Same as tos, but calculates the length. Called by string(bytes) casts. Used only internally.

tos3 #

fn tos3(s charptr) string

Same as tos2, but for char*, to avoid warnings

tos_lit #

fn tos_lit(s charptr) string

cstring_to_vstring #

fn cstring_to_vstring(cstr byteptr) string

cstring_to_vstring creates a copy of cstr and turns it into a v string

compare_strings #

fn compare_strings(a, b &string) int

utf8_char_len #

fn utf8_char_len(b byte) int

utf32_to_str #

fn utf32_to_str(code u32) string

Convert utf32 to utf8 utf32 == Codepoint

utf32_to_str_no_malloc #

fn utf32_to_str_no_malloc(code u32, buf voidptr) string

TODO copypasta

string_from_wide #

fn string_from_wide(_wstr &u16) string

string_from_wide2 #

fn string_from_wide2(_wstr &u16, len int) string

utf8_getchar #

fn utf8_getchar() int

Reads an utf8 character from standard input