json icon indicating copy to clipboard operation
json copied to clipboard

[serializer] Added handling for NaN & Inf.

Open klemens-morgenstern opened this issue 2 years ago • 4 comments

Closes #397

klemens-morgenstern avatar Feb 05 '22 17:02 klemens-morgenstern

Exposition (the .qbk files) needs to be updated explaining serialization error handling and format conversion of nan/inf

vinniefalco avatar Feb 05 '22 18:02 vinniefalco

The approach we described in the issue is somewhat different:

  1. Serializer options are empty by default (not nulls).
  2. If an option is empty and the corresponding special value is encountered — an error is produced.
  3. Thus, users should be able to use options and error codes together. If an error_code isn't used, the serializer throws.

Top level APIs for serialzer should probably look like this:

serializer::serializer(serializer_options const& = {});

serializer::read(char* dest, std::size_t size, serializer_options const& = {});
serializer::read(char* dest, std::size_t size, error_code& ec, serializer_options const& = {});
serializer::read(char* dest, std::size_t size, std::error_code& ec, serializer_options const& = {}); // for convenience

grisumbras avatar Feb 05 '22 18:02 grisumbras

Top level APIs for serialzer should probably look like this:

Well no, the serializer should be constructed with the options, they should not be per-read. Alternatively there can be a set_options function. But it should be specified that undefined behavior results if the options are changed in the middle of serialization.

vinniefalco avatar Feb 05 '22 19:02 vinniefalco

Superceded by #884

grisumbras avatar Jun 02 '23 09:06 grisumbras