ifd_enumerate: Implemented ChildWithIfdIdentity.

pull/3/head
Dustin Oprea 2018-05-29 03:45:09 -04:00
parent dc6bb3e4b1
commit b7368b1fb4
3 changed files with 20 additions and 1 deletions

View File

@ -1412,6 +1412,7 @@ func Test_IfdBuilder_CreateIfdBuilderFromExistingChain_RealData(t *testing.T) {
t.Fatalf("Tag-type not as expected: %d != %d ITE=%s", recoveredIte.TagType, originalIte.TagType, recoveredIte)
}
// TODO(dustin): We're always accessing the addressable-data using the root-IFD. It shouldn't matter, but we'd rather access it from our specific IFD.
originalValueBytes, err := originalIte.ValueBytes(originalIndex.RootIfd.addressableData, originalIndex.RootIfd.ByteOrder)
log.PanicIf(err)
@ -1460,7 +1461,6 @@ func Test_IfdBuilder_CreateIfdBuilderFromExistingChain_RealData_WithUpdate(t *te
ucBt, err := exifBt.value.Ib().FindTagWithName("UserComment")
log.PanicIf(err)
// TODO(dustin): !! Create an example for this.
uc := TagUnknownType_9298_UserComment{
EncodingType: TagUnknownType_9298_UserComment_Encoding_ASCII,
EncodingBytes: []byte("TEST COMMENT"),

View File

@ -355,6 +355,23 @@ type Ifd struct {
thumbnailData []byte
}
func (ifd *Ifd) ChildWithIfdIdentity(ii IfdIdentity) (childIfd *Ifd, err error) {
defer func() {
if state := recover(); state != nil {
err = log.Wrap(state.(error))
}
}()
for _, childIfd := range ifd.Children {
if childIfd.Ii == ii {
return childIfd, nil
}
}
log.Panic(ErrTagNotFound)
return nil, nil
}
func (ifd *Ifd) TagValue(ite *IfdTagEntry) (value interface{}, err error) {
defer func() {
if state := recover(); state != nil {

View File

@ -24,6 +24,8 @@ type IfdTagEntry struct {
// ChildIfdName is a name if this tag represents a child IFD.
ChildIfdName string
// TODO(dustin): !! IB's host the child-IBs directly in the tag, but that's not the case here. Refactor to accomodate it for a consistent experience.
// IfdName is the IFD that this tag belongs to.
Ii IfdIdentity
}