1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 #pragma once 7 8 #include <aws/core/Core_EXPORTS.h> 9 #include <aws/core/utils/memory/AWSMemory.h> 10 #include <aws/core/utils/memory/stl/AWSStreamFwd.h> 11 12 namespace Aws 13 { 14 namespace Utils 15 { 16 namespace Stream 17 { 18 /** 19 * Encapsulates and manages ownership of custom response streams. This is a move only type. 20 */ 21 class AWS_CORE_API ResponseStream 22 { 23 public: 24 /** 25 * sets underlying stream to nullptr 26 */ 27 ResponseStream(); 28 /** 29 * moves the underlying stream 30 */ 31 ResponseStream(ResponseStream&&); 32 /** 33 * Uses factory to allocate underlying stream 34 */ 35 ResponseStream(const Aws::IOStreamFactory& factory); 36 /** 37 * Takes ownership of an underlying stream. 38 */ 39 ResponseStream(IOStream* underlyingStreamToManage); 40 ResponseStream(const ResponseStream&) = delete; 41 ~ResponseStream(); 42 43 /** 44 * moves the underlying stream 45 */ 46 ResponseStream& operator=(ResponseStream&&); 47 ResponseStream& operator=(const ResponseStream&) = delete; 48 49 /** 50 * Gives access to underlying stream, but keep in mind that this changes state of the stream 51 */ GetUnderlyingStream()52 inline Aws::IOStream& GetUnderlyingStream() const { return *m_underlyingStream; } 53 54 private: 55 void ReleaseStream(); 56 57 Aws::IOStream* m_underlyingStream; 58 }; 59 60 class AWS_CORE_API DefaultUnderlyingStream : public Aws::IOStream 61 { 62 public: 63 using Base = Aws::IOStream; 64 65 DefaultUnderlyingStream(); 66 DefaultUnderlyingStream(Aws::UniquePtr<std::streambuf> buf); 67 virtual ~DefaultUnderlyingStream(); 68 }; 69 70 AWS_CORE_API Aws::IOStream* DefaultResponseStreamFactoryMethod(); 71 72 } //namespace Stream 73 } //namespace Utils 74 } //namespace Aws 75