4#include "Stroika/Foundation/StroikaPreComp.h"
8#include "Stroika/Foundation/Containers/Support/ReserveTweaks.h"
10#include "Stroika/Foundation/Execution/Common.h"
11#include "Stroika/Foundation/Execution/OperationNotSupportedException.h"
17#include "TextToBinary.h"
22using namespace Stroika::Foundation::Streams;
23using namespace Stroika::Foundation::Streams::TextToBinary;
46 if (fSrc_ !=
nullptr) {
49 Ensure (not IsOpenRead ());
50 Ensure (fSrc_ ==
nullptr);
54 return fSrc_ !=
nullptr;
59 if (fSrcBufferedSpan_.size () > 0) {
60 return fSrcBufferedSpan_.size ();
62 return fSrc_.AvailableToRead ();
66 Require (IsOpenRead ());
72 Require (IsOpenRead ());
73 Require (not intoBuffer.empty ());
76 if (not fSrcBufferedSpan_.empty ()) [[unlikely]] {
77 auto copiedIntoSpan = Memory::CopyBytes (fSrcBufferedSpan_.subspan (0, min (fSrcBufferedSpan_.size (), intoBuffer.size ())), intoBuffer);
78 Assert (copiedIntoSpan.size () >= 1);
79 fSrcBufferedSpan_ = fSrcBufferedSpan_.subspan (copiedIntoSpan.size ());
80 _fOffset += copiedIntoSpan.size ();
81 return intoBuffer.subspan (0, copiedIntoSpan.size ());
84 Assert (fSrcBufferedSpan_.empty ());
86 if (
auto o = fSrc_.GetRepRWRef ().Read (span{readBuf}, blockFlag)) {
87 if (
size_t nChars = o->size ()) {
90 span{readBuf, nChars}, Memory::SpanBytesCast<span<char8_t>> (span{fSrcBufferedRawBytes_})));
91 Assert (not fSrcBufferedSpan_.empty ());
100 Assert (blockFlag == eDontBlock);
106 AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
107 Require (IsOpenRead ());
113 byte fSrcBufferedRawBytes_[4];
114 span<byte> fSrcBufferedSpan_;
129 if (seekable == SeekableFlag::eSeekable) {
130 result = BufferedInputStream::New (result, SeekableFlag::eSeekable);
131 Ensure (result.IsSeekable ());
139 auto result = New (IterableToInputStream::New<Character> (srcText));
140 Ensure (result.IsSeekable ());
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper< T >, Common::Empty > UseBlockAllocationIfAppropriate
Use this to enable block allocation for a particular class. Beware of subclassing.
NoDataAvailableHandling
If eDontBlock passed to most Stream APIs, then when the code would do a blocking read,...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
static const UTFConvert kThe
Nearly always use this default UTFConvert.
nonvirtual span< TRG_T > ConvertSpan(span< const SRC_T > source, span< TRG_T > target) const
Convert between UTF-N encoded (including the special case of ASCII, and Latin1) character spans (e....
NOT a real mutex - just a debugging infrastructure support tool so in debug builds can be assured thr...
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
virtual bool IsSeekable() const =0
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.