Class used as an adapter to queue of streams.
More...
#include </home/breiker/code/git/cereal_fwd_github/include/cereal/details/extendable_binary_details.hpp>
|
| | StreamAdapter (std::istream &stream, std::stringstream &sharedObjectStream, std::size_t maxBytesInSharedStream) |
| | Construct new object with main and secondary stream. More...
|
| |
| void | pushReadingPos (StreamPos &streamPos) |
| | Pushes new reading position on the stream. More...
|
| |
| std::size_t | readBinary (void *const data, std::size_t size) |
| | Reads binary data from stream which is on top. More...
|
| |
| void | skipData (std::size_t size) |
| | Discards size bytes from the input stream. More...
|
| |
| void | checkIfMaxSize (std::size_t size, std::ostream &stream) |
| | Check if by adding size bytes limit for max copied data is hit. More...
|
| |
| void | readToOtherStream (std::size_t size, std::ostream &stream) |
| | Reads size bytes from the input stream and copies them to other stream. More...
|
| |
Class used as an adapter to queue of streams.
Two streams are managed. Main stream can be used only for reading and reading position can move only forward. Position of reading for second stream can be moved freely. For second stream queue of start and end positions is kept. New StreamPos can be added when last StreamPos was not yet read fully. When StreamPos::end for top StreamPos is reached reading from next StreamPos is continued. If there are no StreamPos on the queue data is read from main stream.
Additional functions for copying data from one stream to the other are provided (readToOtherStream()).
◆ StreamAdapter()
| cereal::extendable_binary_detail::StreamAdapter::StreamAdapter |
( |
std::istream & |
stream, |
|
|
std::stringstream & |
sharedObjectStream, |
|
|
std::size_t |
maxBytesInSharedStream |
|
) |
| |
|
inline |
Construct new object with main and secondary stream.
- Parameters
-
| stream | main reading stream |
| sharedObjectStream | secondary stream for which new reading positions could be given |
| maxBytesInSharedStream | max size of data copied to other stream in readToOtherStream() method |
◆ checkIfMaxSize()
| void cereal::extendable_binary_detail::StreamAdapter::checkIfMaxSize |
( |
std::size_t |
size, |
|
|
std::ostream & |
stream |
|
) |
| |
|
inline |
Check if by adding size bytes limit for max copied data is hit.
- Parameters
-
| size | additional size bytes to read |
| stream | Stream used for data copying Throws Exception if limit would be hit |
◆ pushReadingPos()
| void cereal::extendable_binary_detail::StreamAdapter::pushReadingPos |
( |
StreamPos & |
streamPos | ) |
|
|
inline |
Pushes new reading position on the stream.
- Parameters
-
| streamPos | new reading pos, saves reference which has to be valid for whole object lifetime Throws if not enough bytes are read |
◆ readBinary()
| std::size_t cereal::extendable_binary_detail::StreamAdapter::readBinary |
( |
void *const |
data, |
|
|
std::size_t |
size |
|
) |
| |
|
inline |
Reads binary data from stream which is on top.
- Parameters
-
| data | address to read to |
| size | size of data to read Size has to be less or equal to data available at the current stream position. That is:
- If using streamPos on queue - end of current streamPos
- If using mainStream - end of mainStream Throws if not enough bytes are read.
|
◆ readToOtherStream()
| void cereal::extendable_binary_detail::StreamAdapter::readToOtherStream |
( |
std::size_t |
size, |
|
|
std::ostream & |
stream |
|
) |
| |
|
inline |
Reads size bytes from the input stream and copies them to other stream.
- Parameters
-
| size | The number of bytes to read and copy |
| stream | Stream to copy data to Throws Exception if not enough bytes are read |
◆ skipData()
| void cereal::extendable_binary_detail::StreamAdapter::skipData |
( |
std::size_t |
size | ) |
|
|
inline |
Discards size bytes from the input stream.
- Parameters
-
| size | The number of bytes of data Throws if not enough bytes are read |
The documentation for this class was generated from the following file: