fn cstring_to_vstring(cstr byteptr) string
cstring_to_vstring creates a copy of cstr and turns it into a v string
fn isnil(v voidptr) bool
isnil returns true if an object is nil (only for C objects).
fn malloc(n int) byteptr
fn v_calloc(n int) byteptr
fn memdup(src voidptr, sz int) voidptr
fn utf8_getchar() int
Reads an utf8 character from standard input
fn vstrlen(s byteptr) int
fn eprint(s string)
fn panic(s string)
fn print(s string)
fn print_backtrace()
fn println(s string)
fn proc_pidpath(int, voidptr, int) int
fn ptr_str(ptr voidptr) string
----- value to string functions -----
fn eprintln(s string)
fn utf8_char_len(b byte) int
fn utf32_to_str_no_malloc(code u32, buf voidptr) string
fn string_from_wide(_wstr &u16) string
fn string_from_wide2(_wstr &u16, len int) string
fn tos(s byteptr, len int) string
Converts a C string to a V string. String data is reused, not copied.
fn tos2(s byteptr) string
Same as tos, but calculates the length. Called by string(bytes) casts. Used only internally.
fn tos3(s charptr) string
Same as tos2, but for char*, to avoid warnings
fn tos_clone(s byteptr) string
fn tos_lit(s charptr) string
fn error(s string) Option
fn error_with_code(s string, code int) Option
fn exit(code int)
fn utf32_to_str(code u32) string
Convert utf32 to utf8 utf32 == Codepoint
fn compare_f32(a &f32, b &f32) int
compare_f32 for []f32 sort_with_compare() ref. compare_i64(...)
fn f32_abs(a f32) f32
----- C functions -----
fn f32_max(a f32, b f32) f32
fn f32_min(a f32, b f32) f32
fn compare_f64(a &f64, b &f64) int
compare_f64 for []f64 sort_with_compare() ref. compare_i64(...)
fn f64_max(a f64, b f64) f64
fn vcalloc(n int) byteptr
fn free(ptr voidptr)
fn v_realloc(b byteptr, n u32) byteptr
#include <malloc/malloc.h> fn malloc_size(b byteptr) int
fn compare_i64(a &i64, 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]
fn compare_strings(a &string, b &string) int
fn copy(dst []byte, 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
fn is_atty(fd int) int
fn (o OptionBase) str() string
fn (b []byte) bytestr() string
TODO remove this once runes are implemented
fn (b []byte) clone() []byte
fn (a []byte) contains(val byte) bool
TODO generic
fn (b []byte) hex() string
[]byte.hex returns a string with the hexadecimal representation of the byte elements of the array
fn (a []byte) index(v byte) int
[]byte.index returns the index of the first element equal to the given value, or -1 if the value is not found in the array.
fn (a []char) index(v char) int
[]char.index returns the index of the first element equal to the given value, or -1 if the value is not found in the array. TODO is char type yet in the language?
fn (mut a []int) sort()
[]int.sort sorts array of int in place in ascending order.
fn (a []int) index(v int) int
[]int.index returns the index of the first element equal to the given value, or -1 if the value is not found in the array.
fn (a []int) reduce(iter fn (int, int) int, accum_start int) int
[]int.reduce executes a given reducer function on each element of the array, resulting in a single output value.
fn (a []rune) index(v rune) int
fn (a1 []string) eq(a2 []string) bool
array_eq
fn (a []string) index(v string) int
[]string.index returns the index of the first element equal to the given value, or -1 if the value is not found in the array.
fn (a []string) join(del string) string
fn (s []string) substr(a, b int) string { return join_strings(s.slice_fast(a, b)) }
fn (s []string) join_lines() string
fn (mut s []string) sort()
fn (mut s []string) sort_by_len()
fn (mut s []string) sort_ignore_case()
fn (a []string) str() string
[]string.str returns a string representation of the array of strings => '["a", "b", "c"]'
fn (a []u16) contains(val u16) bool
TODO generic
fn (a []u64) contains(val u64) bool
TODO generic
fn (d any_float) str() string
fn (n any_int) str() string
fn (nn any_int) hex() string
fn (b bool) str() string
fn (nn byte) hex() string
fn (c byte) is_bin_digit() bool
fn (c byte) is_capital() bool
Define this on byte as well, so that we can do s[0].is_capital()
fn (c byte) is_digit() bool
fn (c byte) is_hex_digit() bool
fn (c byte) is_letter() bool
fn (c byte) is_oct_digit() bool
fn (c byte) is_space() bool
fn (c byte) is_white() bool
fn (b byte) str() string
pub fn (nn i64) hex_full() string { return u64_to_hex(u64(nn), 16) } pub fn (nn any_int) hex_full() string { return u64_to_hex(nn, 16) } pub fn (nn voidptr) hex_full() string { return u64_to_hex(nn, 16) } pub fn (nn byteptr) hex_full() string { return u64_to_hex(nn, 16) }
fn (b byte) str_escaped() string
fn (nn byteptr) str() string
fn (bp byteptr) vstring() string
byteptr.vstring() - converts a C style string to a V string. NB: the string data is reused, NOT copied.
fn (bp byteptr) vstring_with_len(len int) string
byteptr.vstring_with_len() - converts a C style string to a V string. NB: the string data is reused, NOT copied.
fn (ch chan) close()
The following methods are only stubs. The real implementation is in vlib/sync/channels.v
fn (ch chan) try_pop(obj voidptr) ChanState
fn (ch chan) try_push(obj voidptr) ChanState
fn (cp charptr) vstring() string
charptr.vstring() - converts C char* to V string. NB: the string data is reused, NOT copied.
fn (cp charptr) vstring_with_len(len int) string
charptr.vstring_with_len() - converts C char* to V string. NB: the string data is reused, NOT copied.
fn (d DenseArray) clone() DenseArray
fn (x f32) str() string
----- f32 to string functions ----- str return a f32 as string in suitable notation
fn (x f32) strsci(digit_num int) string
return a string of the input f32 in scientific notation with digit_num deciamals displayed, max 8 digits
fn (x f32) strlong() string
return a decimal notation of the input f32
fn (a f32) eq_epsilon(b f32) bool
fn (x f64) str() string
----- f64 to string functions ----- str return a f64 as string in suitable notation
fn (x f64) strsci(digit_num int) string
return a string of the input f64 in scientific notation with digit_num deciamals displayed, max 17 digits
fn (x f64) strlong() string
return a decimal notation of the input f64
fn (a f64) eq_epsilon(b f64) bool
fn (n i16) str() string
fn (nn i16) hex() string
fn (nn i64) str() string
fn (nn i64) hex() string
fn (n i8) str() string
fn (nn i8) hex() string
fn (nn int) str_l(max int) string
This implementation is the quickest with gcc -O2
fn (n int) str() string
fn (nn int) hex() string
fn (n int) hex2() string
fn (o Option) str() string
fn (c rune) str() string
fn (n u16) str() string
fn (nn u16) hex() string
fn (nn u32) str() string
fn (nn u32) hex() string
fn (nn u64) str() string
fn (nn u64) hex() string
fn (nn u64) hex_full() string
pub fn (nn byte) hex_full() string { return u64_to_hex(nn, 2) } pub fn (nn i8) hex_full() string { return u64_to_hex(byte(nn), 2) } pub fn (nn u16) hex_full() string { return u64_to_hex(nn, 4) } pub fn (nn i16) hex_full() string { return u64_to_hex(u16(nn), 4) } pub fn (nn u32) hex_full() string { return u64_to_hex(nn, 8) } pub fn (nn int) hex_full() string { return u64_to_hex(u32(nn), 8) }
fn (nn voidptr) str() string
struct ustring {
pub mut:
s string
runes []int
len int
}
mut: hash_cache int NB string.is_lit is an enumeration of the following: .is_lit == 0 => a fresh string, should be freed by autofree .is_lit == 1 => a literal string from .rodata, should NOT be freed .is_lit == -98761234 => already freed string, protects against double frees. ^^^^^^^^^ calling free on these is a bug. Any other value means that the string has been corrupted.
fn (s ustring) str() string
fn (u ustring) add(a ustring) ustring
fn (u ustring) index_after(p ustring, start int) int
fn (u ustring) count(substr ustring) int
counts occurrences of substr in s
fn (u ustring) substr(_start int, _end int) string
fn (u ustring) left(pos int) string
fn (u ustring) right(pos int) string
fn (u ustring) at(idx int) string
struct SortedMap {
value_bytes int
mut:
root &mapnode
pub mut:
len int
}
fn (mut m SortedMap) delete(key string)
fn (m &SortedMap) keys() []string
fn (mut m SortedMap) free()
fn (m SortedMap) print()
struct MethodArgs {
pub:
typ int
}
struct map {
value_bytes int
mut:
cap u32
cached_hashbits byte
shift byte
key_values DenseArray
metas &u32
extra_metas u32
pub mut:
len int
}
fn (mut m map) delete(key string)
Removes the mapping of a particular key from the map.
fn (m &map) keys() []string
Returns all keys in the map. TODO: add optimization in case of no deletes
fn (m map) clone() map
fn (m &map) free()
struct FunctionData {
pub:
name string
attrs []string
args []MethodArgs
return_type int
typ int
}
struct VAssertMetaInfo {
pub:
fpath string
line_nr int
fn_name string
src string
op string
llabel string
rlabel string
lvalue string
rvalue string
}
VAssertMetaInfo is used during assertions. An instance of it is filled in by compile time generated code, when an assertion fails.
struct FieldData {
pub:
name string
attrs []string
is_pub bool
is_mut bool
typ int
}
struct array {
pub:
element_size int
pub mut:
data voidptr
len int
cap int
}
fn (a array) repeat(count int) array
repeat returns new array with the given array elements repeated given times.
fn (mut a array) sort_with_compare(compare voidptr)
array.sort sorts array in-place using given compare function as comparator
fn (mut a array) insert(i int, val voidptr)
array.insert
fn (mut a array) insert_many(i int, val voidptr, size int)
array.insert_many
fn (mut a array) prepend(val voidptr)
array.prepend
fn (mut a array) prepend_many(val voidptr, size int)
array.prepend_many
fn (mut a array) delete(i int)
array.delete deletes array element at the given index
fn (mut a array) clear()
clears the array without deallocating the allocated data
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
fn (a array) first() voidptr
array.first returns the first element of the array
fn (a array) last() voidptr
array.last returns the last element of the array
fn (mut a array) pop() voidptr
array.pop returns the last element of the array, and removes it
fn (mut a array) delete_last()
array.delete_last efficiently deletes the last element of the array
fn (a &array) clone() array
array.clone returns an independent copy of a given array
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
fn (mut a array) reverse_in_place()
fn (a array) reverse() array
array.reverse returns a new array with the elements of the original array in reverse order.
fn (a &array) free()
pub fn (a []int) free() {
fn (mut a array) grow(amount int)
fn (a array) pointers() []voidptr
a.pointers() returns a new array, where each element is the address of the corresponding element in a.
struct string {
pub:
str byteptr
len int
mut:
is_lit int
}
fn (s string) after(dot string) string
fn (s string) after_char(dot byte) string
fn (s string) all_after(dot string) string
fn (s string) all_after_last(dot string) string
fn (s string) all_before(dot string) string
all_before('23:34:45.234', '.') == '23:34:45'
fn (s string) all_before_last(dot string) string
fn (s string) bool() bool
fn (s string) bytes() []byte
fn (s string) capitalize() string
fn (a string) clone() string
fn (s string) contains(substr string) bool
fn (s string) contains_any(chars string) bool
fn (s string) contains_any_substr(substrs []string) bool
fn (s string) count(substr string) int
counts occurrences of substr in s
fn (s string) ends_with(p string) bool
fn (s string) f32() f32
fn (s string) f64() f64
fn (s string) fields() []string
fn (s string) filter(func fn (byte) bool) string
fn (s string) find_between(start string, end string) string
'hey [man] how you doin' find_between('[', ']') == 'man'
fn (s &string) free()
fn (s string) hash() int
fn (s string) i16() i16
fn (s string) i64() i64
fn (s string) i8() i8
fn (s string) index(p string) ?int
fn (s string) index_after(p string, start int) int
fn (s string) index_any(chars string) int
fn (s string) index_byte(c byte) int
fn (s string) index_old(p string) int
fn (s string) int() int
fn (s string) is_capital() bool
fn (s string) is_lower() bool
fn (s string) is_title() bool
fn (s string) is_upper() bool
fn (s string) last_index(p string) ?int
fn (s string) last_index_byte(c byte) int
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'
fn (s string) map(func fn (byte) byte) string
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.
fn (s string) replace(rep string, with string) string
fn (s string) replace_each(vals []string) string
TODO
fn (s string) replace_once(rep string, with string) string
fn (s string) reverse() string
reverse will return a new reversed string.
fn (s string) split(delim string) []string
fn (s string) split_into_lines() []string
fn (s string) split_nth(delim string, nth int) []string
fn (s string) starts_with(p string) bool
fn (s string) str() string
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
fn (s string) strip_margin_custom(del byte) string
fn (s string) substr(start int, end int) string
fn (s string) title() string
fn (s string) to_lower() string
TODO only works with ASCII
fn (s string) to_upper() string
fn (_str string) to_wide() &u16
fn (s string) trim(cutset string) string
fn (s string) trim_left(cutset string) string
fn (s string) trim_prefix(str string) string
fn (s string) trim_right(cutset string) string
fn (s string) trim_space() string
fn (s string) trim_suffix(str string) string
fn (s string) u16() u16
fn (s string) u32() u32
fn (s string) u64() u64
fn (s string) ustring() ustring
fn (s string) ustring_tmp() ustring
fn (_rune string) utf32_code() int
Convert utf8 to utf32