github.com/boki/go-xmp@v1.0.1/models/dc/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 dc implements Dublin Core metadata as defined in XMP Specification Part 1. 16 package dc 17 18 import ( 19 "trimmer.io/go-xmp/xmp" 20 ) 21 22 type DataType string 23 24 const ( 25 DataTypeCollection DataType = "Collection" // Collection 26 DataTypeDataset DataType = "Dataset" // Dataset 27 DataTypeEvent DataType = "Event" // Event 28 DataTypeImage DataType = "Image" // Image 29 DataTypeInteractive DataType = "Interactive Resource" // Interactive Resource 30 DataTypeMoving DataType = "Moving" // Moving Image 31 DataTypePhysical DataType = "Physical Object" // Physical Object 32 DataTypeService DataType = "Service" // Service 33 DataTypeSoftware DataType = "Software" // Software 34 DataTypeSound DataType = "Sound" // Sound 35 DataTypeStillImage DataType = "Still Image" // Still Image 36 DataTypeText DataType = "Text" // Text 37 ) 38 39 // Locale 40 type LocaleArray []string 41 42 func (x LocaleArray) Default() string { 43 if len(x) == 0 { 44 return "" 45 } 46 return x[0] 47 } 48 49 func (x LocaleArray) Typ() xmp.ArrayType { 50 return xmp.ArrayTypeUnordered 51 } 52 53 func (x LocaleArray) MarshalXMP(e *xmp.Encoder, node *xmp.Node, m xmp.Model) error { 54 return xmp.MarshalArray(e, node, x.Typ(), x) 55 } 56 57 func (x *LocaleArray) UnmarshalXMP(d *xmp.Decoder, node *xmp.Node, m xmp.Model) error { 58 if len(node.Nodes) == 0 && len(node.Value) > 0 { 59 *x = append(*x, node.Value) 60 return nil 61 } 62 return xmp.UnmarshalArray(d, node, x.Typ(), x) 63 }