implement standard iostreams based on nng::msg#28
Open
EvanBalster wants to merge 6 commits intocwzx:masterfrom
Open
implement standard iostreams based on nng::msg#28EvanBalster wants to merge 6 commits intocwzx:masterfrom
EvanBalster wants to merge 6 commits intocwzx:masterfrom
Conversation
Fix output overrun when using offset Fix open_range returns
Author
|
I've fleshed the implementation out somewhat. I've gotten it working on osx/clang in addition to windows/msvc. It also now supports unusual character types such as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a complete header-only implementation of the
streambuf, andiostreaminterfaces for NNG messages.I am not sure if supplementary features like this belong in NNGPP, but it's quite useful. As such, consider this PR tentative. I haven't yet conformed it to NNGPP's code style as I expect some discussion about whether it ought to be integrated.
For example:
This code relies on
nng_msg_capacityandnng_msg_reservefunctions, which I contributed to NNG only a few days ago. As such it requires the "tip" version of NNG to function.In addition to reading and writing
nng::msglike a file, a sub-range of the message may be specified usingopen_rangeor additional constructor arguments. This is intended for exposing sections of messages or omitting application-layer headers from I/O operations. The parameter scheme for specifying ranges is a recent addition and might need more thinking.Unlike ordinary iostreams,
msgbufandmsgstreamare copyable, and multiplemsgbufmay refer to the same message at the same time. No special provisions are made for concurrency.I have performed basic consistency testing with this facility in my own library. If it's put into production, more detailed unit tests are probably necessary.
† Note: similar to most implementations of std::stringstream, these classes lack full support for the ios_base::app flag.