Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
InputSubStream.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Streams_InputSubStream_h_
5#define _Stroika_Foundation_Streams_InputSubStream_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <memory>
10#include <optional>
11
12#include "Stroika/Foundation/Common/Common.h"
15
16/**
17 * \file
18 *
19 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
20 *
21 */
22
23namespace Stroika::Foundation::Streams::InputSubStream {
24
25 /**
26 * @brief InputSubStream is an InputStream::Ptr<ELEMENT_TYPE> which provides buffered access.
27 * This is useful if calls to the underling stream source can be expensive. This class
28 * loads chunks of the stream into memory, and reduces calls to the underlying stream.
29 *
30 * \note Execution::InternallySynchronized not supported cuz cannot externally synchronize withot a lock around multiple operations.
31 *
32 * \note \em Thread-Safety <a href="Thread-Safety.md#C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter">C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter</a>
33 */
34 template <typename ELEMENT_TYPE>
36
37 /**
38 * start and end are offsets in the real underlying stream which map to 0, and if specified, end-start (which is this streams ends);
39 * start defaults (if Missing) to the current offset (not necessarily zero for that stream), and end defaults to the actual end of the underlying stream.
40 *
41 * \par Example Usage
42 * \code
43 * InputStream::Ptr<byte> in = InputSubStream<byte>::New (fromStream, 0, contentLength);
44 * \endcode
45 *
46 * \par Example Usage
47 * \code
48 * CallExpectingBinaryInputStreamPtr (InputSubStream<byte>::New (fromStream, 0, contentLength))
49 * \endcode
50 */
51 template <typename ELEMENT_TYPE>
52 auto New (const typename InputStream::Ptr<ELEMENT_TYPE>& realIn, const optional<SeekOffsetType>& start, const optional<SeekOffsetType>& end)
54 template <typename ELEMENT_TYPE>
55 auto New (Execution::InternallySynchronized internallySynchronized, const typename InputStream::Ptr<ELEMENT_TYPE>& realIn,
56 const optional<SeekOffsetType>& start, const optional<SeekOffsetType>& end) -> Ptr<ELEMENT_TYPE>;
57
58}
59
60/*
61 ********************************************************************************
62 ***************************** Implementation Details ***************************
63 ********************************************************************************
64 */
65#include "InputSubStream.inl"
66
67#endif /*_Stroika_Foundation_Streams_InputSubStream_h_*/
typename InputStream::Ptr< ELEMENT_TYPE > Ptr
InputSubStream is an InputStream::Ptr<ELEMENT_TYPE> which provides buffered access....
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...