spec

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatRGBA

func FormatRGBA(c color.RGBA) string

FormatRGBA returns the color as a hex string with the format #rrggbbaa.

func ParseMatrix

func ParseMatrix(s string) ([16]float32, bool)

ParseMatrix parses s as a Matrix.

func ParseRGBA

func ParseRGBA(s string) (c color.RGBA, err error)

ParseRGBA parses s as a RGBA color.

func Register added in v0.24.0

func Register(namespace string, spec Spec)

Register makes a spec available by the provided namesoace. If Register is called twice with the same name or if spec is nil, it panics.

Types

type Any added in v0.24.0

type Any []Marshaler

Any is an extension point containing <any> information.

func (Any) Marshal3MF added in v0.24.0

func (e Any) Marshal3MF(x Encoder, start *xml.StartElement) error

type AnyAttr added in v0.24.0

type AnyAttr []AttrGroup

func (AnyAttr) Get added in v0.24.0

func (a AnyAttr) Get(namespace string) AttrGroup

func (AnyAttr) Marshal3MF added in v0.24.0

func (a AnyAttr) Marshal3MF(x Encoder, start *xml.StartElement) error

type AppendTokenElementDecoder added in v0.23.0

type AppendTokenElementDecoder interface {
	ElementDecoder
	AppendToken(xml.Token)
}

AppendTokenElementDecoder must be implemented by element decoders that need to accumulate tokens to support loseless encoding.

type AttrGroup added in v0.24.0

type AttrGroup interface {
	UnmarshalerAttr
	Marshaler
	Namespace() string
}

AttrGroup defines a container for different attributes of the same namespace. It supports encoding and decoding to XML.

func NewAttrGroup added in v0.24.0

func NewAttrGroup(namespace string, parent xml.Name) AttrGroup

type CharDataElementDecoder

type CharDataElementDecoder interface {
	ElementDecoder
	CharData([]byte)
}

CharDataElementDecoder must be implemented by element decoders that need to decode raw text.

type ChildElementDecoder

type ChildElementDecoder interface {
	ElementDecoder
	Child(xml.Name) (int, ElementDecoder)
}

ChildElementDecoder must be implemented by element decoders that need decoding nested elements.

type ElementDecoder

type ElementDecoder interface {
	Start([]XMLAttr) error
	End()
}

ElementDecoder defines the minimum contract to decode a 3MF node.

type Encoder

type Encoder interface {
	AddRelationship(Relationship)
	FloatPresicion() int
	EncodeToken(xml.Token)
	Flush() error
	SetAutoClose(bool)
	// Use SetSkipAttrEscape(true) when there is no need to escape
	// StartElement attribute values, such as as when all attributes
	// are filled using strconv.
	SetSkipAttrEscape(bool)
}

Encoder provides de necessary methods to encode specs. It should not be implemented by spec authors but will be provided be go3mf itself.

type GetterElementDecoder added in v0.24.0

type GetterElementDecoder interface {
	ElementDecoder
	Element() interface{}
}

func NewElementDecoder added in v0.24.0

func NewElementDecoder(name xml.Name) GetterElementDecoder

type Marshaler

type Marshaler interface {
	Marshal3MF(Encoder, *xml.StartElement) error
}

Marshaler is the interface implemented by objects that can marshal themselves into valid XML elements.

type PropertyGroup

type PropertyGroup interface {
	Len() int
}

type Relationship

type Relationship struct {
	Path string
	Type string
	ID   string
}

type Spec

type Spec interface {
	NewAttrGroup(parent xml.Name) AttrGroup
	NewElementDecoder(name xml.Name) GetterElementDecoder
}

Spec is the interface that must be implemented by a 3mf spec.

Specs may implement ValidateSpec.

func Load added in v0.24.0

func Load(space string) (Spec, bool)

type UnknownAttrs added in v0.23.0

type UnknownAttrs struct {
	Space string
	Attr  []xml.Attr
}

An UnknownAttrs represents a list of attributes that are not supported by any loaded Spec.

func (UnknownAttrs) Marshal3MF added in v0.24.0

func (u UnknownAttrs) Marshal3MF(enc Encoder, start *xml.StartElement) error

func (UnknownAttrs) Namespace added in v0.24.0

func (u UnknownAttrs) Namespace() string

func (*UnknownAttrs) Unmarshal3MFAttr added in v0.24.0

func (u *UnknownAttrs) Unmarshal3MFAttr(a XMLAttr) error

type UnknownTokens added in v0.23.0

type UnknownTokens struct {
	Token []xml.Token
}

UnknownTokens represents a section of an xml that cannot be decoded by any loaded Spec.

func (UnknownTokens) Marshal3MF added in v0.23.0

func (u UnknownTokens) Marshal3MF(enc Encoder, _ *xml.StartElement) error

func (UnknownTokens) XMLName added in v0.24.0

func (u UnknownTokens) XMLName() xml.Name

XMLName returns the xml identifier of the resource.

type UnknownTokensDecoder added in v0.23.0

type UnknownTokensDecoder struct {
	XMLName xml.Name
	// contains filtered or unexported fields
}

UnknownTokensDecoder can be used by spec decoders to maintain the xml tree elements of unknown extensions.

func NewUnknownDecoder added in v0.24.0

func NewUnknownDecoder(name xml.Name) *UnknownTokensDecoder

func (*UnknownTokensDecoder) AppendToken added in v0.23.0

func (d *UnknownTokensDecoder) AppendToken(t xml.Token)

func (*UnknownTokensDecoder) Element added in v0.24.0

func (d *UnknownTokensDecoder) Element() interface{}

func (*UnknownTokensDecoder) End added in v0.23.0

func (d *UnknownTokensDecoder) End()

func (*UnknownTokensDecoder) Start added in v0.23.0

func (d *UnknownTokensDecoder) Start(attrs []XMLAttr) error

func (UnknownTokensDecoder) Tokens added in v0.23.0

type UnmarshalerAttr added in v0.24.0

type UnmarshalerAttr interface {
	Unmarshal3MFAttr(XMLAttr) error
}

UnmarshalerAttr is the interface implemented by objects that can unmarshal an XML element description of themselves.

type ValidateSpec

type ValidateSpec interface {
	Spec
	Validate(model interface{}, path string, element interface{}) error
}

If a Spec implemented ValidateSpec, then model.Validate will call Validate and aggregate the resulting erros.

model is guaranteed to be a *go3mf.Model

func LoadValidator added in v0.24.0

func LoadValidator(ns string) (ValidateSpec, bool)

type XMLAttr added in v0.24.0

type XMLAttr struct {
	Name  xml.Name
	Value []byte
}

An XMLAttr represents an attribute in an XML element (Name=Value).

Jump to

Keyboard shortcuts

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