XU XUv0.13.1
中文

#encoding/toml

import: #encoding/toml

counts: 1 functions, 8 methods, 2 types, 5 constants, 0 method sets

`github.com/pelletier/-toml`: TOML document parser and query model. Parses key-value pairs, tables ([table]), comments (#...), strings, numbers, and booleans into a queryable Doc DOM.

const TYPE_NULL

XuAPI
pub const TYPE_NULL = 0

Purpose

Constant TYPE_NULL, defining protocol or algorithm parameters.

const TYPE_BOOL

XuAPI
pub const TYPE_BOOL = 1

Purpose

Constant TYPE_BOOL, defining protocol or algorithm parameters.

const TYPE_INT

XuAPI
pub const TYPE_INT = 2

Purpose

Constant TYPE_INT, defining protocol or algorithm parameters.

const TYPE_STRING

XuAPI
pub const TYPE_STRING = 3

Purpose

Constant TYPE_STRING, defining protocol or algorithm parameters.

const TYPE_TABLE

XuAPI
pub const TYPE_TABLE = 4

Purpose

Constant TYPE_TABLE, defining protocol or algorithm parameters.

struct Item

XuAPI
pub struct Item {
    pub key string
    pub val string
    pub val_type int
    pub table string
    pub index int
}

Purpose

Structure encapsulating key, val, val_type, table, index.

Public fields

key string
key
val string
value
val_type int
field (int)
table string
field (string)
index int
field (int)

struct Doc

XuAPI
pub struct Doc {
    pub items []Item
}

Purpose

Structure encapsulating items.

Public fields

items []Item
items

parse

XuAPI
pub fn parse(src &string) Doc

Purpose

Parse the input.

Parameters

src &string
source (read-only borrow; caller keeps the original; type &string)

Returns

Doc — a value of this type

(&Doc) get

XuAPI
pub fn (d &Doc) get(key &string) string

Purpose

Execute get on &Doc.

Parameters

d &Doc
The Doc instance used by this call (borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&Doc) get_in

XuAPI
pub fn (d &Doc) get_in(table &string, key &string) string

Purpose

Operation on &Doc: read in.

Parameters

d &Doc
The Doc instance used by this call (borrow).
table &string
table (read-only borrow; caller keeps the original; type &string)
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&Doc) array_len

XuAPI
pub fn (d &Doc) array_len(table &string) int

Purpose

array_len counts [[table]] elements up to the last one holding a key.

Parameters

d &Doc
The Doc instance used by this call (borrow).
table &string
table (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&Doc) get_at

XuAPI
pub fn (d &Doc) get_at(table &string, index int, key &string) string

Purpose

Operation on &Doc: read at.

Parameters

d &Doc
The Doc instance used by this call (borrow).
table &string
table (read-only borrow; caller keeps the original; type &string)
index int
index (int)
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&Doc) has

XuAPI
pub fn (d &Doc) has(key &string) bool

Purpose

Execute has on &Doc.

Parameters

d &Doc
The Doc instance used by this call (borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

(&Doc) get_int

XuAPI
pub fn (d &Doc) get_int(key &string) int

Purpose

Operation on &Doc: read int.

Parameters

d &Doc
The Doc instance used by this call (borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&Doc) get_bool

XuAPI
pub fn (d &Doc) get_bool(key &string) bool

Purpose

Operation on &Doc: read bool.

Parameters

d &Doc
The Doc instance used by this call (borrow).
key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

bool — true or false

(&Doc) tables

XuAPI
pub fn (d &Doc) tables() []string

Purpose

Execute tables on &Doc.

Parameters

d &Doc
The Doc instance used by this call (borrow).

Returns

[]string — slice result