spec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: BSD-2-Clause Imports: 6 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.

Types

type AppendTokenElementDecoder

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

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

type Attr

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

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

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) ElementDecoder
}

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

type ElementDecoder

type ElementDecoder interface {
	Start([]Attr) 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 ErrorWrapper

type ErrorWrapper interface {
	Wrap(error) error
}

type Marshaler

type Marshaler interface {
	Marshal3MF(Encoder) error
}

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

type MarshalerAttr

type MarshalerAttr interface {
	Marshal3MFAttr(Encoder) ([]xml.Attr, error)
}

MarshalerAttr is the interface implemented by objects that can marshal themselves into valid XML attributes.

type PropertyGroup

type PropertyGroup interface {
	Len() int
}

type Relationship

type Relationship struct {
	Path string
	Type string
	ID   string
}

type Spec

type Spec interface {
	DecodeAttribute(parent interface{}, attr Attr) error
	CreateElementDecoder(parent interface{}, name string) ElementDecoder
}

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

Specs may implement ValidateSpec.

type UnknownAttrs

type UnknownAttrs []xml.Attr

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

func (UnknownAttrs) Marshal3MFAttr

func (u UnknownAttrs) Marshal3MFAttr(enc Encoder) ([]xml.Attr, error)

type UnknownTokens

type UnknownTokens []xml.Token

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

func (UnknownTokens) Marshal3MF

func (u UnknownTokens) Marshal3MF(enc Encoder) error

type UnknownTokensDecoder

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

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

func (*UnknownTokensDecoder) AppendToken

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

func (*UnknownTokensDecoder) End

func (d *UnknownTokensDecoder) End()

func (*UnknownTokensDecoder) Start

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

func (UnknownTokensDecoder) Tokens

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 element can be a *go3mf.Model, go3mf.Asset or *go3mf.Object.

Jump to

Keyboard shortcuts

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