Documentation
¶
Overview ¶
Package comdef provide some common type or constant definitions
Index ¶
- Constants
- Variables
- type Align
- type AnyMap
- type BaseFormatter
- type ByteStringWriter
- type Codec
- type Compared
- type DataFormatter
- type Errors
- type Float
- type Float64able
- type GoSerializer
- type Int
- type Int64able
- type IntCheckFunc
- type IntOrFloat
- type Integer
- type L2StrMap
- type MapFunc
- type MarshalFunc
- type MatchFunc
- type Matcher
- type Number
- type NumberOrString
- type Position
- type SafeStringFunc
- type ScalarType
- type Serializer
- type SimpleType
- type SortedType
- type StrCheckFunc
- type StrMap
- type StringHandleFunc
- type StringHandler
- type StringMatchFunc
- type StringMatcher
- type StringWriteStringer
- type ToStringFunc
- type ToTypeFunc
- type Uint
- type UnmarshalFunc
- type Xint
- type XintOrFloatdeprecated
Constants ¶
const ( OpEq = "=" OpNeq = "!=" OpLt = "<" OpLte = "<=" OpGt = ">" OpGte = ">=" )
constants for compare operation
const ( SingleQuote = '\'' DoubleQuote = '"' SlashQuote = '\\' SingleQuoteStr = "'" DoubleQuoteStr = `"` SlashQuoteStr = "\\" )
constants quote chars
const ( // CommaStr const define CommaStr = "," // CommaChar define CommaChar = ',' // EqualStr define EqualStr = "=" // EqualChar define EqualChar = '=' // ColonStr define ColonStr = ":" // ColonChar define ColonChar = ':' // SemicolonStr semicolon define SemicolonStr = ";" // SemicolonChar define SemicolonChar = ';' // PathStr define const PathStr = "/" // PathChar define PathChar = '/' // DefaultSep comma string DefaultSep = "," // SpaceChar char SpaceChar = ' ' // SpaceStr string SpaceStr = " " // NewlineChar char NewlineChar = '\n' // NewlineStr string NewlineStr = "\n" )
const Newline = "\n"
Newline string for non-windows
const NoIdx = -1
NoIdx invalid index or length
Variables ¶
var ErrConvType = errors.New("convert value type error")
ErrConvType error
Functions ¶
This section is empty.
Types ¶
type BaseFormatter ¶
type BaseFormatter struct {
// Out formatted to the writer
Out io.Writer
// Src data(array, map, struct) for format
Src any
// MaxDepth limit depth for array, map data TODO
MaxDepth int
// Prefix string for each element
Prefix string
// Indent string for format each element
Indent string
// ClosePrefix string for last "]", "}"
ClosePrefix string
// contains filtered or unexported fields
}
BaseFormatter struct
Usage:
type YourFormatter struct {
comdef.BaseFormatter
}
// implement the DataFormatter interface...
func (*BaseFormatter) BsWriter ¶
func (f *BaseFormatter) BsWriter() ByteStringWriter
BsWriter warp the Out, build a ByteStringWriter
type ByteStringWriter ¶
type ByteStringWriter interface {
io.Writer
io.ByteWriter
io.StringWriter
fmt.Stringer
}
ByteStringWriter interface
type Codec ¶ added in v0.7.0
type Codec interface {
Decode(blob []byte, v any) (err error)
Encode(v any) (out []byte, err error)
}
Codec interface definition
type Compared ¶ added in v0.6.11
Compared type. alias of constraints.SortedType
TODO: use type alias, will error on go1.18 Error: types.go:50: interface contains type constraints type Compared = SortedType
type DataFormatter ¶
DataFormatter interface
type Float64able ¶ added in v0.6.15
Float64able interface
type GoSerializer ¶ added in v0.7.0
GoSerializer interface definition
type IntOrFloat ¶ added in v0.6.0
IntOrFloat interface type. all int and float types, but NOT uint types
type NumberOrString ¶ added in v0.7.0
NumberOrString interface type for (x)int, float, ~string types
type SafeStringFunc ¶ added in v0.6.12
SafeStringFunc safe convert value to string
type ScalarType ¶ added in v0.6.0
ScalarType basic interface type.
TIP: has bool type, it cannot be ordered
contains: (x)int, float, ~string, ~bool types
type Serializer ¶ added in v0.7.0
type Serializer interface {
Serialize(v any) ([]byte, error)
Deserialize(data []byte, v any) error
}
Serializer interface definition
type SimpleType ¶ added in v0.6.11
SimpleType interface type. alias of ScalarType
contains: (x)int, float, ~string, ~bool types
type SortedType ¶ added in v0.6.2
SortedType interface type. same of constraints.Ordered
it can be ordered, that supports the operators < <= >= >.
contains: (x)int, float, ~string types
type StrCheckFunc ¶ added in v0.6.11
StrCheckFunc check func
type StringHandleFunc ¶ added in v0.6.11
StringHandleFunc definition
func (StringHandleFunc) Handle ¶ added in v0.6.11
func (fn StringHandleFunc) Handle(s string) string
Handle satisfies the StringHandler interface
type StringHandler ¶ added in v0.6.11
StringHandler interface
type StringMatchFunc ¶ added in v0.6.10
StringMatchFunc definition
func (StringMatchFunc) Match ¶ added in v0.6.10
func (fn StringMatchFunc) Match(s string) bool
Match satisfies the StringMatcher interface
type StringMatcher ¶ added in v0.6.10
StringMatcher interface
type StringWriteStringer ¶
type StringWriteStringer interface {
io.StringWriter
fmt.Stringer
}
StringWriteStringer interface
type ToStringFunc ¶ added in v0.6.12
ToStringFunc try to convert value to string, return error on fail
type ToTypeFunc ¶ added in v0.6.15
ToTypeFunc convert value to defined type