context

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegexpMatchingListenPortValue = `^listen\s*(\d+)\s*\S*$`
	RegexpMatchingServerNameValue = `^server_name\s*(.+)$`
)

Variables

View Source
var (
	ErrIndexOutOfRange             = errors.New("index out of range")
	ErrInsertParserTypeError       = errors.New("insert parser type error")
	ErrInsertIntoErrorContext      = errors.WithCode(code.ErrV3OperationOnErrorContext, "insert context into an error context")
	ErrRemoveFromErrorContext      = errors.WithCode(code.ErrV3OperationOnErrorContext, "remove context from an error context")
	ErrModifyFromErrorContext      = errors.WithCode(code.ErrV3OperationOnErrorContext, "modify context from an error context")
	ErrSetValueToErrorContext      = errors.WithCode(code.ErrV3OperationOnErrorContext, "set value to an error context")
	ErrSetFatherToErrorContext     = errors.WithCode(code.ErrV3OperationOnErrorContext, "set father to an error context")
	ErrGetFatherFromErrorContext   = errors.WithCode(code.ErrV3OperationOnErrorContext, "get father from an error context")
	ErrGetChildFromErrorContext    = errors.WithCode(code.ErrV3OperationOnErrorContext, "get child from an error context")
	ErrParseConfigFromErrorContext = errors.WithCode(code.ErrV3OperationOnErrorContext, "parse config from an error context")
	ErrNullPosition                = errors.WithCode(code.ErrV3NullContextPosition, "null position")

	ErrNullContext = errors.New("null context")
)

Functions

func RegisterContextBuilder

func RegisterContextBuilder()

Types

type AbsConfigPath

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

func (AbsConfigPath) BaseDir

func (a AbsConfigPath) BaseDir() string

func (AbsConfigPath) FullPath

func (a AbsConfigPath) FullPath() string

func (AbsConfigPath) RelativePath

func (a AbsConfigPath) RelativePath() string

type BuildOptions

type BuildOptions struct {
	ContextType context_type.ContextType
	ParseType   ParseType
	HasValue    bool
}

type ConfigGraph

type ConfigGraph interface {
	AddEdge(src, dst ConfigPath) error
	CropOffEde(src, dst ConfigPath)
	MainConfigPath() ConfigPath
}

type ConfigPath

type ConfigPath interface {
	FullPath() string
	BaseDir() string
	RelativePath() string
}

func NewAbsConfigPath

func NewAbsConfigPath(absPath string) (ConfigPath, error)

func NewRelConfigPath

func NewRelConfigPath(dir, file string) (ConfigPath, error)

type Context

type Context interface {
	// write `Context` methods
	Insert(ctx Context, idx int) Context
	Remove(idx int) Context
	Modify(ctx Context, idx int) Context
	// read `Context` methods
	Father() Context
	Child(idx int) Context

	QueryByKeyWords(kw KeyWords) Pos
	QueryAllByKeyWords(kw KeyWords) []Pos

	Clone() Context

	// write methods
	SetValue(v string) error
	SetFather(ctx Context) error
	// read methods
	HasChild() bool
	Len() int
	Value() string
	Type() context_type.ContextType
	Error() error

	// dump
	ConfigLines(isDumping bool) ([]string, error)
}

func ErrContext

func ErrContext(errs ...error) Context

func NullContext

func NullContext() Context

type ContextBuilder

type ContextBuilder interface {
	SetType(contextType context_type.ContextType) ContextBuilder
	SetValue(value string) ContextBuilder
	Build() Context
}

type ErrorContext

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

func (*ErrorContext) AppendError

func (e *ErrorContext) AppendError(err error) Context

func (*ErrorContext) Child

func (e *ErrorContext) Child(idx int) Context

func (*ErrorContext) Clone

func (e *ErrorContext) Clone() Context

func (*ErrorContext) ConfigLines

func (e *ErrorContext) ConfigLines(isDumping bool) ([]string, error)

func (*ErrorContext) Error

func (e *ErrorContext) Error() error

func (*ErrorContext) Father

func (e *ErrorContext) Father() Context

func (*ErrorContext) HasChild

func (e *ErrorContext) HasChild() bool

func (*ErrorContext) Insert

func (e *ErrorContext) Insert(ctx Context, idx int) Context

func (*ErrorContext) Len

func (e *ErrorContext) Len() int

func (*ErrorContext) Modify

func (e *ErrorContext) Modify(ctx Context, idx int) Context

func (*ErrorContext) QueryAllByKeyWords

func (e *ErrorContext) QueryAllByKeyWords(kw KeyWords) []Pos

func (*ErrorContext) QueryByKeyWords

func (e *ErrorContext) QueryByKeyWords(kw KeyWords) Pos

func (*ErrorContext) Remove

func (e *ErrorContext) Remove(idx int) Context

func (*ErrorContext) SetFather

func (e *ErrorContext) SetFather(ctx Context) error

func (*ErrorContext) SetValue

func (e *ErrorContext) SetValue(v string) error

func (*ErrorContext) Type

func (*ErrorContext) Value

func (e *ErrorContext) Value() string

type KeyWords

type KeyWords interface {
	Match(ctx Context) bool
	Cascaded() bool
	SetCascaded(cascaded bool) KeyWords
	SetStringMatchingValue(value string) KeyWords
	SetRegexpMatchingValue(value string) KeyWords
}

func NewKeyWords

func NewKeyWords(ctxtype context_type.ContextType) KeyWords

type ParseType

type ParseType int
const (
	ParseConfig ParseType = iota
	ParseContext
	ParseDirective
	ParseComment
)

type Pos

type Pos interface {
	Position() (Context, int)
	Target() Context
}

func NotFoundPos

func NotFoundPos() Pos

func NullPos

func NullPos() Pos

func SetPos

func SetPos(father Context, posIdx int) Pos

type RelConfigPath

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

func (RelConfigPath) BaseDir

func (c RelConfigPath) BaseDir() string

func (RelConfigPath) FullPath

func (c RelConfigPath) FullPath() string

func (RelConfigPath) RelativePath

func (c RelConfigPath) RelativePath() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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