giacomodrago / minijson_reader

A DOM-less JSON parser that can parse a JSON object without allocating a single byte of memory on the heap
Other
66 stars 20 forks source link

C++17 features #33

Closed hemalbavishi closed 2 years ago

hemalbavishi commented 2 years ago

Hello,

I would like to check possibility of using minijson_reader for C++14 as QNX compiler I am using supports upto C++14 considering functional safety. Can you please let me know which particular feature of C++17 is being used in the header file? Moreover, I also want to know whether minijson_reader code can be used in ASIL B Application since it's not using any dynamic memory?

Many thanks!

Regards, Hemal Bavishi

giacomodrago commented 2 years ago

Hi,

Sorry, bad news for your use case: unfortunately the code is littered with C++17 features. Some of them can be done without, but for others more work would be needed: take std::from_chars for example, the first decent function to parse numbers that the C++ standard gifted onto us since 1998. You can't use strtod because it's ancient stuff (among other things, it takes the C locale - a piece of global mutable state coming from the dark ages - into account...), and using standard streams or Boost comes with a different set of drawbacks.

As for dynamic memory usage, there are no explicit memory allocations if you use a buffer_context, but over time I realized that my wording ("without allocating a single byte of memory") is a bit too strong: this library uses exceptions, and where/how they are allocated is implementation defined as per the standard.

There may be other boxes that this library doesn't tick when it comes to automotive and safety standards in general.

I am sorry this doesn't help, but I haven't got the resources to do more than this for you. Maybe other libraries are better suited for your use case, and actually if you need to parse a very specific set of JSON messages under tight constraints you may be better off writing an ad-hoc microlibrary just for your project.

Best