Comments (7)
What kind of API do you have in mind?
from trial.protocol.
I think a...
size_t raw_node(view_type v);
It's the same signature as of literal()
. The difference is that the usual separators will be inserted as if a node was inserted.
An alternative approach would be to change literal()
parameters so you can state your intention and implementation choice there, but I don't like this idea.
TBH I think the hard task will be to choose the name. Is raw_node()
a good name? The implementation itself doesn't seem challenging.
from trial.protocol.
The requirement is that the inserted fragment is a valid JSON element. Otherwise the writer could end up being confused about the current separator and nesting level.
So we could call it element()
.
from trial.protocol.
The name element()
works for me.
from trial.protocol.
On a second thought, I think the code will be more readable if you use the name raw_element()
. To the non-initiated user, there is no difference between value and element (and indeed there is little difference between these two grammar rules in the json spec). To someone that just started to hack on a new codebase, the name choices between value()
and element()
would seem arbitrary and not intuitive. raw_value()
would be yet another option (but then again we're just one jump away from literal_value()
and two jumps from literal()
). Maybe rename literal()
to literal_ws()
and use the name literal()
for this function (but it'd be a bold API breakage here).
from trial.protocol.
An alternative solution is a separator()
function that writes the correct separator depending on context -- comma separator in a JSON array, alternating colon and comma separators in JSON object, and nothing in the top-level scope.
separator()
must be called before inserting raw data. This would allow us to insert raw data in chunks using multiple literal()
calls.
writer.value<begin_array>();
writer.separator();
writer.literal("null");
writer.separator();
writer.literal("nu");
writer.literal("ll");
writer.value<end_array>();
from trial.protocol.
That works.
from trial.protocol.
Related Issues (20)
- Change Allocator template to Allocator type HOT 1
- AllocatorAwareContainer HOT 4
- Use to_address() HOT 2
- Do not inherit from allocator HOT 1
- Use error specializations thoroughly HOT 1
- Compare current string-value with a string_view w/o allocating HOT 12
- reader.value<std::string>() should allow the allocator to be provided HOT 5
- String collector API should only be noexcept if `Collector()` is noexcept HOT 11
- Parser gets confused on non-NULL terminated string HOT 1
- Isn't boost::serialization::nvp missing in serialization support? HOT 1
- Split symbol::string and symbol::object_key events HOT 3
- Tests fail to build on boost 1.76 HOT 6
- Reader algorithms on chunk_reader HOT 4
- Parsers combinators HOT 7
- Merged matching & decode on Boost.Hana serialization
- Use asciidoc to document new pages HOT 4
- fails to build with latest visual studio
- Issues with constness in std::make_pair HOT 4
- Generator for real numbers shouldn't print the fractional part if there is none HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trial.protocol.