...

Source file src/github.com/dsoprea/go-exif/v3/undefined/gps_001C_gps_area_information.go

Documentation: github.com/dsoprea/go-exif/v3/undefined

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

View as plain text