...
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 Tag0002InteropVersion struct {
12 InteropVersion string
13 }
14
15 func (Tag0002InteropVersion) EncoderName() string {
16 return "Codec0002InteropVersion"
17 }
18
19 func (iv Tag0002InteropVersion) String() string {
20 return iv.InteropVersion
21 }
22
23 type Codec0002InteropVersion struct {
24 }
25
26 func (Codec0002InteropVersion) 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.(Tag0002InteropVersion)
34 if ok == false {
35 log.Panicf("can only encode a Tag0002InteropVersion")
36 }
37
38 return []byte(s.InteropVersion), uint32(len(s.InteropVersion)), nil
39 }
40
41 func (Codec0002InteropVersion) 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 iv := Tag0002InteropVersion{
54 InteropVersion: valueString,
55 }
56
57 return iv, nil
58 }
59
60 func init() {
61 registerEncoder(
62 Tag0002InteropVersion{},
63 Codec0002InteropVersion{})
64
65 registerDecoder(
66 exifcommon.IfdExifIopStandardIfdIdentity.UnindexedString(),
67 0x0002,
68 Codec0002InteropVersion{})
69 }
70
View as plain text