conf

package
v1.3.24 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package conf implements parse the ksf config. Usage: After initialization, use obj.GetXXX("/ksf/db<ip>") to get the corresponding data structure.

Index

Constants

View Source
const (
	// Node shows an element is a node
	Node = iota
	// Leaf shows an element is a leaf
	Leaf
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

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

Conf struct for parse xml-like ksf config file.

func New

func New() *Conf

New returns a new Conf struct.

func NewConf

func NewConf(fileName string) (*Conf, error)

NewConf returns a new Conf with the fileName

func (*Conf) GetBoolWithDef

func (c *Conf) GetBoolWithDef(path string, defVal bool) bool

GetBoolWithDef get bool value

func (*Conf) GetDomain

func (c *Conf) GetDomain(path string) []string

GetDomain returns the domain for pointed path

func (*Conf) GetDomainKey

func (c *Conf) GetDomainKey(path string) []string

GetDomainKey returns the domain for pointed path

func (*Conf) GetDomainLine

func (c *Conf) GetDomainLine(path string) []string

GetDomainLine returns the domain for pointed path

func (*Conf) GetFloatWithDef

func (c *Conf) GetFloatWithDef(path string, defVal float64) float64

GetFloatWithDef get float value

func (*Conf) GetInt

func (c *Conf) GetInt(path string) int

GetInt returns the value as an integer for pointed path

func (*Conf) GetInt32WithDef

func (c *Conf) GetInt32WithDef(path string, defVal int32) int32

GetInt32WithDef get int32 value

func (*Conf) GetIntWithDef

func (c *Conf) GetIntWithDef(path string, defVal int) int

GetIntWithDef returns the value as an integer for pointed path, or a default value when error happens

func (*Conf) GetMap

func (c *Conf) GetMap(path string) map[string]string

GetMap returns the key-value as a map for pointed path

func (*Conf) GetString

func (c *Conf) GetString(path string) string

GetString returns the value for pointed path

func (*Conf) GetStringWithDef

func (c *Conf) GetStringWithDef(path string, defVal string) string

GetStringWithDef returns the value for pointed path, or a default value when error happens

func (*Conf) InitFromBytes

func (c *Conf) InitFromBytes(content []byte) error

InitFromBytes returns error when init config from bytes

func (*Conf) InitFromFile

func (c *Conf) InitFromFile(fileName string) error

InitFromFile returns error when init config from a file

func (*Conf) InitFromString

func (c *Conf) InitFromString(content string) error

InitFromString returns error when init config from a string

func (*Conf) ToString

func (c *Conf) ToString() string

ToString returns the config as a string

Jump to

Keyboard shortcuts

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