Documentation ¶
Index ¶
- Constants
- type Bool
- type BoolType
- type ComputedBy
- type DbStore
- type Definition
- type Definitions
- type EnumType
- type Field
- type NamedType
- type Number
- func NewNumberFromFloat32(num float32) *Number
- func NewNumberFromFloat64(num float64) *Number
- func NewNumberFromInt(num int) *Number
- func NewNumberFromInt16(num int16) *Number
- func NewNumberFromInt32(num int32) *Number
- func NewNumberFromInt64(num int64) *Number
- func NewNumberFromInt8(num int8) *Number
- func NewNumberFromString(value string) (*Number, error)
- func NewNumberFromUint(num uint) *Number
- func NewNumberFromUint16(num uint16) *Number
- func NewNumberFromUint32(num uint32) *Number
- func NewNumberFromUint8(num uint8) *Number
- func (left *Number) Div(right *Number, mode RoundingMode, scale int) *Number
- func (value *Number) Equal(that Value) bool
- func (left *Number) GreaterThan(right *Number) bool
- func (left *Number) GreaterThanOrEqual(right *Number) bool
- func (left *Number) LessThan(right *Number) bool
- func (left *Number) LessThanOrEqual(right *Number) bool
- func (left *Number) Minus(right *Number) *Number
- func (left *Number) Mult(right *Number) *Number
- func (left *Number) Plus(right *Number) *Number
- func (value *Number) Round(mode RoundingMode, scale int) *Number
- func (value *Number) String() string
- func (value *Number) Type() Type
- type NumberType
- type Options
- type RoundingMode
- type Session
- func (s *Session) Edit(editId string) (time.Time, map[string]int, error)
- func (s *Session) EditContext(ctx context.Context, editId string) (time.Time, map[string]int, error)
- func (s *Session) Load(id string) (*Worksheet, error)
- func (s *Session) LoadContext(ctx context.Context, id string) (*Worksheet, error)
- func (s *Session) Save(ws *Worksheet) (string, error)
- func (s *Session) SaveContext(ctx context.Context, ws *Worksheet) (string, error)
- func (s *Session) SaveOrUpdate(ws *Worksheet) (string, error)
- func (s *Session) SaveOrUpdateContext(ctx context.Context, ws *Worksheet) (string, error)
- func (s *Session) Update(ws *Worksheet) (string, error)
- func (s *Session) UpdateContext(ctx context.Context, ws *Worksheet) (string, error)
- type Slice
- type SliceType
- type Store
- type StructScanner
- type Text
- type TextType
- type Type
- type Undefined
- type UndefinedType
- type Value
- type Worksheet
- func (ws *Worksheet) Append(name string, element Value) error
- func (ws *Worksheet) Clone() *Worksheet
- func (ws *Worksheet) Del(name string, index int) error
- func (ws *Worksheet) Equal(that Value) bool
- func (ws *Worksheet) Get(name string) (Value, error)
- func (ws *Worksheet) GetSlice(name string) ([]Value, error)
- func (ws *Worksheet) Id() string
- func (ws *Worksheet) IsSet(name string) (bool, error)
- func (ws *Worksheet) MarshalJSON() ([]byte, error)
- func (ws *Worksheet) MustAppend(name string, value Value)
- func (ws *Worksheet) MustDel(name string, index int)
- func (ws *Worksheet) MustGet(name string) Value
- func (ws *Worksheet) MustGetSlice(name string) []Value
- func (ws *Worksheet) MustIsSet(name string) bool
- func (ws *Worksheet) MustSet(name string, value Value)
- func (ws *Worksheet) MustUnset(name string)
- func (ws *Worksheet) Name() string
- func (ws *Worksheet) Set(name string, value Value) error
- func (ws *Worksheet) String() string
- func (ws *Worksheet) StructScan(dest interface{}) error
- func (ws *Worksheet) Type() Type
- func (ws *Worksheet) Unset(name string) error
- func (ws *Worksheet) Version() int
- type WorksheetConverter
Constants ¶
const ( ModeUp RoundingMode = "up" ModeDown = "down" ModeHalf = "half" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents a boolean.
type ComputedBy ¶
type DbStore ¶
type DbStore struct {
// contains filtered or unexported fields
}
func NewStore ¶
func NewStore(defs *Definitions) *DbStore
type Definition ¶
type Definition struct {
// contains filtered or unexported fields
}
func (*Definition) FieldByName ¶
func (def *Definition) FieldByName(name string) *Field
func (*Definition) Fields ¶
func (def *Definition) Fields() []*Field
func (*Definition) Name ¶
func (def *Definition) Name() string
func (*Definition) String ¶
func (def *Definition) String() string
type Definitions ¶
type Definitions struct {
// contains filtered or unexported fields
}
Definitions groups all definitions for a workbook, which may consists of multiple worksheet definitions, custom types, etc.
func MustNewDefinitions ¶
func MustNewDefinitions(reader io.Reader, opts ...Options) *Definitions
func NewDefinitions ¶
func NewDefinitions(reader io.Reader, opts ...Options) (*Definitions, error)
NewDefinitions parses one or more worksheet definitions, and creates worksheet models from them.
func (*Definitions) MustNewWorksheet ¶
func (defs *Definitions) MustNewWorksheet(name string) *Worksheet
func (*Definitions) NewWorksheet ¶
func (defs *Definitions) NewWorksheet(name string) (*Worksheet, error)
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) IsComputedBy ¶
type NamedType ¶
NamedType represents types which are uniquely identified by their names, such worksheet types, or enums.
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
Number represents a fixed decimal number.
func NewNumberFromFloat32 ¶
NewNumberFromFloat32 returns a new Number from float32.
func NewNumberFromFloat64 ¶
NewNumberFromFloat64 returns a new Number from float64.
func NewNumberFromInt ¶
NewNumberFromInt returns a new Number from int.
func NewNumberFromInt16 ¶
NewNumberFromInt16 returns a new Number from int16.
func NewNumberFromInt32 ¶
NewNumberFromInt32 returns a new Number from int32.
func NewNumberFromInt64 ¶
NewNumberFromInt64 returns a new Number from int64.
func NewNumberFromInt8 ¶
NewNumberFromInt8 returns a new Number from int8.
func NewNumberFromString ¶
NewNumberFromString returns a new Number from a string representation.
func NewNumberFromUint ¶
NewNumberFromUint returns a new Number from uint.
func NewNumberFromUint16 ¶
NewNumberFromUint16 returns a new Number from uint16.
func NewNumberFromUint32 ¶
NewNumberFromUint32 returns a new Number from uint32.
func NewNumberFromUint8 ¶
NewNumberFromUint8 returns a new Number from uint8.
func (*Number) GreaterThan ¶
func (*Number) GreaterThanOrEqual ¶
func (*Number) LessThanOrEqual ¶
type NumberType ¶
type NumberType struct {
// contains filtered or unexported fields
}
func (*NumberType) Scale ¶
func (t *NumberType) Scale() int
func (*NumberType) String ¶
func (typ *NumberType) String() string
type Options ¶
type Options struct { // Plugins is a map of workshet names, to field names, to plugins for // externally computed fields. Plugins map[string]map[string]ComputedBy }
type RoundingMode ¶
type RoundingMode string
RoundingMode describes the rounding mode to be used in an operation.
type Session ¶
type Session struct { *DbStore // contains filtered or unexported fields }
Session is the ... TODO(pascal): write
func (*Session) EditContext ¶ added in v1.2.0
func (*Session) LoadContext ¶ added in v1.2.0
func (*Session) SaveContext ¶ added in v1.2.0
func (*Session) SaveOrUpdateContext ¶ added in v1.2.0
type SliceType ¶
type SliceType struct {
// contains filtered or unexported fields
}
func (*SliceType) ElementType ¶
type Store ¶
type Store interface { // Load loads the worksheet with identifier `id` from the store. Load(id string) (*Worksheet, error) LoadContext(ctx context.Context, id string) (*Worksheet, error) // SaveOrUpdate saves or updates a worksheet to the store. On success, // returns an edit identifier. SaveOrUpdate(ws *Worksheet) (string, error) SaveOrUpdateContext(ctx context.Context, ws *Worksheet) (string, error) // Save saves a new worksheet to the store. On success, returns an edit // identifier. Save(ws *Worksheet) (string, error) SaveContext(ctx context.Context, ws *Worksheet) (string, error) // Update updates an existing worksheet in the store. On success, returns an // edit identifier. Update(ws *Worksheet) (string, error) UpdateContext(ctx context.Context, ws *Worksheet) (string, error) // Edit returns a specific edit, the time at which the edit occurred, and all // worksheets modified as a map of their ids to the resulting version. Edit(editId string) (time.Time, map[string]int, error) EditContext(ctx context.Context, editId string) (time.Time, map[string]int, error) }
Store ... TODO(pascal): write about abstraction.
type StructScanner ¶
type StructScanner struct { AllowUndefinedToNonPointer bool // relax conversion, can populate with zero value // contains filtered or unexported fields }
StructScanner stores state allowing overrides for scanning of registered types.
func NewStructScanner ¶
func NewStructScanner() *StructScanner
func (*StructScanner) RegisterConverter ¶
func (ss *StructScanner) RegisterConverter(t reflect.Type, converterFn func(Value) (interface{}, error))
func (*StructScanner) StructScan ¶
func (ss *StructScanner) StructScan(ws *Worksheet, dest interface{}) error
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text represents a string.
type Type ¶
type Type interface { // String returns a string representation of the type. String() string // contains filtered or unexported methods }
Type represents the type of a value.
type UndefinedType ¶
type UndefinedType struct{}
func (*UndefinedType) String ¶
func (typ *UndefinedType) String() string
type Value ¶
type Value interface { // Type returns this value's type. Type() Type // Equal returns whether this value is equal to that value. Value equality // is defined by 'being the same value' inasmuch that you can replace this // value in an expression by that value, and have the same result. // // One could formally define equality by saying that any expression with a // hole E[?] would evaluate to the same value with E[this] or E[that]. Equal(that Value) bool // String returns a string representation of the value. String() string // contains filtered or unexported methods }
Value represents a runtime value.
func MustNewValue ¶
func NewUndefined ¶
func NewUndefined() Value
type Worksheet ¶
type Worksheet struct {
// contains filtered or unexported fields
}
Worksheet is ... TODO(pascal): documentation binge
func (*Worksheet) Clone ¶
Clone duplicates this worksheet, and all worksheets it points to, in order to create a deep-copy.
func (*Worksheet) Get ¶
Get gets a value for base types, e.g. text, number, or bool. For other kinds of values, use specific getters such as `GetSlice`.
func (*Worksheet) MarshalJSON ¶
func (*Worksheet) MustAppend ¶
func (*Worksheet) MustGetSlice ¶
func (*Worksheet) StructScan ¶
type WorksheetConverter ¶
type WorksheetConverter interface { // WorksheetConvert assigns a value from a worksheet field. // // The src value can be any defined worksheet value, e.g. text, bool, // number[n], or even a worksheet value. // // An error should be returned if the conversion cannot be done. WorksheetConvert(src Value) error }
WorksheetConverter is an interface used by StructScan.