Date: Wed, 14 Feb 2024 00:21:34 +0100
On 13/02/2024 21.22, Yexuan Xiao wrote:
> I understand very well that without a parser, the design of JSON might seem useless, but C++ lacks a good IO library. The fundamental question is where to parse from? Using iostream? Iterators? Or std::span/string_view? Does anyone in the real world use these methods to parse JSON? Parsing from std::span seems like a feasible solution, but obviously not enough.
Parsing from a read-only character range seems to be doable.
That supports istream_iterator (for direct file access) as
well as reading mmap'd memory. If there's benefit for the
library to exploit the additional features of "better" iterator
categories, that's a QoI improvement possibility (similar to
some of the algorithms we already have).
> Allowing custom character types is certainly possible, and this design allows using almost any string type.
If you allow template parameters for those basic building blocks,
you need to say what requirements potential template arguments need
to satisfy. For example, would my string class need an "ends_with"
member function? Or a "+" concatenation operator? Or a copy
constructor?
Jens
> I understand very well that without a parser, the design of JSON might seem useless, but C++ lacks a good IO library. The fundamental question is where to parse from? Using iostream? Iterators? Or std::span/string_view? Does anyone in the real world use these methods to parse JSON? Parsing from std::span seems like a feasible solution, but obviously not enough.
Parsing from a read-only character range seems to be doable.
That supports istream_iterator (for direct file access) as
well as reading mmap'd memory. If there's benefit for the
library to exploit the additional features of "better" iterator
categories, that's a QoI improvement possibility (similar to
some of the algorithms we already have).
> Allowing custom character types is certainly possible, and this design allows using almost any string type.
If you allow template parameters for those basic building blocks,
you need to say what requirements potential template arguments need
to satisfy. For example, would my string class need an "ends_with"
member function? Or a "+" concatenation operator? Or a copy
constructor?
Jens
Received on 2024-02-13 23:21:46