Commit Graph

25 Commits (208788de28150f1ceba5fbfa2f3fc5f191ac3258)

Author SHA1 Message Date
Dustin Oprea bd92d354b0 Minor report-card fixes in v1 2020-06-12 02:22:22 -04:00
Dustin Oprea 9aa2497f7b Revert "type.go: Deinegrated `ErrUnhandledUnknownTypedTag`"
This reverts commit 4f2f9044e6.

Reintroduces errors from `UndefinedValue()` when the undefined-type is
unhandled.

- We now just return it rather than panic with it so that we can check
  for it directly rather than use `log.Is()`.

- We've updated the checks across the code accordingly.
2020-01-01 09:05:06 -05:00
Dustin Oprea 4f2f9044e6 type.go: Deinegrated `ErrUnhandledUnknownTypedTag`
Not actually used anywhere.
2019-12-31 07:39:41 -05:00
Dustin Oprea 69821c417f value_context.go: ValueContext now embeds value processing
The upshot of this is that generating a list of type-correct slices or a
string from a tag's value is now stupidly easy.

- Broke parsing into an independent type (parser.go:Parser).

- Moved primary value-processing logic to `ValueContext` so that it
  coexists with the actual data (though as much basic functionality as
  possible is implemented independently and reused here). This
  eliminates extremely ridiculously obtuse usage procedure.

- Deprecated almost all existing TagType functionality (in order to
  distance us from this now-legacy usage pattern). Existing
  functionality maintained for now. We'll drop it when we do the next
  release major.

- `ValueContext` is now passed by reference.
2019-12-29 05:48:34 -05:00
Dustin Oprea 7fb09bbf9f value_context.go: `ValueContext` now wraps members in accessors
It also embeds the type and byte-order so the VC can materialize/process
values self-sufficiently.
2019-12-29 00:35:35 -05:00
Dustin Oprea a69c3987eb type.go: Created `TagTypePrimitive` alias for `uint16`
Added a `Size()` method to it and decommissioned redundant
`TagTypeSize()` and `(TagType).Size()`.

- ifd_enumerate.go: Moved `ValueContext` definition to
  value_context.go .
2019-12-29 00:03:58 -05:00
Dustin Oprea 483dbacf14 type.go: Bugfix for math with embedded data. Add Format().
- ifd_builder.go
  - `BuilderTag` now embeds `ByteOrder`.
  - `BuilderTag` `String()` now prints value.

- type.go
  - `TagType` `ValueIsEmbedded()` renamed to `valueIsEmbedded()`.
  - Add `readRawEncoded()` method to `TagType`.
  - Add `Format()` method to `TagType` to isolate code for processing
    output strings for all types.
    - This will also print a suffixing ellipsis when `justFirst` is
      `true`.

  - Important bugfix for embedded values always being presented as
    four-bytes rather than being truncated to their reported unit-count
    bytes first. We tripped over this when some of our corresponding
    math was found to be wrong elsewhere.

- Minor reformatting.
2019-12-28 23:35:32 -05:00
Dustin Oprea d485d511fb type: Fixed string format. 2018-06-13 01:19:28 -04:00
Dustin Oprea 1abace139c type: Fix for ASCII value encodings having an extra NUL.
- Fixed some error messages for accuracy.
2018-06-13 00:48:30 -04:00
Dustin Oprea f998692895 type: Fixed FromString encoding for ASCII.
- We were appending a newline rather than NUL.
2018-06-10 18:45:34 -04:00
Dustin Oprea d79470a4f4 type: Now support marshaling from string to all types. 2018-06-10 03:25:44 -04:00
Dustin Oprea 98b3d60a12 type: Added encode and decode tests for all types but undefined.
- Updated `(TagType).Encode()` to use the byte-order it already has.
- TODO: Add tests for TypeUndefined.
2018-05-05 15:15:17 -04:00
Dustin Oprea 7166faa0be type: Renamed `ValueBytes()` to `Encode()`. 2018-05-05 02:17:43 -04:00
Dustin Oprea b18da0cc3d ifd_tag_entry: Added full test coverage.
- bytes are now stringified to a hex-byte representation.
2018-05-04 18:34:01 -04:00
Dustin Oprea f4cb06d79d type: Renamed ValueString() to ResolveAsString(). 2018-05-02 02:21:06 -04:00
Dustin Oprea 6ffca34f8e ifd_tag_entry: Implemented Value() and ValueString() wrappers.
- type: Added `(TagType).Resolve()` to return the parsed, typed value.
2018-04-30 02:32:08 -04:00
Dustin Oprea db33894cde unknown: Moved UnknownValue() to type.go . 2018-04-30 01:32:09 -04:00
Dustin Oprea d06a3c8963 ifd_builder: Implemented NewBuilderTagFromConfig() BT factory for testing.
- Updated IfdByteEncoder tests to use it instead of hacking-together
  their own BT's (makes for more standardized, consistent testing).

- Universally refactored all core IFD knowledge implemented upon a
  single IFD name to instead work with IfdIdentity instances, instead,
  in order to validate that we only recognize the IFDs only in the
  context of the correct parents in the hierarchy.

- Implemented standard testing byte-order (assigned to
  TestDefaultByteOrder).
2018-04-27 03:42:59 -04:00
Dustin Oprea 4bea09dc78 ifd_builder: Can now build a complete chain from existing EXIF.
- ifd_builder:
  - We now validate that `builderTag` instances are either a byte array
    or a child Ifd before allowing to add.
  - Renamed `builderTag.valueBytes` to `builderTag.value` (it's not
    necessarily bytes).
  - `builderTag` now gets the child IFD name if representing a child
    IFD.
  - Added ability to dump structure to string slice.
  - Added NewIfdBuilderFromExistingChain to reconstruct whole chain
    from a read IFD chain (collection).
  - Wrote IB dumper.
  - Added structural tests.
  - Moved ifd_tag_entry types to separate file.

- tags_unknown: Unknown-type tags can now satisfy the `UnknownTagValue`
interface to return `[]byte`.
  - `IfdTagEntry.ValueBytes` automatically uses this. Else, error if not
    `[]byte` or `string`.

- ifd_enumerate
  - Now embed `ByteOrder` in `Ifd` (we otherwise require it to be passed
    a bit too often).

- Renamed some occurences of "IFD" to "IB" where an actual IB in order
  to not be confusing.
2018-04-23 04:53:51 -04:00
Dustin Oprea 67a5e1f548 tags: Now read types.
- Required as the source-of-truth for writing.
2018-04-21 11:17:34 -04:00
Dustin Oprea 917e288adf Refactored byte-ordering to use standard binary.ByteOrder .
- ..rather than unnecessary custom implementation.
2018-04-17 06:18:31 -04:00
Dustin Oprea 53f74d18a1 type: Added encoding and complete encode/parse tests. 2018-04-17 06:06:51 -04:00
Dustin Oprea 42e678f6c2 type: Implemented workflow for undefined-type tags.
- Implemented for the straightforward tags. Noted what had to be done
  for the rest.
2018-04-16 00:30:39 -04:00
Dustin Oprea 172013e0f0 ifd: Implemented recursion. Refactored IFD seeking.
- tags.yaml: Uncommented previously-unhandleable tags.
2018-04-15 23:13:25 -04:00
Dustin Oprea 1511788a4e ifd: Implemented several layers of value processing. Done.
- It's going to be laborious to write unit-tests for, though.
2018-04-15 01:25:30 -04:00