registration.go (888B)
1 package exifundefined 2 3 import ( 4 "github.com/dsoprea/go-logging" 5 ) 6 7 // UndefinedTagHandle defines one undefined-type tag with a corresponding 8 // decoder. 9 type UndefinedTagHandle struct { 10 IfdPath string 11 TagId uint16 12 } 13 14 func registerEncoder(entity EncodeableValue, encoder UndefinedValueEncoder) { 15 typeName := entity.EncoderName() 16 17 _, found := encoders[typeName] 18 if found == true { 19 log.Panicf("encoder already registered: %v", typeName) 20 } 21 22 encoders[typeName] = encoder 23 } 24 25 func registerDecoder(ifdPath string, tagId uint16, decoder UndefinedValueDecoder) { 26 uth := UndefinedTagHandle{ 27 IfdPath: ifdPath, 28 TagId: tagId, 29 } 30 31 _, found := decoders[uth] 32 if found == true { 33 log.Panicf("decoder already registered: %v", uth) 34 } 35 36 decoders[uth] = decoder 37 } 38 39 var ( 40 encoders = make(map[string]UndefinedValueEncoder) 41 decoders = make(map[UndefinedTagHandle]UndefinedValueDecoder) 42 )