1package plist 2 3import ( 4 "reflect" 5) 6 7// Property list format constants 8const ( 9 // Used by Decoder to represent an invalid property list. 10 InvalidFormat int = 0 11 12 // Used to indicate total abandon with regards to Encoder's output format. 13 AutomaticFormat = 0 14 15 XMLFormat = 1 16 BinaryFormat = 2 17 OpenStepFormat = 3 18 GNUStepFormat = 4 19) 20 21var FormatNames = map[int]string{ 22 InvalidFormat: "unknown/invalid", 23 XMLFormat: "XML", 24 BinaryFormat: "Binary", 25 OpenStepFormat: "OpenStep", 26 GNUStepFormat: "GNUStep", 27} 28 29type unknownTypeError struct { 30 typ reflect.Type 31} 32 33func (u *unknownTypeError) Error() string { 34 return "plist: can't marshal value of type " + u.typ.String() 35} 36 37type invalidPlistError struct { 38 format string 39 err error 40} 41 42func (e invalidPlistError) Error() string { 43 s := "plist: invalid " + e.format + " property list" 44 if e.err != nil { 45 s += ": " + e.err.Error() 46 } 47 return s 48} 49 50type plistParseError struct { 51 format string 52 err error 53} 54 55func (e plistParseError) Error() string { 56 s := "plist: error parsing " + e.format + " property list" 57 if e.err != nil { 58 s += ": " + e.err.Error() 59 } 60 return s 61} 62 63// A UID represents a unique object identifier. UIDs are serialized in a manner distinct from 64// that of integers. 65// 66// UIDs cannot be serialized in OpenStepFormat or GNUStepFormat property lists. 67type UID uint64 68 69// Marshaler is the interface implemented by types that can marshal themselves into valid 70// property list objects. The returned value is marshaled in place of the original value 71// implementing Marshaler 72// 73// If an error is returned by MarshalPlist, marshaling stops and the error is returned. 74type Marshaler interface { 75 MarshalPlist() (interface{}, error) 76} 77 78// Unmarshaler is the interface implemented by types that can unmarshal themselves from 79// property list objects. The UnmarshalPlist method receives a function that may 80// be called to unmarshal the original property list value into a field or variable. 81// 82// It is safe to call the unmarshal function more than once. 83type Unmarshaler interface { 84 UnmarshalPlist(unmarshal func(interface{}) error) error 85} 86