...

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

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

     1  package exifundefined
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"encoding/binary"
     7  
     8  	"github.com/dsoprea/go-logging"
     9  
    10  	"github.com/dsoprea/go-exif/v3/common"
    11  )
    12  
    13  type TagExifA300FileSource uint32
    14  
    15  func (TagExifA300FileSource) EncoderName() string {
    16  	return "CodecExifA300FileSource"
    17  }
    18  
    19  func (af TagExifA300FileSource) String() string {
    20  	return fmt.Sprintf("0x%08x", uint32(af))
    21  }
    22  
    23  const (
    24  	TagUndefinedType_A300_SceneType_Others                   TagExifA300FileSource = 0
    25  	TagUndefinedType_A300_SceneType_ScannerOfTransparentType TagExifA300FileSource = 1
    26  	TagUndefinedType_A300_SceneType_ScannerOfReflexType      TagExifA300FileSource = 2
    27  	TagUndefinedType_A300_SceneType_Dsc                      TagExifA300FileSource = 3
    28  )
    29  
    30  type CodecExifA300FileSource struct {
    31  }
    32  
    33  func (CodecExifA300FileSource) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
    34  	defer func() {
    35  		if state := recover(); state != nil {
    36  			err = log.Wrap(state.(error))
    37  		}
    38  	}()
    39  
    40  	st, ok := value.(TagExifA300FileSource)
    41  	if ok == false {
    42  		log.Panicf("can only encode a TagExifA300FileSource")
    43  	}
    44  
    45  	ve := exifcommon.NewValueEncoder(byteOrder)
    46  
    47  	ed, err := ve.Encode([]uint32{uint32(st)})
    48  	log.PanicIf(err)
    49  
    50  	// TODO(dustin): Confirm this size against the specification. It's non-specific about what type it is, but it looks to be no more than a single integer scalar. So, we're assuming it's a LONG.
    51  
    52  	return ed.Encoded, 1, nil
    53  }
    54  
    55  func (CodecExifA300FileSource) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
    56  	defer func() {
    57  		if state := recover(); state != nil {
    58  			err = log.Wrap(state.(error))
    59  		}
    60  	}()
    61  
    62  	valueContext.SetUndefinedValueType(exifcommon.TypeLong)
    63  
    64  	valueLongs, err := valueContext.ReadLongs()
    65  	log.PanicIf(err)
    66  
    67  	return TagExifA300FileSource(valueLongs[0]), nil
    68  }
    69  
    70  func init() {
    71  	registerEncoder(
    72  		TagExifA300FileSource(0),
    73  		CodecExifA300FileSource{})
    74  
    75  	registerDecoder(
    76  		exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
    77  		0xa300,
    78  		CodecExifA300FileSource{})
    79  }
    80  

View as plain text