Skip to content

Conversation

cdunn2001
Copy link
Contributor

Template std::string as String.

Maybe this is pointless? The issue is not so much the representation of the JSON strings in the API, but rather of serialization. I want to allow users to specify how we translate between internal char* and the public representation. Users should be able to supply their own converters:

template<>
fromJson<String>(char const* beg, char const* end, String* result) {
  ...
}
template<>
toJson<String>(String const& input, (*alloc)(size_t n), char const** result) {
}

We can provide defaults for std::string, but our default would not handle UTF-32, e.g.

What to you think? (See #423.)

@cdunn2001 cdunn2001 added this to the 2.0.0 milestone Feb 14, 2016
I doubt anyone uses this, and it is an implementation detail. There must
be a better way to handle this. Maybe an injected implementation?
@baylesj
Copy link
Contributor

baylesj commented Jun 21, 2019

If we wanted to do something fancy like wide strings, wouldn't we want the internal representation to be using wchar_t? It's not clear to me what the value add of the String template is if we don't also adjust the backing field from char to a similar template, which seems bug-prone.

@BillyDonahue
Copy link
Contributor

Well, the CharType isn't the only thing that can vary on a std::basic_string.

I can see how there would still be value in import and export from strings that use unusual kinds of allocator, for example, even if they are still char-based.

@baylesj baylesj closed this Jun 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants