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"
18#include "TextToBinary.h"
23using namespace Stroika::Foundation::Streams;
24using namespace Stroika::Foundation::Streams::TextToBinary;
47 if (fSrc_ !=
nullptr) {
50 Ensure (not IsOpenRead ());
51 Ensure (fSrc_ ==
nullptr);
55 return fSrc_ !=
nullptr;
60 if (fSrcBufferedSpan_.size () > 0) {
61 return fSrcBufferedSpan_.size ();
63 return fSrc_.AvailableToRead ();
67 Require (IsOpenRead ());
73 Require (IsOpenRead ());
74 Require (not intoBuffer.empty ());
77 if (not fSrcBufferedSpan_.empty ()) [[unlikely]] {
78 auto copiedIntoSpan = Memory::CopyBytes (fSrcBufferedSpan_.subspan (0, min (fSrcBufferedSpan_.size (), intoBuffer.size ())), intoBuffer);
79 Assert (copiedIntoSpan.size () >= 1);
80 fSrcBufferedSpan_ = fSrcBufferedSpan_.subspan (copiedIntoSpan.size ());
81 _fOffset += copiedIntoSpan.size ();
82 return intoBuffer.subspan (0, copiedIntoSpan.size ());
85 Assert (fSrcBufferedSpan_.empty ());
87 if (
auto o = fSrc_.GetRepRWRef ().Read (span{readBuf}, blockFlag)) {
88 if (
size_t nChars = o->size ()) {
91 span{readBuf, nChars}, Memory::SpanBytesCast<span<char8_t>> (span{fSrcBufferedRawBytes_})));
92 Assert (not fSrcBufferedSpan_.empty ());
101 Assert (blockFlag == eDontBlock);
107 AssertExternallySynchronizedMutex::ReadContext declareContext{fThisAssertExternallySynchronized_};
108 Require (IsOpenRead ());
114 byte fSrcBufferedRawBytes_[4];
115 span<byte> fSrcBufferedSpan_;
130 if (seekable == SeekableFlag::eSeekable) {
131 result = BufferedInputStream::New (result, SeekableFlag::eSeekable);
132 Ensure (result.IsSeekable ());
140 auto result = New (IterableToInputStream::New<Character> (srcText));
141 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.
#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE
[[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not b...
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.