parser

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DelimiterChars = []string{"\t", "\n", " ", "\r"}

Functions

This section is empty.

Types

type ErrEmptyValue

type ErrEmptyValue struct{}

func (*ErrEmptyValue) Error

func (e *ErrEmptyValue) Error() string

type ErrValueType

type ErrValueType struct{}

func (*ErrValueType) Error

func (e *ErrValueType) Error() string

type LstParser

type LstParser struct {
	*Parser
	// contains filtered or unexported fields
}

func NewLstParser

func NewLstParser(content string) *LstParser

func (*LstParser) AddPath

func (p *LstParser) AddPath(idx int, path string) error

func (*LstParser) DelPath

func (p *LstParser) DelPath(idx int)

func (*LstParser) GetPath

func (p *LstParser) GetPath(idx int) string

func (*LstParser) GetPathMap

func (p *LstParser) GetPathMap() map[int]string

func (*LstParser) Render

func (p *LstParser) Render() string

type Parser

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

func NewParser

func NewParser(content string) *Parser

func (*Parser) AddAny

func (p *Parser) AddAny(key string, value []*Token, isClosed ...bool)

func (*Parser) DelKey

func (p *Parser) DelKey(key string)

func (*Parser) GetAny

func (p *Parser) GetAny(key string) *TokenValue

func (*Parser) GetFloat added in v1.0.2

func (p *Parser) GetFloat(key string) (float64, error)

func (*Parser) GetInt

func (p *Parser) GetInt(key string) (int, error)

func (*Parser) GetInts

func (p *Parser) GetInts(key string) ([]int, error)

func (*Parser) GetString

func (p *Parser) GetString(key string) (string, error)

func (*Parser) GetStrings

func (p *Parser) GetStrings(key string) ([]string, error)

func (*Parser) Render

func (p *Parser) Render() string

func (*Parser) SetAny

func (p *Parser) SetAny(key string, value []*Token, isClosed ...bool)

func (*Parser) SetFloat added in v1.0.2

func (p *Parser) SetFloat(key string, value float64, isClosed ...bool)

func (*Parser) SetInt

func (p *Parser) SetInt(key string, value int, isClosed ...bool)

func (*Parser) SetInts

func (p *Parser) SetInts(key string, value []int, isClosed ...bool)

func (*Parser) SetString

func (p *Parser) SetString(key, value string, isClosed ...bool)

func (*Parser) SetStrings

func (p *Parser) SetStrings(key string, value []string, isClosed ...bool)

type Token

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

func GenTokenList

func GenTokenList(val ...any) []*Token

func GenTokens

func GenTokens(val any) []*Token

func NewDelimiterToken

func NewDelimiterToken(c string) *Token

func NewRawContentToken added in v1.0.4

func NewRawContentToken(c string) *Token

func (*Token) Clear

func (t *Token) Clear()

func (*Token) Copy

func (t *Token) Copy() *Token

func (*Token) GetFloat added in v1.0.2

func (t *Token) GetFloat() float64

func (*Token) GetInt added in v1.0.2

func (t *Token) GetInt() int

func (*Token) IsCloseKey

func (t *Token) IsCloseKey() bool

func (*Token) IsCloseKeyBy

func (t *Token) IsCloseKeyBy(key string) bool

func (*Token) IsDelimiter

func (t *Token) IsDelimiter() bool

func (*Token) IsFloat added in v1.0.3

func (t *Token) IsFloat() bool

func (*Token) IsInt added in v1.0.3

func (t *Token) IsInt() bool

func (*Token) IsKey

func (t *Token) IsKey() bool

func (*Token) IsString

func (t *Token) IsString() bool

func (*Token) RawContent

func (t *Token) RawContent() string

func (*Token) Render

func (t *Token) Render() string

Render 渲染成文本

func (*Token) String

func (t *Token) String() string

func (*Token) Type

func (t *Token) Type() TokenType

type TokenType

type TokenType int
const (
	TokenNone   TokenType = iota
	TokenIgnore           // 注释
	TokenKey
	TokenString
	TokenInt
	TokenFloat
	TokenDelimiter
	TokenRawContent
)

type TokenValue

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

func NewTokenValue

func NewTokenValue(tokens []*Token) *TokenValue

func (*TokenValue) GetCleanTokens

func (tv *TokenValue) GetCleanTokens() []*Token

func (*TokenValue) GetFloat added in v1.0.2

func (tv *TokenValue) GetFloat() (float64, error)

func (*TokenValue) GetFloats added in v1.0.2

func (tv *TokenValue) GetFloats() ([]float64, error)

func (*TokenValue) GetFull

func (tv *TokenValue) GetFull() []*Token

func (*TokenValue) GetInt

func (tv *TokenValue) GetInt() (int, error)

func (*TokenValue) GetInts

func (tv *TokenValue) GetInts() ([]int, error)

func (*TokenValue) GetString

func (tv *TokenValue) GetString() (string, error)

func (*TokenValue) GetStrings

func (tv *TokenValue) GetStrings() ([]string, error)

func (*TokenValue) GetSub

func (tv *TokenValue) GetSub(key string) *TokenValue

func (*TokenValue) ReplaceValue

func (tv *TokenValue) ReplaceValue(tokens []*Token)

func (*TokenValue) SetSub

func (tv *TokenValue) SetSub(key string, values []*Token, isClosed ...bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL