Open reventlov opened 2 years ago
The implementation of this is probably to update the C++ UpdateFromTextStream()
methods to take an optional output parameter, or to build a parallel API like UpdateFromTextStreamOrReturnError()
. I haven't given a lot of thought to the best way to actually return the error(s). Right now, the update bails out if there is any error, but I can imagine having an allow_partial_update
option similar to the allow_partial_output
option for text output, so ideally the API would allow multiple errors to be returned.
A (maybe) comprehensive list of the places that are are likely to need to be changed:
UpdateFromTextStream()
on generated structure (struct
and bits
) views; tests in text_format_test.cc, nested_structure_test.cc, bits_test.cc, anonymous_bits_test.cc, uint_sizes_test.cc, and complex_structure_test.ccUpdateFromTextStream()
on virtual fields; tests in virtual_field_test.ccUpdateFromTextStream()
on arrays, which really just calls ReadArrayFromTextStream()
; tests in emboss_array_view_test.ccUpdateFromTextStream()
on enum
; tests in emboss_enum_view_test.ccUpdateFromTextStream()
on built-in types: Flag
, UInt
, Int
, Bcd
, and Float
; tests are all in emboss_prelude_test.ccUpdateFromText
convenience function should also get an optional parameter or alternate API.UpdateFromText
or UpdateFromTextStream
in text-format.md, cpp-guide.md, and cpp-reference.md.
UpdateFromText()
just returns abool
indicating success/failure. There is currently no way to find out where parsing failed, which makes it difficult to debug manually-written text format structs.