#include "Stroika/Foundation/StroikaPreComp.h"#include "Stroika/Foundation/Streams/InputStream.h"#include "Stroika/Foundation/Traversal/Iterable.h"#include "ToSeekableInputStream.inl"Go to the source code of this file.
Namespaces | |
| namespace | Stroika::Foundation |
Functions | |
| template<typename ELEMENT_TYPE > | |
| auto | Stroika::Foundation::Streams::ToSeekableInputStream::New (const Ptr< ELEMENT_TYPE > &in) -> Ptr< ELEMENT_TYPE > |
Definition in file ToSeekableInputStream.h.
| auto Stroika::Foundation::Streams::ToSeekableInputStream::New | ( | const Ptr< ELEMENT_TYPE > & | in | ) | -> Ptr<ELEMENT_TYPE> |
Not all input streams are seekable, but throwing a little memory at it, its easy to assure they are all seekable.
That's what this utility does: maps the given input stream into a functionally identical one, except possibly adding seekability.
If the argument stream is already seekable, New () just returns its argument (so perhaps a misnomer but I thought better to follow factory pattern).
A socket is the canonical stream you might want this for: there is nowhere to seek back TO, because the bytes are gone once read (IO::Network::SocketStream::IsSeekable () returns false; so does InputStreamFromStdIStream constructed eNotSeekable - over cin, say). Wrapping one lets code that must read the same input twice do so:
That two-pass shape is why this exists: see Providers::LibXML2::Provider::SAXParse (), which needs it when asked to both validate against a schema and report parse events, because that reads twice.
Definition at line 16 of file ToSeekableInputStream.inl.