Make value types replacable (by providing type traits) #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now, picojson has fixed the types used to represent various types of JSON (e.g. number, string, boolean, ...). But there has been a constant request to replace how the numbers are represented (which has been handled to some extent by adding the
PICOJSON_USE_INT64
flag).The ideal way to answer such requests is to templatize the
value
type so that the types used for storing the JSON values via type traits (using#ifdef
s to switch between the types is not an answer, since it would cause compile or link-time errors when more than one module uses picojson with different set of types).This PR does that. It implements a type trait (only for numbers at the moment), so that users can define their own set of traits and use the templatized value type (
value_t<TraitsT>
).I am going to merge this branch to master if I anybody actually starts using the feature (and if he/she provides the source code that can be used for testing the feature).