xmp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 19 Imported by: 68

Documentation

Overview

Package xmp implements the Extensible Metadata Platform (XMP) defined in ISO 16684-1:2011(E).

Index

Constants

View Source
const (
	Xpacket = 1 << iota
	Xpadding
)
View Source
const (
	CREATE  SyncFlags = 1 << iota // create when not exist, nothing when exist or source is empty
	REPLACE                       // replace when dest exist, nothing when missing or source is empty
	DELETE                        // clear dest when source value is empty
	APPEND                        // list-only: append non-empty source value
	UNIQUE                        // list-only: append non-empty unique source value
	NOFAIL                        // don't fail when state+op+flags don't match
	DEFAULT = CREATE | REPLACE | DELETE | UNIQUE
	MERGE   = CREATE | UNIQUE | NOFAIL
	EXTEND  = CREATE | REPLACE | UNIQUE | NOFAIL
	ADD     = CREATE | UNIQUE | NOFAIL
)
View Source
const XMP_TOOLKIT_VERSION = "Go XMP SDK 1.0"

Variables

View Source
var EEmptyValue = errors.New("empty value")
View Source
var EmptyName = xml.Name{}
View Source
var ErrOverflow = errors.New("xmp: document exceeds size limit")

Functions

func ConvertFilter

func ConvertFilter(value string) reflect.Value

converter function for Gorilla schema; will become unnecessary once https://github.com/gorilla/schema/issues/57 is fixed

register with decoder.RegisterConverter(Filter(""), ConvertFilter)

func DumpStats

func DumpStats()

func GetLocaleField

func GetLocaleField(v Model, lang string, name string) (string, error)

func GetModelPath

func GetModelPath(v Model, path Path) (string, error)

func GetNativeField

func GetNativeField(v Model, name string) (string, error)

func Marshal

func Marshal(d *Document) ([]byte, error)

func MarshalArray

func MarshalArray(e *Encoder, node *Node, typ ArrayType, items interface{}) error

func MarshalIndent

func MarshalIndent(d *Document, prefix, indent string) ([]byte, error)

func Max

func Max(x, y int) int

func Max64

func Max64(x, y int64) int64

func Min

func Min(x, y int) int

func Min64

func Min64(x, y int64) int64

func NewName

func NewName(local string) xml.Name

func Register

func Register(ns *Namespace, groups ...NamespaceGroup)

func ScanPackets

func ScanPackets(r io.Reader) ([][]byte, error)

func SetAgent

func SetAgent(org, software, version, extra string)

func SetLocaleField

func SetLocaleField(v Model, lang string, name, value string) error

func SetLogLevel

func SetLogLevel(l LogLevelType)

func SetLogger

func SetLogger(v Logger)

func SetModelPath

func SetModelPath(v Model, path Path, value string, flags SyncFlags) error

func SetNativeField

func SetNativeField(v Model, name, value string) error

func ToRawString

func ToRawString(t interface{}) (string, error)

func ToString

func ToString(t interface{}) string

func Unmarshal

func Unmarshal(data []byte, d *Document) error

func UnmarshalArray

func UnmarshalArray(d *Decoder, node *Node, typ ArrayType, out interface{}) error

Types

type AgentName

type AgentName string

8.2.2.1 AgentName

func (AgentName) IsZero

func (x AgentName) IsZero() bool

func (AgentName) String

func (x AgentName) String() string

type AltItem

type AltItem struct {
	Value     string `xmp:",chardata" json:"value"`
	Lang      string `xmp:"xml:lang"  json:"lang"`
	IsDefault bool   `xmp:"-"         json:"isDefault"`
}

Note: when changing these tags, also update json.go for proper marshal/demarshal

func (AltItem) GetLang

func (x AltItem) GetLang() string

func (*AltItem) UnmarshalText

func (x *AltItem) UnmarshalText(data []byte) error

type AltString

type AltString []AltItem

func NewAltString

func NewAltString(items ...interface{}) AltString

func (*AltString) Add

func (a *AltString) Add(lang string, value string)

func (*AltString) AddDefault

func (a *AltString) AddDefault(lang string, value string)

func (*AltString) AddUnique

func (a *AltString) AddUnique(lang string, value string) bool

func (AltString) Default

func (a AltString) Default() string

func (*AltString) EnsureDefault

func (a *AltString) EnsureDefault()

make sure there is exactly one a default and it's the first item

func (AltString) Get

func (a AltString) Get(lang string) string

func (AltString) Index

func (a AltString) Index(lang string) int

func (AltString) IsZero

func (x AltString) IsZero() bool

func (AltString) MarshalXMP

func (x AltString) MarshalXMP(e *Encoder, node *Node, m Model) error

func (*AltString) RemoveLang

func (a *AltString) RemoveLang(lang string)

func (*AltString) Set

func (a *AltString) Set(lang string, value string)

func (AltString) Typ

func (a AltString) Typ() ArrayType

func (*AltString) UnmarshalXMP

func (x *AltString) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type AltStringArray

type AltStringArray []*AltString

func NewAltStringArray

func NewAltStringArray(items ...*AltString) AltStringArray

func (*AltStringArray) Add

func (x *AltStringArray) Add(v *AltString) error

func (AltStringArray) IsZero

func (x AltStringArray) IsZero() bool

func (AltStringArray) MarshalXMP

func (x AltStringArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (AltStringArray) Typ

func (x AltStringArray) Typ() ArrayType

func (*AltStringArray) UnmarshalXMP

func (x *AltStringArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Array

type Array interface {
	Typ() ArrayType
}

type ArrayType

type ArrayType string

Choice / Alternative Arrays with xml:lang support

const (
	ArrayTypeOrdered     ArrayType = "Seq"
	ArrayTypeUnordered   ArrayType = "Bag"
	ArrayTypeAlternative ArrayType = "Alt"
)

type Attr

type Attr struct {
	Name  xml.Name
	Value string
}

type AttrList

type AttrList []Attr

func (*AttrList) From

func (x *AttrList) From(l []xml.Attr)

func (AttrList) IsZero

func (x AttrList) IsZero() bool

func (AttrList) XML

func (x AttrList) XML() []xml.Attr

type Bool

type Bool bool

8.2.1.1 Boolean

const (
	True  Bool = true
	False Bool = false
)

func (Bool) MarshalJSON

func (x Bool) MarshalJSON() ([]byte, error)

func (Bool) MarshalText

func (x Bool) MarshalText() ([]byte, error)

func (*Bool) UnmarshalText

func (x *Bool) UnmarshalText(data []byte) error

func (Bool) Value

func (x Bool) Value() bool

type ConverterFunc

type ConverterFunc func(string) string

type Date

type Date time.Time

8.2.1.2 Date

func NewDate

func NewDate(t time.Time) Date

func Now

func Now() Date

func ParseDate

func ParseDate(value string) (Date, error)

func (Date) IsZero

func (x Date) IsZero() bool

func (Date) MarshalText

func (x Date) MarshalText() ([]byte, error)

func (Date) String

func (x Date) String() string

func (Date) Time

func (x Date) Time() Time

func (*Date) UnmarshalText

func (x *Date) UnmarshalText(data []byte) error

func (Date) Value

func (x Date) Value() time.Time

type DateList

type DateList []Date

func (DateList) MarshalXMP

func (x DateList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (DateList) Typ

func (x DateList) Typ() ArrayType

func (*DateList) UnmarshalXMP

func (x *DateList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode(x *Document) error

func (*Decoder) DecodeElement

func (d *Decoder) DecodeElement(v interface{}, src *Node) error

func (*Decoder) SetVersion

func (d *Decoder) SetVersion(v Version)

type Document

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

func NewDocument

func NewDocument() *Document

high-level XMP document interface

func Read

func Read(r io.Reader) (*Document, error)

func Scan

func Scan(r io.Reader) (*Document, error)

func (*Document) AddModel

func (d *Document) AddModel(v Model) (*Node, error)

func (*Document) Close

func (d *Document) Close()

func (*Document) Dump

func (d *Document) Dump()

func (*Document) DumpNamespaces

func (d *Document) DumpNamespaces()

func (*Document) FilterNamespaces

func (d *Document) FilterNamespaces(keep NamespaceList) bool

will keep document nodes matching the list and delete all others. returns true if any namespace was removed.

func (*Document) FindModel

func (d *Document) FindModel(ns *Namespace) Model

func (*Document) FindNode

func (d *Document) FindNode(ns *Namespace) *Node

func (Document) FindNs

func (d Document) FindNs(name, uri string) *Namespace

func (*Document) GetPath

func (d *Document) GetPath(path Path) (string, error)

func (Document) IsDirty

func (d Document) IsDirty() bool

func (*Document) ListPaths

func (d *Document) ListPaths() (PathValueList, error)

func (*Document) MakeModel

func (d *Document) MakeModel(ns *Namespace) (Model, error)

func (*Document) MarshalJSON

func (d *Document) MarshalJSON() ([]byte, error)

func (*Document) Merge

func (d *Document) Merge(b *Document, flags SyncFlags) error

func (*Document) Namespaces

func (d *Document) Namespaces() NamespaceList

func (*Document) Nodes

func (d *Document) Nodes() NodeList

func (*Document) RemoveNamespace

func (d *Document) RemoveNamespace(ns *Namespace) bool

func (*Document) RemoveNamespaceByName

func (d *Document) RemoveNamespaceByName(n string) bool

func (*Document) RemoveNamespaces

func (d *Document) RemoveNamespaces(remove NamespaceList) bool

will delete all document nodes matching the list

func (*Document) SetDirty

func (d *Document) SetDirty()

func (*Document) SetPath

func (d *Document) SetPath(desc PathValue) error

func (*Document) Sync

func (d *Document) Sync(sPath, dPath Path, flags SyncFlags, v Model, f ConverterFunc) error

func (*Document) SyncModels

func (d *Document) SyncModels() error

cross-model sync, must be explicitly called to merge across models

func (*Document) SyncMulti

func (d *Document) SyncMulti(desc SyncDescList, m Model) error

Model is optional and exists for performance reasons to avoid lookups when a sync destination is a specific model only (useful to implement SyncFromXMP() in models)

func (*Document) UnmarshalJSON

func (d *Document) UnmarshalJSON(data []byte) error

The difference to regular JSON decoding is that we must take care of unknown properties that Go's JSON decoder simply ignores. In our XMP model we capture everything unknown in child nodes. Note: due to internal namespace lookups we cannot use node attributes, because attribute unmarshal will fail for all unknown namespaces.

type DocumentArray

type DocumentArray []*Document

func (DocumentArray) MarshalXMP

func (x DocumentArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (DocumentArray) Typ

func (x DocumentArray) Typ() ArrayType

func (*DocumentArray) UnmarshalXMP

func (x *DocumentArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Duration

type Duration time.Duration

Duration

func ParseDuration

func ParseDuration(d string) (Duration, error)

func (Duration) Duration

func (d Duration) Duration() time.Duration

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (Duration) RoundToDays

func (d Duration) RoundToDays() int

func (Duration) RoundToHours

func (d Duration) RoundToHours() int64

func (Duration) RoundToMillisecond

func (d Duration) RoundToMillisecond() int64

func (Duration) RoundToMinutes

func (d Duration) RoundToMinutes() int64

func (Duration) RoundToSeconds

func (d Duration) RoundToSeconds() int64

func (Duration) String

func (d Duration) String() string

func (Duration) Truncate

func (d Duration) Truncate(r time.Duration) Duration

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

type Encoder

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

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(d *Document) error

encode to separate rdf:Description objects per namespace

func (*Encoder) EncodeElement

func (e *Encoder) EncodeElement(v interface{}, node *Node) error

func (*Encoder) Indent

func (e *Encoder) Indent(prefix, indent string)

func (*Encoder) SetFlags

func (e *Encoder) SetFlags(flags int)

func (*Encoder) SetMaxSize

func (e *Encoder) SetMaxSize(size int64)

type Extension

type Extension Node

Raw nodes are used to keep custom data models inside a container. This is used by extension nodes in the Adobe UMC SDK, but may be used in private models as well.

func (*Extension) FindNodeByName

func (x *Extension) FindNodeByName(name string) *Node

func (*Extension) IsZero

func (x *Extension) IsZero() bool

func (*Extension) MarshalXML

func (x *Extension) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Extension) MarshalXMP

func (x Extension) MarshalXMP(e *Encoder, node *Node, m Model) error

func (*Extension) UnmarshalXML

func (x *Extension) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*Extension) UnmarshalXMP

func (x *Extension) UnmarshalXMP(d *Decoder, src *Node, m Model) error

func (*Extension) UnmarshalXMPAttr

func (x *Extension) UnmarshalXMPAttr(d *Decoder, a Attr) error

type ExtensionArray

type ExtensionArray []*Extension

used for xmpMM:Pantry bags

<xmpMM:Pantry>

<rdf:Bag>
  <rdf:li>
    <rdf:Description>...</rdf:Description>
  </rdf:li>
</rdf:Bag>

</xmpMM:Pantry>

func (ExtensionArray) MarshalXMP

func (x ExtensionArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (ExtensionArray) Typ

func (x ExtensionArray) Typ() ArrayType

func (*ExtensionArray) UnmarshalXMP

func (x *ExtensionArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Filter

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

func NewFilter

func NewFilter(include, exclude NamespaceList) *Filter

func ParseFilter

func ParseFilter(s string) *Filter

func ParseFilterStrict

func ParseFilterStrict(s string) (*Filter, error)

func (Filter) Apply

func (x Filter) Apply(d *Document) bool

func (Filter) String

func (x Filter) String() string

func (*Filter) UnmarshalText

func (x *Filter) UnmarshalText(b []byte) error

type GPSCoord

type GPSCoord string

GPS Coordinates

“DDD,MM,SSk” or “DDD,MM.mmk”

DDD is a number of degrees
MM is a number of minutes
SS is a number of seconds
mm is a fraction of minutes
k is a single character N, S, E, or W indicating a direction (north, south, east, west)

func (GPSCoord) IsZero

func (x GPSCoord) IsZero() bool

func (GPSCoord) Value

func (x GPSCoord) Value() string

type GUID

type GUID string

8.2.2.3 GUID (a simple non-Uri identifier)

func (GUID) IsZero

func (x GUID) IsZero() bool

func (GUID) Issuer

func (x GUID) Issuer() string

func (GUID) MarshalText

func (x GUID) MarshalText() ([]byte, error)

func (GUID) MarshalXMP

func (x GUID) MarshalXMP(e *Encoder, node *Node, m Model) error

func (GUID) String

func (x GUID) String() string

func (*GUID) UnmarshalText

func (x *GUID) UnmarshalText(data []byte) error

func (GUID) Value

func (x GUID) Value() string

type GUIDList

type GUIDList []GUID

func (GUIDList) MarshalXMP

func (x GUIDList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (GUIDList) Typ

func (x GUIDList) Typ() ArrayType

func (*GUIDList) UnmarshalXMP

func (x *GUIDList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type IntArray

type IntArray []int

Unordered Integer Arrays

func NewIntArray

func NewIntArray(items ...int) IntArray

func (*IntArray) Add

func (x *IntArray) Add(v int) error

func (IntArray) IsZero

func (x IntArray) IsZero() bool

func (IntArray) MarshalXMP

func (x IntArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (IntArray) Typ

func (x IntArray) Typ() ArrayType

func (*IntArray) UnmarshalXMP

func (x *IntArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type IntList

type IntList []int

Ordered Integer Arrays

func NewIntList

func NewIntList(items ...int) IntList

func (*IntList) Add

func (x *IntList) Add(v int) error

func (IntList) IsZero

func (x IntList) IsZero() bool

func (IntList) MarshalXMP

func (x IntList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (IntList) String

func (x IntList) String() string

func (IntList) Typ

func (x IntList) Typ() ArrayType

func (*IntList) UnmarshalXMP

func (x *IntList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type LogLevelType

type LogLevelType int
const (
	LogLevelInvalid LogLevelType = iota
	LogLevelDebug
	LogLevelInfo
	LogLevelWarning
	LogLevelError
)

func LogLevel

func LogLevel() LogLevelType

package level logging control

func (LogLevelType) Prefix

func (l LogLevelType) Prefix() string

type LogType

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

func (LogType) Debug

func (x LogType) Debug(v ...interface{})

func (LogType) Debugf

func (x LogType) Debugf(s string, v ...interface{})

func (LogType) Error

func (x LogType) Error(v ...interface{})

func (LogType) Errorf

func (x LogType) Errorf(s string, v ...interface{})

func (LogType) Info

func (x LogType) Info(v ...interface{})

func (LogType) Infof

func (x LogType) Infof(s string, v ...interface{})

func (LogType) Warn

func (x LogType) Warn(v ...interface{})

func (LogType) Warnf

func (x LogType) Warnf(s string, v ...interface{})

type Logger

type Logger interface {
	Error(v ...interface{})
	Errorf(s string, v ...interface{})
	Warn(v ...interface{})
	Warnf(s string, v ...interface{})
	Info(v ...interface{})
	Infof(s string, v ...interface{})
	Debug(v ...interface{})
	Debugf(s string, v ...interface{})
}
var (
	Log Logger = &LogType{}
)

type Marshaler

type Marshaler interface {
	MarshalXMP(e *Encoder, n *Node, model Model) error
}

type MarshalerAttr

type MarshalerAttr interface {
	MarshalXMPAttr(e *Encoder, name xml.Name, n *Node) (Attr, error)
}

type Model

type Model interface {
	Can(nsName string) bool
	Namespaces() NamespaceList
	SyncFromXMP(d *Document) error
	SyncToXMP(d *Document) error
	SyncModel(d *Document) error
	CanTag(tag string) bool
	GetTag(tag string) (string, error)
	SetTag(tag, value string) error
}

interface for data models

type ModelFactory

type ModelFactory func(name string) Model

type NamedExtensionArray

type NamedExtensionArray []*Extension

Generates the following XMP/JSON structures from an array instead of xmp:<rdf:Bag> / json:[]

<iXML:extension>

<PRIVATE-NAME-1 rdf:parseType="Resource">
    <PRIVATE-FIELD/>
</PRIVATE-NAME-1>
<PRIVATE-NAME-2 rdf:parseType="Resource">
    <PRIVATE-FIELD/>
</PRIVATE-NAME-2>

</iXML:extension>

iXML:extension: {
		"PRIVATE-NAME-1": {
	        "PRIVATE-FIELD": "",
     },
		"PRIVATE-NAME-2": {
	        "PRIVATE-FIELD": "",
     }
}

func (*NamedExtensionArray) FindNodeByName

func (x *NamedExtensionArray) FindNodeByName(name string) *Node

func (NamedExtensionArray) MarshalXMP

func (x NamedExtensionArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (NamedExtensionArray) Typ

func (*NamedExtensionArray) UnmarshalXMP

func (x *NamedExtensionArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Namespace

type Namespace struct {
	Name    string
	URI     string
	Factory ModelFactory
}

func GetNamespace

func GetNamespace(prefix string) (*Namespace, error)

func NewNamespace

func NewNamespace(name, uri string, factory ModelFactory) *Namespace

func (Namespace) Expand

func (n Namespace) Expand(local string) string

func (Namespace) GetAttr

func (n Namespace) GetAttr() Attr

func (Namespace) GetName

func (n Namespace) GetName() string

func (Namespace) GetURI

func (n Namespace) GetURI() string

func (Namespace) MatchAttrName

func (n Namespace) MatchAttrName(name string) bool

func (Namespace) MatchXMLName

func (n Namespace) MatchXMLName(name xml.Name) bool

func (Namespace) NewModel

func (n Namespace) NewModel() Model

func (Namespace) RootName

func (n Namespace) RootName() xml.Name

func (Namespace) Split

func (n Namespace) Split(name string) string

func (Namespace) XMLName

func (n Namespace) XMLName(local string) xml.Name

type NamespaceGroup

type NamespaceGroup string

Namespace Groups

const (
	NoMetadata     NamespaceGroup = ""
	XmpMetadata    NamespaceGroup = "xmp"
	ImageMetadata  NamespaceGroup = "image"
	MusicMetadata  NamespaceGroup = "music"
	MovieMetadata  NamespaceGroup = "movie"
	SoundMetadata  NamespaceGroup = "sound"
	CameraMetadata NamespaceGroup = "camera"
	VfxMetadata    NamespaceGroup = "vfx"
	RightsMetadata NamespaceGroup = "rights"
)

func ParseNamespaceGroup

func ParseNamespaceGroup(s string) NamespaceGroup

func (NamespaceGroup) Contains

func (g NamespaceGroup) Contains(ns *Namespace) bool

func (NamespaceGroup) Namespaces

func (g NamespaceGroup) Namespaces() NamespaceList

type NamespaceGroupList

type NamespaceGroupList []NamespaceGroup

func (NamespaceGroupList) Contains

func (l NamespaceGroupList) Contains(ns *Namespace) bool

type NamespaceList

type NamespaceList []*Namespace

func GetGroupNamespaces

func GetGroupNamespaces(group NamespaceGroup) (NamespaceList, error)

func (NamespaceList) Contains

func (l NamespaceList) Contains(ns *Namespace) bool

func (NamespaceList) ContainsName

func (l NamespaceList) ContainsName(n string) bool

func (*NamespaceList) RemoveDups

func (l *NamespaceList) RemoveDups() NamespaceList

type Node

type Node struct {
	XMLName xml.Name // node name and namespace
	Attr    AttrList // captures all unbound attributes and XMP qualifiers
	Model   Model    // XmpCore, DublinCore, etc
	Value   string
	Nodes   NodeList // child nodes
}

func NewNode

func NewNode(name xml.Name) *Node

func (*Node) AddAttr

func (n *Node) AddAttr(attr Attr)

func (*Node) AddNode

func (n *Node) AddNode(x *Node) *Node

keep list of nodes unique, overwrite contents when names equal

func (*Node) AddStringAttr

func (n *Node) AddStringAttr(name, value string)

keep list of attributes unique, overwrite value when names equal

func (*Node) AppendNode

func (n *Node) AppendNode(x *Node) *Node

append in any case

func (Node) ArrayType

func (n Node) ArrayType() ArrayType

func (*Node) Clear

func (n *Node) Clear()

func (*Node) Close

func (n *Node) Close()

func (Node) Dump

func (n Node) Dump(d int)

func (*Node) FullName

func (n *Node) FullName() string

func (*Node) GetAttr

func (n *Node) GetAttr(ns, name string) []Attr

func (*Node) GetPath

func (n *Node) GetPath(path Path) (string, error)

func (Node) IsArray

func (n Node) IsArray() bool

func (*Node) IsZero

func (n *Node) IsZero() bool

func (*Node) ListPaths

func (n *Node) ListPaths(path Path) (PathValueList, error)

func (*Node) MarshalXML

func (n *Node) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Node) Name

func (n *Node) Name() string

func (*Node) Namespace

func (n *Node) Namespace() string

func (*Node) Namespaces

func (n *Node) Namespaces(d *Document) NamespaceList

func (*Node) RemoveNode

func (n *Node) RemoveNode(x *Node) *Node

func (*Node) SetPath

func (n *Node) SetPath(path Path, value string, flags SyncFlags) error

func (*Node) UnmarshalXML

func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type NodeList

type NodeList []*Node

func (*NodeList) AddNode

func (x *NodeList) AddNode(n *Node) *Node

func (*NodeList) AppendNode

func (x *NodeList) AppendNode(n *Node) *Node

func (*NodeList) FindNode

func (n *NodeList) FindNode(ns *Namespace) *Node

func (*NodeList) FindNodeByName

func (n *NodeList) FindNodeByName(prefix string) *Node

func (*NodeList) Index

func (x *NodeList) Index(n *Node) int

func (*NodeList) RemoveNode

func (x *NodeList) RemoveNode(n *Node) *Node

type NullBool

type NullBool bool

Bool

func ParseNullBool

func ParseNullBool(d string) (NullBool, error)

func (NullBool) MarshalJSON

func (x NullBool) MarshalJSON() ([]byte, error)

func (NullBool) MarshalText

func (x NullBool) MarshalText() ([]byte, error)

func (*NullBool) UnmarshalJSON

func (x *NullBool) UnmarshalJSON(data []byte) error

func (*NullBool) UnmarshalText

func (x *NullBool) UnmarshalText(data []byte) error

func (NullBool) Value

func (x NullBool) Value() bool

type NullFloat

type NullFloat float32

Float32

func ParseNullFloat

func ParseNullFloat(d string) (NullFloat, error)

func (NullFloat) Float32

func (f NullFloat) Float32() float32

func (NullFloat) MarshalJSON

func (f NullFloat) MarshalJSON() ([]byte, error)

JSON does not define NaN, +Inf and -Inf

func (NullFloat) MarshalText

func (f NullFloat) MarshalText() ([]byte, error)

func (*NullFloat) UnmarshalJSON

func (f *NullFloat) UnmarshalJSON(data []byte) error

func (*NullFloat) UnmarshalText

func (f *NullFloat) UnmarshalText(data []byte) error

func (NullFloat) Value

func (f NullFloat) Value() float64

type NullFloat64

type NullFloat64 float64

Float64

func ParseNullFloat64

func ParseNullFloat64(d string) (NullFloat64, error)

func (NullFloat64) Float64

func (f NullFloat64) Float64() float64

func (NullFloat64) MarshalJSON

func (f NullFloat64) MarshalJSON() ([]byte, error)

JSON does not define NaN, +Inf and -Inf

func (NullFloat64) MarshalText

func (f NullFloat64) MarshalText() ([]byte, error)

func (*NullFloat64) UnmarshalJSON

func (f *NullFloat64) UnmarshalJSON(data []byte) error

func (*NullFloat64) UnmarshalText

func (f *NullFloat64) UnmarshalText(data []byte) error

func (NullFloat64) Value

func (f NullFloat64) Value() float64

type NullInt

type NullInt int

Int

func ParseNullInt

func ParseNullInt(d string) (NullInt, error)

func (NullInt) Int

func (i NullInt) Int() int

func (NullInt) MarshalJSON

func (i NullInt) MarshalJSON() ([]byte, error)

func (NullInt) MarshalText

func (i NullInt) MarshalText() ([]byte, error)

func (*NullInt) UnmarshalJSON

func (i *NullInt) UnmarshalJSON(data []byte) error

func (*NullInt) UnmarshalText

func (i *NullInt) UnmarshalText(data []byte) error

func (NullInt) Value

func (i NullInt) Value() int

type NullString

type NullString string

String

func ParseNullString

func ParseNullString(s string) (NullString, error)

func (NullString) MarshalText

func (s NullString) MarshalText() ([]byte, error)

func (NullString) String

func (s NullString) String() string

func (*NullString) UnmarshalText

func (s *NullString) UnmarshalText(data []byte) error

func (NullString) Value

func (s NullString) Value() string

type Path

type Path string

func NewPath

func NewPath(prefix string, segments ...string) Path

func (Path) AppendIndex

func (x Path) AppendIndex(i int) Path

func (Path) AppendIndexString

func (x Path) AppendIndexString(s string) Path

func (Path) Fields

func (x Path) Fields() []string

func (Path) IsXmpPath

func (x Path) IsXmpPath() bool

ns:tagname/subtagname

func (Path) Len

func (x Path) Len() int

func (Path) MatchNamespace

func (x Path) MatchNamespace(ns *Namespace) bool

func (Path) Namespace

func (x Path) Namespace(d *Document) (*Namespace, error)

func (Path) NamespacePrefix

func (x Path) NamespacePrefix() string

func (Path) PeekNamespacePrefix

func (x Path) PeekNamespacePrefix() string

func (Path) Pop

func (x Path) Pop() (string, Path)

func (Path) PopFront

func (x Path) PopFront() (string, Path)

func (Path) Push

func (x Path) Push(segment ...string) Path

func (Path) String

func (x Path) String() string

func (*Path) UnmarshalText

func (x *Path) UnmarshalText(data []byte) error

type PathValue

type PathValue struct {
	Path      Path      `json:"path"`
	Namespace string    `json:"namespace,omitempty"`
	Value     string    `json:"value"`
	Flags     SyncFlags `json:"flags,omitempty"`
}

type PathValueList

type PathValueList []PathValue

func ListModelPaths

func ListModelPaths(v Model) (PathValueList, error)

func (*PathValueList) Add

func (x *PathValueList) Add(p Path, v string)

func (*PathValueList) AddFlags

func (x *PathValueList) AddFlags(p Path, v string, f SyncFlags)

func (PathValueList) Diff

func (PathValueList) Find

func (x PathValueList) Find(p Path) *PathValue

func (PathValueList) Unique

func (x PathValueList) Unique() PathValueList

assumes a sorted list

type Rational

type Rational struct {
	Num int64
	Den int64
}

Rational "n/m"

func FloatToRational

func FloatToRational(f float32) Rational

Beware: primitive conversion algorithm

func (*Rational) Addr

func (x *Rational) Addr() *Rational

func (Rational) IsZero

func (x Rational) IsZero() bool

func (Rational) MarshalText

func (x Rational) MarshalText() ([]byte, error)

func (Rational) String

func (x Rational) String() string

func (*Rational) UnmarshalText

func (x *Rational) UnmarshalText(data []byte) error

func (Rational) Value

func (x Rational) Value() float64

type RationalArray

type RationalArray []Rational

func NewRationalArray

func NewRationalArray(items ...Rational) RationalArray

func (RationalArray) MarshalXMP

func (a RationalArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (RationalArray) Typ

func (a RationalArray) Typ() ArrayType

func (*RationalArray) UnmarshalXMP

func (a *RationalArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Registry

type Registry struct {
	// contains filtered or unexported fields
}
var NsRegistry Registry = Registry{
	// contains filtered or unexported fields
}

func (*Registry) GetGroupNamespaces

func (r *Registry) GetGroupNamespaces(group NamespaceGroup) (NamespaceList, error)

func (*Registry) GetNamespace

func (r *Registry) GetNamespace(prefix string) (*Namespace, error)

func (*Registry) GetPrefix

func (r *Registry) GetPrefix(uri string) string

func (*Registry) Namespaces

func (r *Registry) Namespaces() NamespaceList

func (*Registry) Prefixes

func (r *Registry) Prefixes() []string

func (*Registry) RegisterNamespace

func (r *Registry) RegisterNamespace(ns *Namespace, groups NamespaceGroupList)

func (*Registry) Short

func (r *Registry) Short(uri, name string) string

type SplitInt

type SplitInt uint32

32bit Integer split byte-wise (06:13:14:61)

func (SplitInt) Uint32

func (x SplitInt) Uint32() uint32

func (*SplitInt) UnmarshalText

func (x *SplitInt) UnmarshalText(data []byte) error

func (SplitInt) Value

func (x SplitInt) Value() uint32

type StringArray

type StringArray []string

Unordered String Arrays

func NewStringArray

func NewStringArray(items ...string) StringArray

func (*StringArray) Add

func (x *StringArray) Add(v string) error

func (*StringArray) AddUnique

func (x *StringArray) AddUnique(v string) error

func (*StringArray) Contains

func (x *StringArray) Contains(v string) bool

func (*StringArray) Index

func (x *StringArray) Index(val string) int

func (StringArray) IsZero

func (x StringArray) IsZero() bool

func (StringArray) MarshalText

func (x StringArray) MarshalText() ([]byte, error)

func (StringArray) MarshalXMP

func (x StringArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (*StringArray) Remove

func (x *StringArray) Remove(v string)

func (StringArray) Typ

func (x StringArray) Typ() ArrayType

func (*StringArray) UnmarshalText

func (x *StringArray) UnmarshalText(data []byte) error

func (*StringArray) UnmarshalXMP

func (x *StringArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type StringList

type StringList []string

Ordered String Arrays

func NewStringList

func NewStringList(items ...string) StringList

func (*StringList) Add

func (x *StringList) Add(v string) error

func (*StringList) AddUnique

func (x *StringList) AddUnique(v string) error

func (*StringList) Contains

func (x *StringList) Contains(v string) bool

func (*StringList) Index

func (x *StringList) Index(val string) int

func (StringList) IsZero

func (x StringList) IsZero() bool

func (StringList) MarshalText

func (x StringList) MarshalText() ([]byte, error)

func (StringList) MarshalXMP

func (x StringList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (*StringList) Remove

func (x *StringList) Remove(v string)

func (StringList) Typ

func (x StringList) Typ() ArrayType

func (*StringList) UnmarshalText

func (x *StringList) UnmarshalText(data []byte) error

func (*StringList) UnmarshalXMP

func (x *StringList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type SyncDesc

type SyncDesc struct {
	Source  Path
	Dest    Path
	Flags   SyncFlags
	Convert ConverterFunc
}

type SyncDescList

type SyncDescList []*SyncDesc

type SyncFlags

type SyncFlags int

func ParseSyncFlag

func ParseSyncFlag(s string) SyncFlags

func ParseSyncFlags

func ParseSyncFlags(s string) (SyncFlags, error)

func (*SyncFlags) UnmarshalText

func (f *SyncFlags) UnmarshalText(data []byte) error

type Tag

type Tag struct {
	Key   string `xmp:"-" json:"key,omitempty"`
	Value string `xmp:"-" json:"value,omitempty"`
	Lang  string `xmp:"-" json:"lang,omitempty"`
}

type TagList

type TagList []Tag

func ListNativeFields

func ListNativeFields(v Model) (TagList, error)

func (TagList) MarshalXMP

func (x TagList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (*TagList) UnmarshalXMP

func (x *TagList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Time

type Time time.Time

Non-Standard Time

func NewTime

func NewTime(t time.Time) Time

func ParseTime

func ParseTime(value string) (Time, error)

func (Time) IsZero

func (x Time) IsZero() bool

func (Time) MarshalText

func (x Time) MarshalText() ([]byte, error)

func (Time) String

func (x Time) String() string

func (*Time) UnmarshalText

func (x *Time) UnmarshalText(data []byte) error

func (Time) Value

func (x Time) Value() time.Time

type UnknownNamespaceError

type UnknownNamespaceError struct {
	Name xml.Name
}

func (*UnknownNamespaceError) Error

func (e *UnknownNamespaceError) Error() string

type Unmarshaler

type Unmarshaler interface {
	UnmarshalXMP(d *Decoder, n *Node, model Model) error
}

type UnmarshalerAttr

type UnmarshalerAttr interface {
	UnmarshalXMPAttr(d *Decoder, a Attr) error
}

type Uri

type Uri string

8.2.2.10 Uri (Note: special handling as rdf:resource attribute without node content)

func NewUri

func NewUri(u string) Uri

func (Uri) IsZero

func (x Uri) IsZero() bool

func (*Uri) UnmarshalXMP

func (x *Uri) UnmarshalXMP(d *Decoder, node *Node, m Model) error

func (Uri) Value

func (x Uri) Value() string

type UriArray

type UriArray []Uri

func (UriArray) IsZero

func (x UriArray) IsZero() bool

func (UriArray) MarshalXMP

func (x UriArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (UriArray) Typ

func (x UriArray) Typ() ArrayType

func (*UriArray) UnmarshalXMP

func (x *UriArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type UriList

type UriList []Uri

func (UriList) IsZero

func (x UriList) IsZero() bool

func (UriList) MarshalXMP

func (x UriList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (UriList) Typ

func (x UriList) Typ() ArrayType

func (*UriList) UnmarshalXMP

func (x *UriList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Url

type Url string

func (Url) IsZero

func (x Url) IsZero() bool

func (Url) Value

func (x Url) Value() string

type UrlArray

type UrlArray []Url

func (UrlArray) MarshalXMP

func (x UrlArray) MarshalXMP(e *Encoder, node *Node, m Model) error

func (UrlArray) Typ

func (x UrlArray) Typ() ArrayType

func (*UrlArray) UnmarshalXMP

func (x *UrlArray) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type UrlList

type UrlList []Url

func (UrlList) MarshalXMP

func (x UrlList) MarshalXMP(e *Encoder, node *Node, m Model) error

func (UrlList) Typ

func (x UrlList) Typ() ArrayType

func (*UrlList) UnmarshalXMP

func (x *UrlList) UnmarshalXMP(d *Decoder, node *Node, m Model) error

type Version

type Version struct {
	Major int
	Minor int
	Patch int
}

func ParseVersion

func ParseVersion(s string) (Version, error)

func (Version) After

func (v Version) After(a Version) bool

func (Version) Before

func (v Version) Before(a Version) bool

func (Version) Between

func (v Version) Between(a, b Version) bool

func (Version) Equal

func (v Version) Equal(a Version) bool

func (Version) IsZero

func (v Version) IsZero() bool

func (Version) String

func (v Version) String() string

type Zero

type Zero interface {
	IsZero() bool
}

Jump to

Keyboard shortcuts

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