#include "Stroika/Foundation/StroikaPreComp.h"
#include <istream>
#include "Stroika/Foundation/Common/Common.h"
#include "Stroika/Foundation/Streams/InputStream.h"
#include "Stroika/Foundation/Streams/InternallySynchronizedInputStream.h"
#include "InputStreamFromStdIStream.inl"
Go to the source code of this file.
|
template<typename ELEMENT_TYPE , typename BASIC_ISTREAM_ELEMENT_TYPE , typename BASIC_ISTREAM_TRAITS_TYPE >
requires ((same_as<ELEMENT_TYPE, byte> and same_as<BASIC_ISTREAM_ELEMENT_TYPE, char>) or (same_as<ELEMENT_TYPE, Characters::Character> and same_as<BASIC_ISTREAM_ELEMENT_TYPE, wchar_t>)) |
| Ptr< ELEMENT_TYPE > | Stroika::Foundation::Streams::iostream::InputStreamFromStdIStream::New (basic_istream< BASIC_ISTREAM_ELEMENT_TYPE, BASIC_ISTREAM_TRAITS_TYPE > &originalStream) |
| |
◆ New()
template<typename ELEMENT_TYPE , typename BASIC_ISTREAM_ELEMENT_TYPE , typename BASIC_ISTREAM_TRAITS_TYPE >
requires ((same_as<ELEMENT_TYPE, byte> and same_as<BASIC_ISTREAM_ELEMENT_TYPE, char>) or (same_as<ELEMENT_TYPE, Characters::Character> and same_as<BASIC_ISTREAM_ELEMENT_TYPE, wchar_t>))
| Ptr< ELEMENT_TYPE > Stroika::Foundation::Streams::iostream::InputStreamFromStdIStream::New |
( |
basic_istream< BASIC_ISTREAM_ELEMENT_TYPE, BASIC_ISTREAM_TRAITS_TYPE > & |
originalStream | ) |
|
InputStreamFromStdIStream wraps an argument std::istream or std::wistream or std::basic_istream<> as a Stroika InputStream object
- Example Usage
stringstream tmpStrm;
tmpStrm << "some xml";
XML::SAXParse (InputStreamFromStdIStream::New<byte> (tmpStrm), MyCallback{});
- Note
- InputStreamFromStdIStream ::Close () does not call close on the owned basic_istream, 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 tmpStrm;
WriteTextStream_ (newDocXML, tmpStrm);
return InputStreamFromStdIStream::New<byte>(tmpStrm).ReadAll ();
- Example Usage
stringstream tmpStrm;
WriteTextStream_ (newDocXML, tmpStrm);
MyCallback myCallback;
XML::SAXParse (InputStreamFromStdIStream::New<byte> (tmpStrm), myCallback);
- Note
- Where wchar_t is 16 bits (Windows), a std::wistream holds UTF-16, so a Character may be two of its elements: the stream converts. It cannot seek by Character over the wistream itself, so seekable (the default) buffers what it reads (BufferedInputStream), offsets counting Characters from where it started - and, holding data read ahead, the wistream must not be read directly meanwhile.
-
The lifetime of the underlying created (shared_ptr) Stream must be >= the lifetime of the argument std::istream
-
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 istream be made from another thread. However, no data is cached in this class - it just delegates, so calls CAN be made the the underlying istream - 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 IStreamType object.
Definition at line 177 of file InputStreamFromStdIStream.inl.