...
1 package exifundefined
2
3 import (
4 "encoding/binary"
5
6 "github.com/dsoprea/go-logging"
7
8 "github.com/dsoprea/go-exif/v3/common"
9 )
10
11 type Tag9000ExifVersion struct {
12 ExifVersion string
13 }
14
15 func (Tag9000ExifVersion) EncoderName() string {
16 return "Codec9000ExifVersion"
17 }
18
19 func (ev Tag9000ExifVersion) String() string {
20 return ev.ExifVersion
21 }
22
23 type Codec9000ExifVersion struct {
24 }
25
26 func (Codec9000ExifVersion) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
27 defer func() {
28 if state := recover(); state != nil {
29 err = log.Wrap(state.(error))
30 }
31 }()
32
33 s, ok := value.(Tag9000ExifVersion)
34 if ok == false {
35 log.Panicf("can only encode a Tag9000ExifVersion")
36 }
37
38 return []byte(s.ExifVersion), uint32(len(s.ExifVersion)), nil
39 }
40
41 func (Codec9000ExifVersion) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
42 defer func() {
43 if state := recover(); state != nil {
44 err = log.Wrap(state.(error))
45 }
46 }()
47
48 valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
49
50 valueString, err := valueContext.ReadAsciiNoNul()
51 log.PanicIf(err)
52
53 ev := Tag9000ExifVersion{
54 ExifVersion: valueString,
55 }
56
57 return ev, nil
58 }
59
60 func init() {
61 registerEncoder(
62 Tag9000ExifVersion{},
63 Codec9000ExifVersion{})
64
65 registerDecoder(
66 exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
67 0x9000,
68 Codec9000ExifVersion{})
69 }
70
View as plain text