Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Copy.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_Copy_h_
5#define _Stroika_Foundation_Streams_Copy_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
11
12/**
13 * \file
14 *
15 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
16 *
17 * TODO:
18 * @todo Provide a variant of CopyAll which is safely always cancelable (at least of underlying src and target streams cancelable). Maybe this
19 * is already done? Or maybe this involves using ReadSome() and blocking on availability of more? CONSIDER
20 * So far have not encountered a need.
21 *
22 * @todo Redo API (at least overloads) with progress tracker(?)
23 */
24
25namespace Stroika::Foundation::Streams {
26
27 /**
28 * @brief Copy the contents of stream 'from' to stream 'to'
29 *
30 * \note ***Cancelation Point*** (but may not always be cancelable - may cancel - depends on argument streams Read/Write routines)
31 */
32 template <typename ELEMENT_TYPE>
33 void CopyAll (typename InputStream::Ptr<ELEMENT_TYPE> from, typename OutputStream::Ptr<ELEMENT_TYPE> to, size_t bufferSize = 10 * 1024);
34
35 /**
36 * @brief Copy the contents of stream 'from' to stream 'to', by reading ALL of from into memory at once, and then writing it to 'to' (fails if not enough memory to hold entire from stream in RAM)
37 *
38 * \note ***Cancelation Point*** (but may not always be cancelable - may cancel - depends on argument streams Read/Write routines)
39 */
40 template <typename ELEMENT_TYPE>
41 void CopyAll_OneRead (typename InputStream::Ptr<ELEMENT_TYPE> from, typename OutputStream::Ptr<ELEMENT_TYPE> to);
42
43 /**
44 * @brief Copy the contents of stream 'from' to stream 'to', by reading a chunk at a time - tends to do multiple reads and writes - but works with arbitrarily large stream
45 *
46 * \note ***Cancelation Point*** (but may not always be cancelable - may cancel - depends on argument streams Read/Write routines)
47 */
48 template <typename ELEMENT_TYPE>
49 void CopyAll_Buffered (typename InputStream::Ptr<ELEMENT_TYPE> from, typename OutputStream::Ptr<ELEMENT_TYPE> to, size_t bufferSize = 10 * 1024);
50
51}
52
53/*
54 ********************************************************************************
55 ***************************** Implementation Details ***************************
56 ********************************************************************************
57 */
58#include "Copy.inl"
59
60#endif /*_Stroika_Foundation_Streams_Copy_h_*/
void CopyAll_Buffered(typename InputStream::Ptr< ELEMENT_TYPE > from, typename OutputStream::Ptr< ELEMENT_TYPE > to, size_t bufferSize=10 *1024)
Copy the contents of stream 'from' to stream 'to', by reading a chunk at a time - tends to do multipl...
Definition Copy.inl:37
void CopyAll_OneRead(typename InputStream::Ptr< ELEMENT_TYPE > from, typename OutputStream::Ptr< ELEMENT_TYPE > to)
Copy the contents of stream 'from' to stream 'to', by reading ALL of from into memory at once,...
Definition Copy.inl:26
void CopyAll(typename InputStream::Ptr< ELEMENT_TYPE > from, typename OutputStream::Ptr< ELEMENT_TYPE > to, size_t bufferSize=10 *1024)
Copy the contents of stream 'from' to stream 'to'.
Definition Copy.inl:15