variants

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Null = iota
	Integer
	Long
	Float
	Double
	String
	Boolean
	DateTime
	TimeSpan
	Object
	Array
)

Defines supported types of variant values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractVariantOperations

type AbstractVariantOperations struct {
	Overrides IVariantOperationsOverrides
}

Implements an abstractd variant operations manager object.

func InheritAbstractVariantOperations

func InheritAbstractVariantOperations(overrides IVariantOperationsOverrides) *AbstractVariantOperations

func (*AbstractVariantOperations) Add

func (c *AbstractVariantOperations) Add(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '+' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) And

func (c *AbstractVariantOperations) And(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs AND operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Div

func (c *AbstractVariantOperations) Div(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '/' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Equal

func (c *AbstractVariantOperations) Equal(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '=' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) GetElement

func (c *AbstractVariantOperations) GetElement(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs [] operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) In

func (c *AbstractVariantOperations) In(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs IN operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Less

func (c *AbstractVariantOperations) Less(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '<' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) LessEqual

func (c *AbstractVariantOperations) LessEqual(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '<=' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Lsh

func (c *AbstractVariantOperations) Lsh(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '<<' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Mod

func (c *AbstractVariantOperations) Mod(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '%' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) More

func (c *AbstractVariantOperations) More(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '>' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) MoreEqual

func (c *AbstractVariantOperations) MoreEqual(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '>=' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Mul

func (c *AbstractVariantOperations) Mul(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '*' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Negative

func (c *AbstractVariantOperations) Negative(value *Variant) (*Variant, error)

Performs unary '-' operation for a variant.

Parameters:

  • value: The operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Not

func (c *AbstractVariantOperations) Not(value *Variant) (*Variant, error)

Performs NOT operation for a variant.

Parameters:

  • value: The operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) NotEqual

func (c *AbstractVariantOperations) NotEqual(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '<>' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Or

func (c *AbstractVariantOperations) Or(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs OR operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Pow

func (c *AbstractVariantOperations) Pow(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '^' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Rsh

func (c *AbstractVariantOperations) Rsh(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '>>' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Sub

func (c *AbstractVariantOperations) Sub(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs '-' operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

func (*AbstractVariantOperations) Xor

func (c *AbstractVariantOperations) Xor(
	value1 *Variant, value2 *Variant) (*Variant, error)

Performs XOR operation for two variants.

Parameters:

  • value1: The first operand for this operation.
  • value2: The second operand for this operation.

Returns: A result variant object.

type IVariantOperations

type IVariantOperations interface {
	// Converts variant to specified type
	//
	// Parameters:
	//   - value: A variant value to be converted.
	//   - newType: A type of object to be returned.
	// Returns: A converted Variant value.
	Convert(value *Variant, newType int) (*Variant, error)

	// Performs '+' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Add(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '-' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Sub(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '*' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Mul(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '/' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Div(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '%' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Mod(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '^' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Pow(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs AND operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	And(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs OR operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Or(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs XOR operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Xor(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs << operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Lsh(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs >> operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Rsh(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs NOT operation for a variant.
	//
	// Parameters:
	//   - value: The operand for this operation.
	// Returns: A result variant object.
	Not(value *Variant) (*Variant, error)

	// Performs unary '-' operation for a variant.
	//
	// Parameters:
	//   - value: The operand for this operation.
	// Returns: A result variant object.
	Negative(value *Variant) (*Variant, error)

	// Performs '=' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Equal(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '<>' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	NotEqual(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '>' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	More(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '<' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	Less(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '>=' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	MoreEqual(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs '<=' operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	LessEqual(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs IN operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	In(value1 *Variant, value2 *Variant) (*Variant, error)

	// Performs [] operation for two variants.
	//
	// Parameters:
	//   - value1: The first operand for this operation.
	//   - value2: The second operand for this operation.
	// Returns: A result variant object.
	GetElement(value1 *Variant, value2 *Variant) (*Variant, error)
}

Defines an interface for variant operations manager.

type IVariantOperationsOverrides

type IVariantOperationsOverrides interface {
	Convert(value *Variant, newType int) (*Variant, error)
}

type TypeSafeVariantOperations

type TypeSafeVariantOperations struct {
	AbstractVariantOperations
}

Implements a strongly typed (type safe) variant operations manager object.

func NewTypeSafeVariantOperations

func NewTypeSafeVariantOperations() *TypeSafeVariantOperations

func (*TypeSafeVariantOperations) Convert

func (c *TypeSafeVariantOperations) Convert(
	value *Variant, newType int) (*Variant, error)

Converts variant to specified type

Parameters:

  • value: A variant value to be converted.
  • newType: A type of object to be returned.

Returns: A converted Variant value.

type TypeUnsafeVariantOperations

type TypeUnsafeVariantOperations struct {
	AbstractVariantOperations
}

Implements a type unsafe variant operations manager object.

func NewTypeUnsafeVariantOperations

func NewTypeUnsafeVariantOperations() *TypeUnsafeVariantOperations

func (*TypeUnsafeVariantOperations) Convert

func (c *TypeUnsafeVariantOperations) Convert(
	value *Variant, newType int) (*Variant, error)

Converts variant to specified type

Parameters:

  • value: A variant value to be converted.
  • newType: A type of object to be returned.

Returns: A converted Variant value.

type Variant

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

Defines container for variant values.

var Empty *Variant = EmptyVariant()

Empty variant constant

func EmptyVariant

func EmptyVariant() *Variant

Constructs an empty variant object

func NewVariant

func NewVariant(value interface{}) *Variant

Constructs this class and assignes a value.

Params:

  • value: another variant value.

func VariantFromArray

func VariantFromArray(value []*Variant) *Variant

Creates a new variant from Array value.

Params:

  • value: a variant value.

Rturns: A created variant object

func VariantFromBoolean

func VariantFromBoolean(value bool) *Variant

Creates a new variant from Boolean value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromDateTime

func VariantFromDateTime(value time.Time) *Variant

Creates a new variant from DateTime value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromDouble

func VariantFromDouble(value float64) *Variant

Creates a new variant from Double value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromFloat

func VariantFromFloat(value float32) *Variant

Creates a new variant from Float value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromInteger

func VariantFromInteger(value int) *Variant

Creates a new variant from Integer value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromLong

func VariantFromLong(value int64) *Variant

Creates a new variant from Long value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromObject

func VariantFromObject(value interface{}) *Variant

Creates a new variant from Object value.

Params:

  • value: a variant value.

Rturns: A created variant object

func VariantFromString

func VariantFromString(value string) *Variant

Creates a new variant from String value.

Params:

  • value: a variant value.

Returns: A created variant object

func VariantFromTimeSpan

func VariantFromTimeSpan(value time.Duration) *Variant

Creates a new variant from TimeSpan value.

Params:

  • value: a variant value.

Rturns: A created variant object

func (*Variant) AsArray

func (c *Variant) AsArray() []*Variant

Gets variant value as variant array

func (*Variant) AsBoolean

func (c *Variant) AsBoolean() bool

Gets variant value as boolean

func (*Variant) AsDateTime

func (c *Variant) AsDateTime() time.Time

Gets variant value as DateTime

func (*Variant) AsDouble

func (c *Variant) AsDouble() float64

Gets variant value as double

func (*Variant) AsFloat

func (c *Variant) AsFloat() float32

Gets variant value as float

func (*Variant) AsInteger

func (c *Variant) AsInteger() int

Gets variant value as integer

func (*Variant) AsLong

func (c *Variant) AsLong() int64

Gets variant value as int64

func (*Variant) AsObject

func (c *Variant) AsObject() interface{}

Gets variant value as object

func (*Variant) AsString

func (c *Variant) AsString() string

Gets variant value as string

func (*Variant) AsTimeSpan

func (c *Variant) AsTimeSpan() time.Duration

Gets variant value as TimeSpan

func (*Variant) Assign

func (c *Variant) Assign(value *Variant)

Assignes a new value to this object. Parameters:

  • value A new value to be assigned.

func (*Variant) Clear

func (c *Variant) Clear()

Clears this object and assignes a VariantType.Null type.

func (*Variant) Clone

func (c *Variant) Clone() *Variant

Cloning the variant value

Returns The cloned value of this variant

func (*Variant) Equals

func (c *Variant) Equals(obj interface{}) bool

Compares this object to the specified one.

Parameters:

  • obj An object to be compared.

Returns <code>true</code> if objects are equal.

func (*Variant) GetByIndex

func (c *Variant) GetByIndex(index int) *Variant

Gets an array element by its index.

Parameters:

  • index an element index

Returns a requested array element

func (*Variant) IsEmpty

func (c *Variant) IsEmpty() bool

Checks is this variant value empty. Returns <code>true</code< is this variant value is empty.

func (*Variant) IsNull

func (c *Variant) IsNull() bool

Checks is this variant value Null.

Returns <code>true</code> if this variant value is Null.

func (*Variant) Length

func (c *Variant) Length() int

Gets length of the array

Returns the length of the array or 0

func (*Variant) SetAsArray

func (c *Variant) SetAsArray(value []*Variant)

Sets variant value as variant array

Parameters:

  • value a value to be set

func (*Variant) SetAsBoolean

func (c *Variant) SetAsBoolean(value bool)

Sets variant value as boolean

Parameters:

  • value a value to be set

func (*Variant) SetAsDateTime

func (c *Variant) SetAsDateTime(value time.Time)

Sets variant value as DateTime

Parameters:

  • value a value to be set

func (*Variant) SetAsDouble

func (c *Variant) SetAsDouble(value float64)

Sets variant value as double

Parameters:

  • value a value to be set

func (*Variant) SetAsFloat

func (c *Variant) SetAsFloat(value float32)

Sets variant value as float

Parameters:

  • value a value to be set

func (*Variant) SetAsInteger

func (c *Variant) SetAsInteger(value int)

Sets variant value as integer

Parameters:

  • value a value to be set

func (*Variant) SetAsLong

func (c *Variant) SetAsLong(value int64)

Sets variant value as int64

Parameters:

  • value a value to be set

func (*Variant) SetAsObject

func (c *Variant) SetAsObject(value interface{})

Sets variant value as object

Parameters:

  • value a value to be set

func (*Variant) SetAsString

func (c *Variant) SetAsString(value string)

Sets variant value as string

Parameters:

  • value a value to be set

func (*Variant) SetAsTimeSpan

func (c *Variant) SetAsTimeSpan(value time.Duration)

Sets variant value as TimeSpan

Parameters:

  • value a value to be set

func (*Variant) SetByIndex

func (c *Variant) SetByIndex(index int, element *Variant)

Sets an array element by its index.

Parameters:

  • index an element index
  • element an element value

func (*Variant) SetLength

func (c *Variant) SetLength(value int)

Sets a new array length

Parameters:

  • value a new array length

func (*Variant) String

func (c *Variant) String() string

Gets a string value for this object.

Returns a string value for this object.

func (*Variant) Type

func (c *Variant) Type() int

Gets a variant type

Jump to

Keyboard shortcuts

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