go-exif/v2/undefined/exif_A000_flashpix_version.go
Dustin Oprea 32a5d88770 New integration of common/ and undefined/ subpackages
- common/type.go: Add FormatFromType() .
- Renamed common/type_encode.go to common/value_encoder.go .
2020-01-12 18:56:35 -05:00

66 lines
1.3 KiB
Go

package exifundefined
import (
"encoding/binary"
"github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v2/common"
)
type TagA000FlashpixVersion struct {
string
}
func (TagA000FlashpixVersion) EncoderName() string {
return "CodecA000FlashpixVersion"
}
func (fv TagA000FlashpixVersion) String() string {
return fv.string
}
type CodecA000FlashpixVersion struct {
}
func (CodecA000FlashpixVersion) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
defer func() {
if state := recover(); state != nil {
err = log.Wrap(state.(error))
}
}()
s, ok := value.(TagA000FlashpixVersion)
if ok == false {
log.Panicf("can only encode a TagA000FlashpixVersion")
}
return []byte(s.string), uint32(len(s.string)), nil
}
func (CodecA000FlashpixVersion) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
defer func() {
if state := recover(); state != nil {
err = log.Wrap(state.(error))
}
}()
valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
valueString, err := valueContext.ReadAsciiNoNul()
log.PanicIf(err)
return TagA000FlashpixVersion{valueString}, nil
}
func init() {
registerEncoder(
TagA000FlashpixVersion{},
CodecA000FlashpixVersion{})
registerDecoder(
exifcommon.IfdPathStandardExif,
0xa000,
CodecA000FlashpixVersion{})
}