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;
45 if (fSrc_ !=
nullptr) {
48 Ensure (not IsOpenRead ());
49 Ensure (fSrc_ ==
nullptr);
53 return fSrc_ !=
nullptr;
58 if (fSrcBufferedSpan_.size () > 0) {
59 return fSrcBufferedSpan_.size ();
61 return fSrc_.AvailableToRead ();
65 Require (IsOpenRead ());
71 Require (IsOpenRead ());
72 Require (not intoBuffer.empty ());
75 if (not fSrcBufferedSpan_.empty ()) [[unlikely]] {
76 auto copiedIntoSpan = Memory::CopyBytes (fSrcBufferedSpan_.subspan (0, min (fSrcBufferedSpan_.size (), intoBuffer.size ())), intoBuffer);
77 Assert (copiedIntoSpan.size () >= 1);
78 fSrcBufferedSpan_ = fSrcBufferedSpan_.subspan (copiedIntoSpan.size ());
79 _fOffset += copiedIntoSpan.size ();
80 return intoBuffer.subspan (0, copiedIntoSpan.size ());
83 Assert (fSrcBufferedSpan_.empty ());
85 if (
auto o = fSrc_.GetRepRWRef ().Read (span{readBuf}, blockFlag)) {
86 if (
size_t nChars = o->size ()) {
89 span{readBuf, nChars}, Memory::SpanBytesCast<span<char8_t>> (span{fSrcBufferedRawBytes_})));
90 Assert (not fSrcBufferedSpan_.empty ());
99 Assert (blockFlag == eDontBlock);
105 AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
106 Require (IsOpenRead ());
112 byte fSrcBufferedRawBytes_[4];
113 span<byte> fSrcBufferedSpan_;
132 return New (IterableToInputStream::New<Character> (srcText));
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.