package core:fmt

⌘K
Ctrl+K
or
/

    Overview

    package fmt implements formatted I/O with procedures similar to C's printf and Python's format. The format 'verbs' are derived from C's but simpler.

    Printing

    The verbs:

    General:

    %v     the value in a default format
    %#v    an expanded format of %v with newlines and indentation
    %w     an Odin-syntax representation of the value
    %T     an Odin-syntax representation of the type of the value
    %%     a literal percent sign; consumes no value
    {{     a literal open brace; consumes no value
    }}     a literal close brace; consumes no value
    {:v}   equivalent to %v (Python-like formatting syntax)
    
    

    Boolean:

    %t    the word "true" or "false"
    

    Integer:

    %b    base 2
    %c    the character represented by the corresponding Unicode code point
    %r    synonym for %c
    %o    base 8
    %d    base 10
    %i    base 10
    %z    base 12
    %x    base 16, with lower-case letters for a-f
    %X    base 16, with upper-case letters for A-F
    %U    Unicode format: U+1234; same as "U+%04X"
    

    Floating-point, complex numbers, and quaternions:

    %e    scientific notation, e.g. -1.23456e+78
    %E    scientific notation, e.g. -1.23456E+78
    %f    decimal point but no exponent, e.g. 123.456
    %F    synonym for %f
    %g    synonym for %f with default maximum precision
    %G    synonym for %g
    %h    hexadecimal (lower-case) representation with 0h prefix (0h01234abcd)
    %H    hexadecimal (upper-case) representation with 0H prefix (0h01234ABCD)
    %m    number of bytes in the best unit of measurement, e.g. 123.45mib
    %M    number of bytes in the best unit of measurement, e.g. 123.45MiB
    

    String and slice of bytes

    %s    the uninterpreted bytes of the string or slice
    %q    a double-quoted string safely escaped with Odin syntax
    %x    base 16, lower-case, two characters per byte
    %X    base 16, upper-case, two characters per byte
    

    Slice and dynamic array:

    %p    address of the 0th element in base 16 notation (upper-case), with leading 0x
    

    Pointer:

    %p    base 16 notation (upper-case), with leading 0x
    The %b, %d, %o, %z, %x, %X verbs also work with pointers,
    treating it as if it was an integer
    

    Enums:

    %s    prints the name of the enum field
    The %i, %d, %f verbs also work with enums,
    treating it as if it was a number
    
    

    For compound values, the elements are printed using these rules recursively; laid out like the following:

    struct:            {name0 = field0, name1 = field1, ...}
    array              [elem0, elem1, elem2, ...]
    enumerated array   [key0 = elem0, key1 = elem1, key2 = elem2, ...]
    maps:              map[key0 = value0, key1 = value1, ...]
    bit sets           {key0 = elem0, key1 = elem1, ...}
    pointer to above:  &{}, &[], &map[]
    
    

    Width is specified by an optional decimal number immediately after the '%'. If not present, the width is whatever is necessary to represent the value. Precision is specified after the (optional) width by a period followed by a decimal number. If no period is present, a default precision is used. A period with no following number specifies a precision of 0.

    Examples:

    %f     default width, default precision
    %8f    width 8, default precision
    %.2f   default width, precision 2
    %8.3f  width 8, precision 3
    %8.f   width 8, precision 0
    
    

    Width and precision are measured in units of Unicode code points (runes). n.b. C's printf uses units of bytes.

    Other flags:

    +      always print a sign for numeric values
    -      pad with spaces on the right rather the left (left-justify the field)
    #      alternate format:
                   add leading 0b for binary (%#b)
                   add leading 0o for octal (%#o)
                   add leading 0z for dozenal (%#z)
                   add leading 0x or 0X for hexadecimal (%#x or %#X)
                   remove leading 0x for %p (%#p)
                   add a space between bytes and the unit of measurement (%#m or %#M)
    ' '    (space) leave a space for elided sign in numbers (% d)
    0      pad with leading zeros rather than spaces
    
    
    

    Flags are ignored by verbs that don't expect them.

    For each printf-like procedure, there is a print function that takes no format, and is equivalent to doing %v for every value and inserts a separator between each value (default is a single space). Another procedure println which has the same functionality as print but appends a newline.

    Explicit argument indices:

    In printf-like procedures, the default behaviour is for each formatting verb to format successive arguments passed in the call. However, the notation [n] immediately before the verb indicates that the nth zero-index argument is to be formatted instead. The same notation before an '*' for a width or precision specifier selects the argument index holding the value. Python-like syntax with argument indices differs for selecting the argument index: {n:v}

    Examples:

    fmt.printfln("%[1]d %[0]d", 13, 37) // C-like syntax
    fmt.printfln("{1:d} {0:d}", 13, 37) // Python-like syntax
    

    prints "37 13", whilst:

    fmt.printfln("%*[2].*[1][0]f", 17.0, 2, 6) // C-like syntax
    fmt.printfln("{0:*[2].*[1]f}", 17.0, 2, 6) // Python-like syntax
    

    is equivalent to:

    fmt.printfln("%6.2f",   17.0) // C-like syntax
    fmt.printfln("{:6.2f}", 17.0) // Python-like syntax
    

    and prints "17.00".

    Format errors:

    If an invalid argument is given for a verb, such as providing a string to %d, the generated string will contain a description of the problem. For example:

    Bad enum value:
    	%!(BAD ENUM VALUE)
    Too many arguments:
    	%!(EXTRA <value>, <value>, ...)
    Too few arguments:
    	%!(MISSING ARGUMENT)
    Invalid width or precision
    	%!(BAD WIDTH)
    	%!(BAD PRECISION)
    Missing verb:
    	%!(NO VERB)
    Invalid or invalid use of argument index:
    	%!(BAD ARGUMENT NUMBER)
    Missing close brace when using Python-like formatting syntax:
    	%!(MISSING CLOSE BRACE)
    

    Types

    Info ¶

    Info :: struct {
    	using state:         Info_State,
    	writer:              io.Stream,
    	arg:                 any,
    	// Temporary
    	indirection_level:   int,
    	record_level:        int,
    	optional_len:        runtime.Maybe($T),
    	use_nul_termination: bool,
    	n:                   int,
    }
     

    Internal data structure that stores the required information for formatted printing

    Related Procedures With Parameters

    Info_State ¶

    Info_State :: struct {
    	minus:                  bool,
    	plus:                   bool,
    	space:                  bool,
    	zero:                   bool,
    	hash:                   bool,
    	width_set:              bool,
    	prec_set:               bool,
    	ignore_user_formatters: bool,
    	in_bad:                 bool,
    	width:                  int,
    	prec:                   int,
    	indent:                 int,
    }

    Register_User_Formatter_Error ¶

    Register_User_Formatter_Error :: enum int {
    	None, 
    	No_User_Formatter, 
    	Formatter_Previously_Found, 
    }
    Related Procedures With Returns

    User_Formatter ¶

    User_Formatter :: proc(fi: ^Info, arg: any, verb: rune) -> bool
     

    Custom formatter signature. It returns true if the formatting was successful and false when it could not be done

    Related Procedures With Parameters

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    aprint ¶

    aprint :: proc(.. args: ..any, sep: string = " ", allocator := context.allocator) -> string {…}
     

    Creates a formatted string

    *Allocates Using Context's Allocator*
    
    Inputs:
    - args: A variadic list of arguments to be formatted.
    - sep: An optional separator string (default is a single space).
    
    Returns: A formatted string.
    

    aprintf ¶

    aprintf :: proc(fmt: string, .. args: ..any, allocator := context.allocator, newline: bool = false) -> string {…}
     

    Creates a formatted string using a format string and arguments

    *Allocates Using Context's Allocator*
    
    Inputs:
    - fmt: A format string with placeholders for the provided arguments.
    - args: A variadic list of arguments to be formatted.
    - newline: Whether the string should end with a newline. (See `aprintfln`.)
    
    Returns: A formatted string. The returned string must be freed accordingly.
    

    aprintfln ¶

    aprintfln :: proc(fmt: string, .. args: ..any, allocator := context.allocator) -> string {…}
     

    Creates a formatted string using a format string and arguments, followed by a newline.

    *Allocates Using Context's Allocator*
    
    Inputs:
    - fmt: A format string with placeholders for the provided arguments.
    - args: A variadic list of arguments to be formatted.
    
    Returns: A formatted string. The returned string must be freed accordingly.
    

    aprintln ¶

    aprintln :: proc(.. args: ..any, sep: string = " ", allocator := context.allocator) -> string {…}
     

    Creates a formatted string with a newline character at the end

    *Allocates Using Context's Allocator*
    
    Inputs:
    - args: A variadic list of arguments to be formatted.
    - sep: An optional separator string (default is a single space).
    
    Returns: A formatted string with a newline character at the end.
    

    assertf ¶

    assertf :: proc(condition: bool, fmt: string, .. args: ..any, loc := #caller_location) {…}
     

    Runtime assertion with a formatted message

    Inputs:
    condition: The boolean condition to be asserted fmt: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted loc: The location of the caller

    bprint ¶

    bprint :: proc(buf: []u8, .. args: ..any, sep: string = " ") -> string {…}
     

    Creates a formatted string using a supplied buffer as the backing array. Writes into the buffer.

    Inputs:
    buf: The backing buffer args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    A formatted string

    bprintf ¶

    bprintf :: proc(buf: []u8, fmt: string, .. args: ..any, newline: bool = false) -> string {…}
     

    Creates a formatted string using a supplied buffer as the backing array. Writes into the buffer.

    Inputs:
    buf: The backing buffer fmt: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted newline: Whether the string should end with a newline. (See bprintfln.)

    Returns:
    A formatted string

    bprintfln ¶

    bprintfln :: proc(buf: []u8, fmt: string, .. args: ..any) -> string {…}
     

    Creates a formatted string using a supplied buffer as the backing array, followed by a newline. Writes into the buffer.

    Inputs:
    buf: The backing buffer fmt: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted

    Returns:
    A formatted string

    bprintln ¶

    bprintln :: proc(buf: []u8, .. args: ..any, sep: string = " ") -> string {…}
     

    Creates a formatted string using a supplied buffer as the backing array, appends newline. Writes into the buffer.

    Inputs:
    buf: The backing buffer args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    A formatted string with a newline character at the end

    caprintf ¶

    caprintf :: proc(format: string, .. args: ..any, newline: bool = false) -> cstring {…}
     

    Creates a formatted C string

    Allocates Using Context's Allocator

    Inputs:
    format: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted newline: Whether the string should end with a newline. (See caprintfln.)

    Returns:
    A formatted C string

    caprintfln ¶

    caprintfln :: proc(format: string, .. args: ..any) -> cstring {…}
     

    Creates a formatted C string, followed by a newline.

    Allocates Using Context's Allocator

    Inputs:
    format: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted

    Returns:
    A formatted C string

    ctprint ¶

    ctprint :: proc(.. args: ..any, sep: string = " ") -> cstring {…}
     

    Creates a formatted C string

    *Allocates Using Context's Temporary Allocator*
    
    Inputs:
    - args: A variadic list of arguments to be formatted.
    - sep: An optional separator string (default is a single space).
    
    Returns: A formatted C string.
    

    ctprintf ¶

    ctprintf :: proc(format: string, .. args: ..any, newline: bool = false) -> cstring {…}
     

    Creates a formatted C string

    Allocates Using Context's Temporary Allocator

    Inputs:
    format: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted newline: Whether the string should end with a newline. (See ctprintfln.)

    Returns:
    A formatted C string

    ctprintfln ¶

    ctprintfln :: proc(format: string, .. args: ..any) -> cstring {…}
     

    Creates a formatted C string, followed by a newline.

    Allocates Using Context's Temporary Allocator

    Inputs:
    format: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted

    Returns:
    A formatted C string

    enum_value_to_string ¶

    enum_value_to_string :: proc(val: any) -> (string, bool) {…}
     

    String representation of an enum value.

    Inputs:
    val: The enum value.

    Returns:
    The string representation of the enum value and a boolean indicating success.

    eprint ¶

    eprint :: proc(.. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    eprint formats using the default print settings and writes to os.stderr

    eprintf ¶

    eprintf :: proc(fmt: string, .. args: ..any, flush: bool = true) -> int {…}
     

    eprintf formats according to the specified format string and writes to os.stderr

    eprintfln ¶

    eprintfln :: proc(fmt: string, .. args: ..any, flush: bool = true) -> int {…}
     

    eprintfln formats according to the specified format string and writes to os.stderr, followed by a newline.

    eprintln ¶

    eprintln :: proc(.. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    eprintln formats using the default print settings and writes to os.stderr

    fmt_arg ¶

    fmt_arg :: proc(fi: ^Info, arg: any, verb: rune) {…}
     

    Formats an argument based on its type and the given formatting verb

    Inputs:
    fi: A pointer to an Info struct containing formatting information. arg: The value to be formatted. verb: The formatting verb rune (e.g. 'T').

    NOTE: Uses user formatters if available and not ignored.

    fmt_array ¶

    fmt_array :: proc(
    	fi:        ^Info, 
    	data:      rawptr, 
    	n:         int, 
    	elem_size: int, 
    	elem:      ^runtime.Type_Info, 
    	verb:      rune, 
    ) {…}
     

    Formats an array into a string representation

    Inputs:
    fi: Pointer to the formatting Info struct. data: The raw pointer to the array data. n: The number of elements in the array. elem_size: The size of each element in the array. elem: Pointer to the type information of the array element. verb: The formatting verb (e.g. 's','q','p','w').

    fmt_array_nul_terminated ¶

    fmt_array_nul_terminated :: proc(
    	fi:        ^Info, 
    	data:      rawptr, 
    	max_n:     int, 
    	elem_size: int, 
    	elem:      ^runtime.Type_Info, 
    	verb:      rune, 
    ) {…}
     

    Formats a NUL-terminated array into a string representation

    Inputs:
    fi: Pointer to the formatting Info struct. data: The raw pointer to the array data. max_n: The maximum number of elements to process. elem_size: The size of each element in the array. elem: Pointer to the type information of the array element. verb: The formatting verb.

    fmt_bad_verb ¶

    fmt_bad_verb :: proc(fi: ^Info, verb: rune) {…}
     

    Writes a bad verb error message

    Inputs:
    fi: A pointer to an Info structure verb: The invalid format verb

    fmt_bit_field ¶

    fmt_bit_field :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Bit_Field, type_name: string) {…}

    fmt_bit_set ¶

    fmt_bit_set :: proc(fi: ^Info, v: any, name: string = "", verb: rune = 'v') {…}
     

    Formats a bit set and writes it to the provided Info structure

    Inputs:
    fi: A pointer to the Info structure where the formatted bit set will be written. v: The bit set value to be formatted. name: An optional string for the name of the bit set (default is an empty string). verb: An optional verb to adjust format.

    fmt_bool ¶

    fmt_bool :: proc(fi: ^Info, b: bool, verb: rune) {…}
     

    Formats a boolean value according to the specified format verb

    Inputs:
    fi: A pointer to an Info structure b: The boolean value to format verb: The format verb

    fmt_complex ¶

    fmt_complex :: proc(fi: ^Info, c: complex128, bits: int, verb: rune) {…}
     

    Formats a complex number based on the given formatting verb

    Inputs:
    fi: A pointer to an Info struct containing formatting information. c: The complex128 value to be formatted. bits: The number of bits in the complex number (32 or 64). verb: The formatting verb rune ('f', 'F', 'v', 'h', 'H', 'w').

    fmt_cstring ¶

    fmt_cstring :: proc(fi: ^Info, s: cstring, verb: rune) {…}
     

    Formats a C-style string with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. s: The C-style string to format. verb: The format specifier character (Ref fmt_string).

    fmt_enum ¶

    fmt_enum :: proc(fi: ^Info, v: any, verb: rune) {…}
     

    Formats an enum value with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. v: The enum value to format. verb: The format specifier character (e.g. 'i','d','f','s','v','q','w').

    fmt_float ¶

    fmt_float :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune) {…}
     

    Formats a floating-point number with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. v: The floating-point number to format. bit_size: The size of the floating-point number in bits (16, 32, or 64). verb: The format specifier character.

    fmt_int ¶

    fmt_int :: proc(fi: ^Info, u: u64, is_signed: bool, bit_size: int, verb: rune) {…}
     

    Formats an integer value according to the specified formatting verb.

    Inputs:
    fi: A pointer to the Info struct containing formatting options. u: The integer value to be formatted. is_signed: Whether the value should be treated as signed or unsigned. bit_size: The number of bits of the value (e.g. 32, 64). verb: The formatting verb to use (e.g. 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X', 'c', 'r', 'U').

    fmt_int_128 ¶

    fmt_int_128 :: proc(fi: ^Info, u: u128, is_signed: bool, bit_size: int, verb: rune) {…}
     

    Formats an int128 value according to the specified formatting verb.

    Inputs:
    fi: A pointer to the Info struct containing formatting options. u: The int128 value to be formatted. is_signed: Whether the value should be treated as signed or unsigned. bit_size: The number of bits of the value (e.g. 64, 128). verb: The formatting verb to use (e.g. 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X', 'c', 'r', 'U').

    fmt_matrix ¶

    fmt_matrix :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Matrix) {…}
     

    Formats a matrix as a string

    Inputs:
    fi: A pointer to an Info struct containing formatting information. v: The matrix value to be formatted. verb: The formatting verb rune. info: A runtime.Type_Info_Matrix struct containing matrix type information.

    fmt_named ¶

    fmt_named :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Named) {…}
     

    Formats a named type into a string representation

    Inputs:
    fi: Pointer to the formatting Info struct. v: The value to format. verb: The formatting verb. info: The named type information.

    NOTE: This procedure supports built-in custom formatters for core library types such as runtime.Source_Code_Location, time.Duration, and time.Time.

    fmt_pointer ¶

    fmt_pointer :: proc(fi: ^Info, p: rawptr, verb: rune) {…}
     

    Formats a raw pointer with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. p: The raw pointer to format. verb: The format specifier character (e.g. 'p', 'v', 'b', 'o', 'i', 'd', 'z', 'x', 'X').

    fmt_quaternion ¶

    fmt_quaternion :: proc(fi: ^Info, q: quaternion256, bits: int, verb: rune) {…}
     

    Formats a quaternion number based on the given formatting verb

    Inputs:
    fi: A pointer to an Info struct containing formatting information. q: The quaternion256 value to be formatted. bits: The number of bits in the quaternion number (64, 128, or 256). verb: The formatting verb rune ('f', 'F', 'v', 'h', 'H', 'w').

    fmt_rune ¶

    fmt_rune :: proc(fi: ^Info, r: rune, verb: rune) {…}
     

    Formats a rune value according to the specified formatting verb.

    Inputs:
    fi: A pointer to the Info struct containing formatting options. r: The rune value to be formatted. verb: The formatting verb to use (e.g. 'c', 'r', 'v', 'q').

    fmt_soa_pointer ¶

    fmt_soa_pointer :: proc(fi: ^Info, p: runtime.Raw_Soa_Pointer, verb: rune) {…}
     

    Formats a Structure of Arrays (SoA) pointer with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. p: The SoA pointer to format. verb: The format specifier character.

    fmt_string ¶

    fmt_string :: proc(fi: ^Info, s: string, verb: rune) {…}
     

    Formats a string with a specific format.

    Inputs:
    fi: Pointer to the Info struct containing format settings. s: The string to format. verb: The format specifier character (e.g. 's', 'v', 'q', 'x', 'X').

    fmt_struct ¶

    fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_Struct, type_name: string) {…}
     

    Formats a struct for output, handling various struct types (e.g., SOA, raw unions)

    Inputs:
    fi: A mutable pointer to an Info struct containing formatting state v: The value to be formatted the_verb: The formatting verb to be used (e.g. 'v') info: Type information about the struct type_name: The name of the type being formatted

    fmt_union ¶

    fmt_union :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Union, type_size: int) {…}
     

    Formats a union type into a string representation

    Inputs:
    fi: Pointer to the formatting Info struct. v: The value to format. verb: The formatting verb. info: The union type information. type_size: The size of the union type.

    fmt_value ¶

    fmt_value :: proc(fi: ^Info, v: any, verb: rune) {…}
     

    Formats a value based on its type and formatting verb

    Inputs:
    fi: A pointer to an Info struct containing formatting information. v: The value to be formatted. verb: The formatting verb rune.

    NOTE: Uses user formatters if available and not ignored.

    fmt_write_array ¶

    fmt_write_array :: proc(
    	fi:         ^Info, 
    	array_data: rawptr, 
    	count:      int, 
    	elem_size:  int, 
    	elem_id:    typeid, 
    	verb:       rune, 
    ) {…}
     

    Formats an array and writes it to the provided Info structure

    Inputs:
    fi: A pointer to the Info structure where the formatted array will be written. array_data: A raw pointer to the array data. count: The number of elements in the array. elem_size: The size of each element in the array. elem_id: The typeid of the array elements. verb: The formatting verb to be used for the array elements.

    fmt_write_indent ¶

    fmt_write_indent :: proc(fi: ^Info) {…}
     

    Writes the specified number of indents to the provided Info structure

    Inputs:
    fi: A pointer to the Info structure where the indents will be written.

    fmt_write_padding ¶

    fmt_write_padding :: proc(fi: ^Info, width: int) {…}
     

    Writes padding characters for formatting

    Inputs:
    fi: A pointer to an Info structure width: The number of padding characters to write

    fprint ¶

    fprint :: proc(fd: os.Handle, .. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    fprint formats using the default print settings and writes to fd

    fprint_type ¶

    fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info, flush: bool = true) -> (n: int, err: io.Error) {…}

    fprint_typeid ¶

    fprint_typeid :: proc(fd: os.Handle, id: typeid, flush: bool = true) -> (n: int, err: io.Error) {…}

    fprintf ¶

    fprintf :: proc(fd: os.Handle, fmt: string, .. args: ..any, flush: bool = true, newline: bool = false) -> int {…}
     

    fprintf formats according to the specified format string and writes to fd

    fprintfln ¶

    fprintfln :: proc(fd: os.Handle, fmt: string, .. args: ..any, flush: bool = true) -> int {…}
     

    fprintfln formats according to the specified format string and writes to fd, followed by a newline.

    fprintln ¶

    fprintln :: proc(fd: os.Handle, .. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    fprintln formats using the default print settings and writes to fd

    int_from_arg ¶

    int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) {…}
     

    Retrieves an integer from a list of any type at the specified index

    Inputs:
    args: A list of values of any type arg_index: The index to retrieve the integer from

    Returns:
    int: The integer value at the specified index new_arg_index: The new argument index ok: A boolean indicating if the conversion to integer was successful

    panicf ¶

    panicf :: proc(fmt: string, .. args: ..any, loc := #caller_location) -> ! {…}
     

    Runtime panic with a formatted message

    Inputs:
    fmt: A format string with placeholders for the provided arguments args: A variadic list of arguments to be formatted loc: The location of the caller

    print ¶

    print :: proc(.. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    print formats using the default print settings and writes to os.stdout

    printf ¶

    printf :: proc(fmt: string, .. args: ..any, flush: bool = true) -> int {…}
     

    printf formats according to the specified format string and writes to os.stdout

    printfln ¶

    printfln :: proc(fmt: string, .. args: ..any, flush: bool = true) -> int {…}
     

    printfln formats according to the specified format string and writes to os.stdout, followed by a newline.

    println ¶

    println :: proc(.. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    println formats using the default print settings and writes to os.stdout

    register_user_formatter ¶

    register_user_formatter :: proc(id: typeid, formatter: User_Formatter) -> Register_User_Formatter_Error {…}
     

    Registers a user-defined formatter for a specific typeid

    Inputs:
    id: The typeid of the custom type. formatter: The User_Formatter function for the custom type.

    Returns:
    A Register_User_Formatter_Error value indicating the success or failure of the operation.

    WARNING: set_user_formatters must be called before using this procedure.

    sbprint ¶

    sbprint :: proc(buf: ^strings.Builder, .. args: ..any, sep: string = " ") -> string {…}
     

    Formats using the default print settings and writes to the given strings.Builder

    Inputs:
    buf: A pointer to a strings.Builder to store the formatted string args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    A formatted string

    sbprintf ¶

    sbprintf :: proc(buf: ^strings.Builder, fmt: string, .. args: ..any, newline: bool = false) -> string {…}
     

    Formats and writes to a strings.Builder buffer according to the specified format string

    Inputs:
    buf: A pointer to a strings.Builder buffer fmt: The format string args: A variadic list of arguments to be formatted newline: Whether a trailing newline should be written. (See sbprintfln.)

    Returns:
    The resulting formatted string

    sbprintfln ¶

    sbprintfln :: proc(buf: ^strings.Builder, format: string, .. args: ..any) -> string {…}
     

    Formats and writes to a strings.Builder buffer according to the specified format string, followed by a newline.

    Inputs:
    buf: A pointer to a strings.Builder to store the formatted string args: A variadic list of arguments to be formatted

    Returns:
    A formatted string

    sbprintln ¶

    sbprintln :: proc(buf: ^strings.Builder, .. args: ..any, sep: string = " ") -> string {…}
     

    Formats and writes to a strings.Builder buffer using the default print settings

    Inputs:
    buf: A pointer to a strings.Builder buffer args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    The resulting formatted string

    set_user_formatters ¶

    set_user_formatters :: proc(m: ^map[typeid]User_Formatter) {…}
     

    Sets user-defined formatters for custom print formatting of specific types

    Inputs:
    m: A pointer to a map of typeids to User_Formatter structs.

    NOTE: Must be called before using register_user_formatter.

    stored_enum_value_to_string ¶

    stored_enum_value_to_string :: proc(enum_type: ^runtime.Type_Info, ev: runtime.Type_Info_Enum_Value, offset: int = 0) -> (string, bool) {…}
     

    Converts a stored enum value to a string representation

    Inputs:
    enum_type: A pointer to the runtime.Type_Info of the enumeration. ev: The runtime.Type_Info_Enum_Value of the stored enum value. offset: An optional integer to adjust the enumeration value (default is 0).

    Returns:
    A tuple containing the string representation of the enum value and a bool indicating success.

    string_to_enum_value ¶

    string_to_enum_value :: proc($T: typeid, s: string) -> (typeid, bool) {…}
     

    Returns the enum value of a string representation.

    $T: The typeid of the enum type. Inputs: s: The string representation of the enum value.

    Returns:
    The enum value and a boolean indicating success.

    tprint ¶

    tprint :: proc(.. args: ..any, sep: string = " ") -> string {…}
     

    Creates a formatted string

    *Allocates Using Context's Temporary Allocator*
    
    Inputs:
    - args: A variadic list of arguments to be formatted.
    - sep: An optional separator string (default is a single space).
    
    Returns: A formatted string.
    

    tprintf ¶

    tprintf :: proc(fmt: string, .. args: ..any, newline: bool = false) -> string {…}
     

    Creates a formatted string using a format string and arguments

    *Allocates Using Context's Temporary Allocator*
    
    Inputs:
    - fmt: A format string with placeholders for the provided arguments.
    - args: A variadic list of arguments to be formatted.
    - newline: Whether the string should end with a newline. (See `tprintfln`.)
    
    Returns: A formatted string.
    

    tprintfln ¶

    tprintfln :: proc(fmt: string, .. args: ..any) -> string {…}
     

    Creates a formatted string using a format string and arguments, followed by a newline.

    *Allocates Using Context's Temporary Allocator*
    
    Inputs:
    - fmt: A format string with placeholders for the provided arguments.
    - args: A variadic list of arguments to be formatted.
    
    Returns: A formatted string.
    

    tprintln ¶

    tprintln :: proc(.. args: ..any, sep: string = " ") -> string {…}
     

    Creates a formatted string with a newline character at the end

    *Allocates Using Context's Temporary Allocator*
    
    Inputs:
    - args: A variadic list of arguments to be formatted.
    - sep: An optional separator string (default is a single space).
    
    Returns: A formatted string with a newline character at the end.
    

    wprint ¶

    wprint :: proc(w: io.Stream, .. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    Formats and writes to an io.Writer using the default print settings

    Inputs:
    w: An io.Writer to write to args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    The number of bytes written

    wprint_type ¶

    wprint_type :: proc(w: io.Stream, info: ^runtime.Type_Info, flush: bool = true) -> (int, io.Error) {…}
     

    Writes a ^runtime.Type_Info value to an io.Writer

    Inputs:
    w: An io.Writer to write to info: A pointer to a runtime.Type_Info value

    Returns:
    The number of bytes written and an io.Error if encountered

    wprint_typeid ¶

    wprint_typeid :: proc(w: io.Stream, id: typeid, flush: bool = true) -> (int, io.Error) {…}
     

    Writes a typeid value to an io.Writer

    Inputs:
    w: An io.Writer to write to id: A typeid value

    Returns:
    The number of bytes written and an io.Error if encountered

    wprintf ¶

    wprintf :: proc(w: io.Stream, fmt: string, .. args: ..any, flush: bool = true, newline: bool = false) -> int {…}
     

    Formats and writes to an io.Writer according to the specified format string

    Inputs:
    w: An io.Writer to write to fmt: The format string args: A variadic list of arguments to be formatted newline: Whether a trailing newline should be written. (See wprintfln.)

    Returns:
    The number of bytes written

    wprintfln ¶

    wprintfln :: proc(w: io.Stream, format: string, .. args: ..any, flush: bool = true) -> int {…}
     

    Formats and writes to an io.Writer according to the specified format string, followed by a newline.

    Inputs:
    w: The io.Writer to write to. args: A variadic list of arguments to be formatted.

    Returns:
    The number of bytes written.

    wprintln ¶

    wprintln :: proc(w: io.Stream, .. args: ..any, sep: string = " ", flush: bool = true) -> int {…}
     

    Formats and writes to an io.Writer using the default print settings with a newline character at the end

    Inputs:
    w: An io.Writer to write to args: A variadic list of arguments to be formatted sep: An optional separator string (default is a single space)

    Returns:
    The number of bytes written

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-07 (vendor "odin") Windows_amd64 @ 2024-07-18 21:09:42.157067900 +0000 UTC