Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ToSeekableInputStream.h File Reference
#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 >
 

Detailed Description

Note
Code-Status: Beta

Definition in file ToSeekableInputStream.h.

Function Documentation

◆ New()

template<typename ELEMENT_TYPE >
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).

Example Usage
InputStream::Ptr<Character> in = ToSeekableInputStream::New<Character> (existingInputStream);
Note
this helper does not require it be given the input stream at SeekOffset 0, but for pretty obvious reasons it cannot produce a stream that permits seeking backwards from where it starts. This is checked via assertions.
this helper may be problematic with very large streams, as it caches the stream in memory as it reads, and would eventually run out.

Definition at line 15 of file ToSeekableInputStream.inl.