go: cuelang.org/go/cue/literal Index | Files

package literal

import "cuelang.org/go/cue/literal"

Package literal implements conversions to and from string representations of basic data types.

Index

Package Files

doc.go num.go string.go

Constants

const (
    K   = mulDec | mul1
    M   = mulDec | mul2
    G   = mulDec | mul3
    T   = mulDec | mul4
    P   = mulDec | mul5
    E   = mulDec | mul6
    Z   = mulDec | mul7
    Y   = mulDec | mul8

    Ki  = mulBin | mul1
    Mi  = mulBin | mul2
    Gi  = mulBin | mul3
    Ti  = mulBin | mul4
    Pi  = mulBin | mul5
    Ei  = mulBin | mul6
    Zi  = mulBin | mul7
    Yi  = mulBin | mul8
)

func ParseNum Uses

func ParseNum(s string, n *NumInfo) error

ParseNum parses s and populates NumInfo with the result.

func Unquote Uses

func Unquote(s string) (string, error)

Unquote interprets s as a single- or double-quoted, single- or multi-line string, possibly with custom escape delimiters, returning the string value that s quotes.

type Multiplier Uses

type Multiplier byte

A Multiplier indicates a multiplier indicator used in the literal.

type NumInfo Uses

type NumInfo struct {
    UseSep bool
    // contains filtered or unexported fields
}

NumInfo contains information about a parsed numbers.

Reusing a NumInfo across parses may avoid memory allocations.

func (*NumInfo) Decimal Uses

func (p *NumInfo) Decimal(v *decimal) error

Decimal is for internal use.

func (*NumInfo) IsInt Uses

func (p *NumInfo) IsInt() bool

IsInt reports whether the number is an integral number.

func (*NumInfo) Multiplier Uses

func (p *NumInfo) Multiplier() Multiplier

Multiplier reports which multiplier was used in an integral number.

func (*NumInfo) String Uses

func (p *NumInfo) String() string

String returns a canonical string representation of the number so that it can be parsed with math.Float.Parse.

type QuoteInfo Uses

type QuoteInfo struct {
    // contains filtered or unexported fields
}

QuoteInfo describes the type of quotes used for a string.

func ParseQuotes Uses

func ParseQuotes(start, end string) (q QuoteInfo, nStart, nEnd int, err error)

ParseQuotes checks if the opening quotes in start matches the ending quotes in end and reports its type as q or an error if they do not matching or are invalid. nStart indicates the number of bytes used for the opening quote.

func (QuoteInfo) IsDouble Uses

func (q QuoteInfo) IsDouble() bool

IsDouble reports whether the literal uses double quotes.

func (QuoteInfo) Unquote Uses

func (q QuoteInfo) Unquote(s string) (string, error)

Unquote unquotes the given string. It must be terminated with a quote or an interpolation start. Escape sequences are expanded and surrogates are replaced with the corresponding non-surrogate code points.

Package literal imports 7 packages (graph) and is imported by 14 packages. Updated 2020-07-07. Refresh now. Tools for package owners.