parser

package
v0.0.0-...-95e2e8c Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(parsers List) error

func Compare

func Compare(a interface{}, b interface{}) (*bool, error)

Compares two values outputted by the parsers returns nil if a = b, true if a < b, false if a > b

Types

type Boolean

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

func NewBoolean

func NewBoolean(
	config *BooleanConfig,
) *Boolean

func (*Boolean) GetRegexpPattern

func (boolean *Boolean) GetRegexpPattern() string

func (*Boolean) Name

func (boolean *Boolean) Name() string

func (*Boolean) Parse

func (boolean *Boolean) Parse(value string) (interface{}, error)

func (*Boolean) Primitive

func (boolean *Boolean) Primitive() bool

type BooleanConfig

type BooleanConfig struct {
	Name        string   `yaml:"name"`
	Type        string   `yaml:"type"`
	TrueValues  []string `yaml:"trueValues"`
	FalseValues []string `yaml:"falseValues"`
	Logger      *logrus.Entry
}

func (*BooleanConfig) GetName

func (config *BooleanConfig) GetName() string

func (*BooleanConfig) Primitive

func (config *BooleanConfig) Primitive() bool

func (*BooleanConfig) Validate

func (config *BooleanConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

type Config

type Config interface {
	Validate(parsers map[string]Config, log *logrus.Entry) error
	GetName() string
	Primitive() bool
}

type Float

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

func NewFloat

func NewFloat(
	config *FloatConfig,
) *Float

func (*Float) GetRegexpPattern

func (float *Float) GetRegexpPattern() string

func (*Float) Name

func (float *Float) Name() string

func (*Float) Parse

func (float *Float) Parse(value string) (interface{}, error)

func (*Float) Primitive

func (float *Float) Primitive() bool

type FloatConfig

type FloatConfig struct {
	Name             string `yaml:"name"`
	Type             string `yaml:"type"`
	DecimalSeparator string `yaml:"decimalSeparator"`
	IgnoreCharacters string `yaml:"ignoreCharacters"`
	Logger           *logrus.Entry
}

func (*FloatConfig) GetName

func (config *FloatConfig) GetName() string

func (*FloatConfig) Primitive

func (config *FloatConfig) Primitive() bool

func (*FloatConfig) Validate

func (config *FloatConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

type Integer

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

func NewInteger

func NewInteger(
	config *IntegerConfig,
) *Integer

func (*Integer) GetRegexpPattern

func (integer *Integer) GetRegexpPattern() string

func (*Integer) Name

func (integer *Integer) Name() string

func (*Integer) Parse

func (integer *Integer) Parse(value string) (interface{}, error)

func (*Integer) Primitive

func (integer *Integer) Primitive() bool

type IntegerConfig

type IntegerConfig struct {
	Name             string `yaml:"name"`
	Type             string `yaml:"type"`
	IgnoreCharacters string `yaml:"ignoreCharacters"`
	Logger           *logrus.Entry
}

func (*IntegerConfig) GetName

func (config *IntegerConfig) GetName() string

func (*IntegerConfig) Primitive

func (config *IntegerConfig) Primitive() bool

func (*IntegerConfig) Validate

func (config *IntegerConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

type Json

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

func NewJson

func NewJson(
	config *JsonConfig,
) *Json

func (*Json) GetRegexpPattern

func (json *Json) GetRegexpPattern() string

func (*Json) Name

func (json *Json) Name() string

func (*Json) Parse

func (json *Json) Parse(value string) (interface{}, error)

func (*Json) Primitive

func (json *Json) Primitive() bool

type JsonConfig

type JsonConfig struct {
	Name   string `yaml:"name"`
	Type   string `yaml:"type"`
	Logger *logrus.Entry
}

func (*JsonConfig) GetName

func (config *JsonConfig) GetName() string

func (*JsonConfig) Primitive

func (config *JsonConfig) Primitive() bool

func (*JsonConfig) Validate

func (config *JsonConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

type List

type List = map[string]Parser

func NewFromConfigs

func NewFromConfigs(
	configs map[string]Config,
) (List, error)

type Mock

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

func NewMock

func NewMock() *Mock

func NewMockWithPrefix

func NewMockWithPrefix(prefix string) *Mock

func (*Mock) GetRegexpPattern

func (mock *Mock) GetRegexpPattern() string

func (*Mock) Name

func (mock *Mock) Name() string

func (*Mock) Parse

func (mock *Mock) Parse(value string) (interface{}, error)

func (*Mock) Primitive

func (mock *Mock) Primitive() bool

type Parser

type Parser interface {
	Name() string
	GetRegexpPattern() string
	Primitive() bool
	Parse(value string) (interface{}, error)
}

func NewFromConfig

func NewFromConfig(
	config Config,
	parsers List,
) (Parser, error)

type Split

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

func NewSplit

func NewSplit(
	config *SplitConfig,
	parsers List,
) *Split

func (*Split) GetRegexpPattern

func (split *Split) GetRegexpPattern() string

func (*Split) Name

func (split *Split) Name() string

func (*Split) Parse

func (split *Split) Parse(value string) (interface{}, error)

func (*Split) Primitive

func (split *Split) Primitive() bool

type SplitConfig

type SplitConfig struct {
	Name              string  `yaml:"name"`
	Type              string  `yaml:"type"`
	Delimiter         *string `yaml:"delimiter"`
	DelimiterIsRegexp *bool   `yaml:"delimiterIsRegexp"`
	Parser            string  `yaml:"parser"`
	Logger            *logrus.Entry
	DelimiterRegexp   *regexp.Regexp
}

func (*SplitConfig) GetDelimiter

func (config *SplitConfig) GetDelimiter() string

func (*SplitConfig) GetName

func (config *SplitConfig) GetName() string

func (*SplitConfig) IsDelimiterARegexp

func (config *SplitConfig) IsDelimiterARegexp() bool

func (*SplitConfig) Primitive

func (config *SplitConfig) Primitive() bool

func (*SplitConfig) Validate

func (config *SplitConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

type String

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

func NewString

func NewString(
	config *StringConfig,
) (*String, error)

func (*String) GetRegexpPattern

func (str *String) GetRegexpPattern() string

func (*String) Name

func (str *String) Name() string

func (*String) Parse

func (str *String) Parse(value string) (interface{}, error)

func (*String) Primitive

func (str *String) Primitive() bool

type StringConfig

type StringConfig struct {
	Name               string `yaml:"name"`
	Type               string `yaml:"type"`
	ConvertFromCharset string `yaml:"convertFromCharset"`
	Logger             *logrus.Entry
}

func (*StringConfig) GetName

func (config *StringConfig) GetName() string

func (*StringConfig) Primitive

func (config *StringConfig) Primitive() bool

func (*StringConfig) Validate

func (config *StringConfig) Validate(parsers map[string]Config, log *logrus.Entry) error

Jump to

Keyboard shortcuts

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