go-exif/v2/undefined/gps_001B_gps_processing_method.go
Dustin Oprea 08ac8466dd ifd.go: Add type system for IFD IDs, names, and paths
This allows us to pass around individual tokens that we can use to
generate IDs, names, and qualified and non-qualified IFD paths, rather
than [necessarily] having to pass or store them individually.

The previous global variables were strings. Now they are IfdIdentity structs
and have been renamed to be more accurate (in general, as well as for this).
The previous variables have been kept but are now just assigned to the newer
variables. This is backwards-compatibility that will be removed in the future.
2020-05-20 14:07:16 -04:00

66 lines
1.4 KiB
Go

package exifundefined
import (
"encoding/binary"
"github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v2/common"
)
type Tag001BGPSProcessingMethod struct {
string
}
func (Tag001BGPSProcessingMethod) EncoderName() string {
return "Codec001BGPSProcessingMethod"
}
func (gpm Tag001BGPSProcessingMethod) String() string {
return gpm.string
}
type Codec001BGPSProcessingMethod struct {
}
func (Codec001BGPSProcessingMethod) 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.(Tag001BGPSProcessingMethod)
if ok == false {
log.Panicf("can only encode a Tag001BGPSProcessingMethod")
}
return []byte(s.string), uint32(len(s.string)), nil
}
func (Codec001BGPSProcessingMethod) 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 Tag001BGPSProcessingMethod{valueString}, nil
}
func init() {
registerEncoder(
Tag001BGPSProcessingMethod{},
Codec001BGPSProcessingMethod{})
registerDecoder(
exifcommon.IfdGpsInfoStandardIfdIdentity.UnindexedString(),
0x001b,
Codec001BGPSProcessingMethod{})
}