Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
OutputStreamFromStdOStream.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <ostream>
#include "Stroika/Foundation/Common/Common.h"
#include "Stroika/Foundation/Streams/OutputStream.h"
#include "OutputStreamFromStdOStream.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::Streams::iostream
 

Typedefs

template<typename ELEMENT_TYPE >
using Stroika::Foundation::Streams::iostream::OutputStreamFromStdOStream::Ptr = typename OutputStream::Ptr< ELEMENT_TYPE >
 

Functions

template<typename ELEMENT_TYPE , typename BASIC_OSTREAM_ELEMENT_TYPE , typename BASIC_OSTREAM_TRAITS_TYPE >
requires ((same_as<ELEMENT_TYPE, byte> and same_as<BASIC_OSTREAM_ELEMENT_TYPE, char>) or (same_as<ELEMENT_TYPE, Characters::Character> and same_as<BASIC_OSTREAM_ELEMENT_TYPE, wchar_t>))
Ptr< ELEMENT_TYPE > Stroika::Foundation::Streams::iostream::OutputStreamFromStdOStream::New (basic_ostream< BASIC_OSTREAM_ELEMENT_TYPE, BASIC_OSTREAM_TRAITS_TYPE > &originalStream)
 

Detailed Description

Note
Code-Status: Alpha

TODO:

Definition in file OutputStreamFromStdOStream.h.

Typedef Documentation

◆ Ptr

template<typename ELEMENT_TYPE >
using Stroika::Foundation::Streams::iostream::OutputStreamFromStdOStream::Ptr = typedef typename OutputStream::Ptr<ELEMENT_TYPE>

very rough - going to need more stuff

A SocketStream wraps a a socket as a InputOutputStream - two separate but related streams.

The only real connection is that they share a common socket, and if it is closed, then the whole SocketStream will stop working.

\note   SocketStream adopts its owned ConnectionOrientedStreamSocket, so that a Close () on SocketStream
        will Close that socket as well.

        But SocketStream is an InputOutputStream - so you can close the input and output sides separately.
        If you call close on only one side of the input stream, Shutdown () will be used to shutdown
        just that end of the stream.

        Closing both sides of the stream (calling Close on the InputOutputStream) closes both sides and
        ShutDowns both sides of the socket.
Example Usage
ConnectionOrientedStreamSocket::Ptr connectionSocket = from_somewhere;
SocketStream::Ptr inOut = SocketStream::New (connectionSocket);
Note
Execution::InternallySynchronized not supported cuz cannot externally synchronize withot a lock around multiple operations.
Thread-Safety C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter

Definition at line 26 of file OutputStreamFromStdOStream.h.

Function Documentation

◆ New()

template<typename ELEMENT_TYPE , typename BASIC_OSTREAM_ELEMENT_TYPE , typename BASIC_OSTREAM_TRAITS_TYPE >
requires ((same_as<ELEMENT_TYPE, byte> and same_as<BASIC_OSTREAM_ELEMENT_TYPE, char>) or (same_as<ELEMENT_TYPE, Characters::Character> and same_as<BASIC_OSTREAM_ELEMENT_TYPE, wchar_t>))
Ptr< ELEMENT_TYPE > Stroika::Foundation::Streams::iostream::OutputStreamFromStdOStream::New ( basic_ostream< BASIC_OSTREAM_ELEMENT_TYPE, BASIC_OSTREAM_TRAITS_TYPE > &  originalStream)

OutputStreamFromStdOStream wraps an argument std::ostream or std::wostream or std::basic_ostream<> as a Stroika OutputStream object

\note   OutputStreamFromStdOStream ::Close () does not call close on the owned basic_ostream, because there is no such stdC++ method (though filestream has one)

Default seekability should be determined automatically, but for now, I cannot figure out how...

Example Usage
stringstream s;
OutputStreamFromStdOStream<byte>::Ptr so = OutputStreamFromStdOStream<byte>::New (s);
const char kData_[] = "ddasdf3294234";
so.Write (reinterpret_cast<const byte*> (std::begin (kData_)), reinterpret_cast<const byte*> (std::begin (kData_)) + strlen (kData_));
EXPECT_TRUE (s.str () == kData_);
Note
The lifetime of the underlying created (shared_ptr) Stream must be <= the lifetime of the argument std::ostream
Thread-Safety C++-Standard-Thread-Safety-For-Envelope-Plus-Must-Externally-Synchronize-Letter It is also up to the caller to assure no references to or calls to that ostream be made from another thread. However, no data is cached in this class - it just delegates, so calls CAN be made the the underlying ostream - so long as not concurrently.

If you pass in eInternallySynchronized, the internal rep is internally synchronized, but you still must assure no other threads access the OStreamType object.

Definition at line 101 of file OutputStreamFromStdOStream.inl.