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