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

isnil #

fn isnil(v voidptr) bool

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

malloc #

fn malloc(n int) byteptr

v_calloc #

fn v_calloc(n int) byteptr

memdup #

fn memdup(src voidptr, sz int) voidptr

utf8_getchar #

fn utf8_getchar() int

Reads an utf8 character from standard input

vstrlen #

fn vstrlen(s byteptr) int

eprint #

fn eprint(s string)

panic #

fn panic(s string)

print #

fn print(s string)

println #

fn println(s string)

proc_pidpath #

fn proc_pidpath(int, voidptr, int) int

ptr_str #

fn ptr_str(ptr voidptr) string

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

eprintln #

fn eprintln(s string)

utf8_char_len #

fn utf8_char_len(b byte) int

utf32_to_str_no_malloc #

fn utf32_to_str_no_malloc(code u32, buf voidptr) string

string_from_wide #

fn string_from_wide(_wstr &u16) string

string_from_wide2 #

fn string_from_wide2(_wstr &u16, len int) string

tos #

fn tos(s byteptr, len int) string

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

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_clone #

fn tos_clone(s byteptr) string

tos_lit #

fn tos_lit(s charptr) string

error #

fn error(s string) Option

error_with_code #

fn error_with_code(s string, code int) Option

exit #

fn exit(code int)

utf32_to_str #

fn utf32_to_str(code u32) string

Convert utf32 to utf8 utf32 == Codepoint

compare_f32 #

fn compare_f32(a &f32, b &f32) int

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

f32_abs #

fn f32_abs(a f32) f32

----- C functions -----

f32_max #

fn f32_max(a f32, b f32) f32

f32_min #

fn f32_min(a f32, b f32) f32

compare_f64 #

fn compare_f64(a &f64, b &f64) int

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

f64_max #

fn f64_max(a f64, b f64) f64

vcalloc #

fn vcalloc(n int) byteptr

free #

fn free(ptr voidptr)

v_realloc #

fn v_realloc(b byteptr, n u32) byteptr

#include <malloc/malloc.h> fn malloc_size(b byteptr) int

compare_i64 #

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]

compare_strings #

fn compare_strings(a &string, b &string) int

copy #

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

is_atty #

fn is_atty(fd int) int

OptionBase.str #

fn (o OptionBase) str() string

[]byte.bytestr #

fn (b []byte) bytestr() string

TODO remove this once runes are implemented

[]byte.clone #

fn (b []byte) clone() []byte

[]byte.contains #

fn (a []byte) contains(val byte) bool

TODO generic

[]byte.hex #

fn (b []byte) hex() string

[]byte.hex returns a string with the hexadecimal representation of the byte elements of the array

[]byte.index #

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.

[]char.index #

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?

[]int.sort #

fn (mut a []int) sort()

[]int.sort sorts array of int in place in ascending order.

[]int.index #

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.

[]int.reduce #

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.

[]rune.index #

fn (a []rune) index(v rune) int

[]string.eq #

fn (a1 []string) eq(a2 []string) bool

array_eq checks if two arrays contain all the same elements in the same order. []int == []int (also for: i64, f32, f64, byte, string)

[]string.index #

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.

[]string.join #

fn (a []string) join(del string) string

fn (s []string) substr(a, b int) string { return join_strings(s.slice_fast(a, b)) }

[]string.join_lines #

fn (s []string) join_lines() string

[]string.sort #

fn (mut s []string) sort()

[]string.sort_by_len #

fn (mut s []string) sort_by_len()

[]string.sort_ignore_case #

fn (mut s []string) sort_ignore_case()

[]string.str #

fn (a []string) str() string

[]string.str returns a string representation of the array of strings => '["a", "b", "c"]'

[]u16.contains #

fn (a []u16) contains(val u16) bool

TODO generic

[]u64.contains #

fn (a []u64) contains(val u64) bool

TODO generic

any_float.str #

fn (d any_float) str() string

any_int.str #

fn (n any_int) str() string

any_int.hex #

fn (nn any_int) hex() string

bool.str #

fn (b bool) str() string

byte.hex #

fn (nn byte) hex() string

byte.is_bin_digit #

fn (c byte) is_bin_digit() bool

byte.is_capital #

fn (c byte) is_capital() bool

Define this on byte as well, so that we can do s[0].is_capital()

byte.is_digit #

fn (c byte) is_digit() bool

byte.is_hex_digit #

fn (c byte) is_hex_digit() bool

byte.is_letter #

fn (c byte) is_letter() bool

byte.is_oct_digit #

fn (c byte) is_oct_digit() bool

byte.is_space #

fn (c byte) is_space() bool

byte.is_white #

fn (c byte) is_white() bool

byte.str #

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) }

byte.str_escaped #

fn (b byte) str_escaped() string

byteptr.str #

fn (nn byteptr) str() string

byteptr.vstring #

fn (bp byteptr) vstring() string

byteptr.vstring() - converts a C style string to a V string. NB: the string data is reused, NOT copied.

byteptr.vstring_with_len #

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.

chan.close #

fn (ch chan) close()

The following methods are only stubs. The real implementation is in vlib/sync/channels.v

chan.try_pop #

fn (ch chan) try_pop(obj voidptr) ChanState

chan.try_push #

fn (ch chan) try_push(obj voidptr) ChanState

charptr.vstring #

fn (cp charptr) vstring() string

charptr.vstring() - converts C char* to V string. NB: the string data is reused, NOT copied.

charptr.vstring_with_len #

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.

DenseArray.clone #

fn (d DenseArray) clone() DenseArray

f32.str #

fn (x f32) str() string

----- f32 to string functions ----- str return a f32 as string in suitable notation

f32.strsci #

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

f32.strlong #

fn (x f32) strlong() string

return a decimal notation of the input f32

f32.eq_epsilon #

fn (a f32) eq_epsilon(b f32) bool

f64.str #

fn (x f64) str() string

----- f64 to string functions ----- str return a f64 as string in suitable notation

f64.strsci #

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

f64.strlong #

fn (x f64) strlong() string

return a decimal notation of the input f64

f64.eq_epsilon #

fn (a f64) eq_epsilon(b f64) bool

i16.str #

fn (n i16) str() string

i16.hex #

fn (nn i16) hex() string

i64.str #

fn (nn i64) str() string

i64.hex #

fn (nn i64) hex() string

i8.str #

fn (n i8) str() string

i8.hex #

fn (nn i8) hex() string

int.str_l #

fn (nn int) str_l(max int) string

This implementation is the quickest with gcc -O2

int.str #

fn (n int) str() string

int.hex #

fn (nn int) hex() string

int.hex2 #

fn (n int) hex2() string

Option.str #

fn (o Option) str() string

rune.str #

fn (c rune) str() string

u16.str #

fn (n u16) str() string

u16.hex #

fn (nn u16) hex() string

u32.str #

fn (nn u32) str() string

u32.hex #

fn (nn u32) hex() string

u64.str #

fn (nn u64) str() string

u64.hex #

fn (nn u64) hex() string

u64.hex_full #

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) }

voidptr.str #

fn (nn voidptr) str() string

ustring #

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.

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 int, _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

SortedMap #

struct SortedMap {
	value_bytes int
	root        &mapnode
pub mut:
	len         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()

MethodArgs #

struct MethodArgs {
	typ int

map #

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

map.delete #

fn (mut m map) delete(key string)

Removes the mapping of a particular key from the map.

map.keys #

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

Returns all keys in the map. TODO: add optimization in case of no deletes

map.clone #

fn (m map) clone() map

map.free #

fn (m &map) free()

FunctionData #

struct FunctionData {
	name        string
	attrs       []string
	args        []MethodArgs
	return_type int
	typ         int

VAssertMetaInfo #

struct VAssertMetaInfo {
	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.

FieldData #

struct FieldData {
	name   string
	attrs  []string
	is_pub bool
	is_mut bool
	typ    int

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)


array.insert_many #

fn (mut a array) insert_many(i int, val voidptr, size int)


array.prepend #

fn (mut a array) prepend(val voidptr)


array.prepend_many #

fn (mut a array) prepend_many(val voidptr, size int)


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.pop #

fn (mut a array) pop() voidptr

array.pop returns the last element of the array, and removes it

array.delete_last #

fn (mut a array) delete_last()

array.delete_last efficiently deletes 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_in_place #

fn (mut a array) reverse_in_place()

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()

pub fn (a []int) free() {

array.grow #

fn (mut a array) grow(amount int)

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.

string #

struct string {
	str    byteptr
	len    int
	is_lit int

string.after #

fn (s string) after(dot string) string

string.after_char #

fn (s string) after_char(dot byte) 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.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.bool #

fn (s string) bool() bool

string.bytes #

fn (s string) bytes() []byte

string.capitalize #

fn (s string) capitalize() string

string.clone #

fn (a string) clone() string

string.contains #

fn (s string) contains(substr string) bool

string.contains_any #

fn (s string) contains_any(chars string) bool

string.contains_any_substr #

fn (s string) contains_any_substr(substrs []string) bool

string.count #

fn (s string) count(substr string) int

counts occurrences of substr in s

string.ends_with #

fn (s string) ends_with(p string) bool

string.f32 #

fn (s string) f32() f32

string.f64 #

fn (s string) f64() f64

string.fields #

fn (s string) fields() []string

string.filter #

fn (s string) filter(func fn (byte) bool) string

string.find_between #

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

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

string.free #

fn (s &string) free()

string.hash #

fn (s string) hash() int

string.i16 #

fn (s string) i16() i16

string.i64 #

fn (s string) i64() i64

string.i8 #

fn (s string) i8() i8

string.index #

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

string.index_after #

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

string.index_any #

fn (s string) index_any(chars string) int

string.index_byte #

fn (s string) index_byte(c byte) int

string.index_old #

fn (s string) index_old(p string) int

string.int #

fn (s string) int() int

string.is_capital #

fn (s string) is_capital() bool

string.is_lower #

fn (s string) is_lower() bool

string.is_title #

fn (s string) is_title() bool

string.is_upper #

fn (s string) is_upper() bool

string.last_index #

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

string.last_index_byte #

fn (s string) last_index_byte(c byte) int

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.map #

fn (s string) map(func fn (byte) byte) string

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.replace #

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

string.replace_each #

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


string.replace_once #

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

string.reverse #

fn (s string) reverse() string

reverse will return a new reversed string.

string.split #

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

string.split_into_lines #

fn (s string) split_into_lines() []string

string.split_nth #

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

string.starts_with #

fn (s string) starts_with(p string) bool

string.str #

fn (s string) str() 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.substr #

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

string.title #

fn (s string) title() string

string.to_lower #

fn (s string) to_lower() string

TODO only works with ASCII

string.to_upper #

fn (s string) to_upper() string

string.to_wide #

fn (_str string) to_wide() &u16

string.trim #

fn (s string) trim(cutset string) string

string.trim_left #

fn (s string) trim_left(cutset string) string

string.trim_prefix #

fn (s string) trim_prefix(str string) string

string.trim_right #

fn (s string) trim_right(cutset string) string

string.trim_space #

fn (s string) trim_space() string

string.trim_suffix #

fn (s string) trim_suffix(str string) string

string.u16 #

fn (s string) u16() u16

string.u32 #

fn (s string) u32() u32

string.u64 #

fn (s string) u64() u64

string.ustring #

fn (s string) ustring() ustring

string.ustring_tmp #

fn (s string) ustring_tmp() ustring

string.utf32_code #

fn (_rune string) utf32_code() int

Convert utf8 to utf32