github.com/boki/go-xmp@v1.0.1/models/xmp_bj/types.go (about) 1 // Copyright (c) 2017-2018 Alexander Eichhorn 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 // Package xmpbj implements the XMP Basic Job Ticket namespace as defined by XMP Specification Part 2. 16 package xmpbj 17 18 import ( 19 "trimmer.io/go-xmp/xmp" 20 ) 21 22 // Part 2: 1.2.5.1 Job 23 type Job struct { 24 ID string `xmp:"stJob:id,attr"` 25 Name string `xmp:"stJob:name,attr"` 26 Url xmp.Uri `xmp:"stJob:url,attr"` 27 } 28 29 func (x Job) IsZero() bool { 30 return x.ID == "" && x.Name == "" && x.Url == "" 31 } 32 33 func (x Job) MarshalXMP(e *xmp.Encoder, node *xmp.Node, m xmp.Model) error { 34 if x.IsZero() { 35 return nil 36 } 37 type _t Job 38 return e.EncodeElement(_t(x), node) 39 } 40 41 type JobArray []*Job 42 43 func (x JobArray) Typ() xmp.ArrayType { 44 return xmp.ArrayTypeUnordered 45 } 46 47 func (x JobArray) MarshalXMP(e *xmp.Encoder, node *xmp.Node, m xmp.Model) error { 48 return xmp.MarshalArray(e, node, x.Typ(), x) 49 } 50 51 func (x *JobArray) UnmarshalXMP(d *xmp.Decoder, node *xmp.Node, m xmp.Model) error { 52 return xmp.UnmarshalArray(d, node, x.Typ(), x) 53 }