4#ifndef _Stroika_Foundation_Memory_BLOB_h_
5#define _Stroika_Foundation_Memory_BLOB_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
14#include "Stroika/Foundation/Common/Common.h"
15#include "Stroika/Foundation/Common/Concepts.h"
17#include "Stroika/Foundation/Memory/Common.h"
35namespace Stroika::Foundation::Memory {
87 template <ranges::range CONTAINER_OF_BYTE>
91 BLOB (span<const byte>
s);
104 explicit BLOB (
const shared_ptr<_IRep>& rep);
105 explicit BLOB (shared_ptr<_IRep>&& rep);
110 nonvirtual
BLOB& operator= (
BLOB&&
rhs)
noexcept =
default;
111 nonvirtual
BLOB& operator= (
const BLOB&
rhs) =
default;
171 template <Common::trivially_copyable T>
173 template <Common::trivially_copyable T>
175 template <Common::trivially_copyable T>
178 template <Common::trivially_copyable T>
181 template <Common::trivially_copyable T>
195 template <
typename BYTEISH,
size_t EXTENT = dynamic_extent>
198 template <
typename BYTEISH,
size_t EXTENT>
209 static BLOB AttachAndDelete (
const byte*
s,
size_t arrayLen);
215 nonvirtual
byte operator[] (
const size_t i)
const;
221 nonvirtual
bool empty ()
const;
240 template <
typename T>
242#if !qCompilerAndStdLib_template_requires_doesnt_work_with_specialization_Buggy
245 Common::IAnyOf<T,span<const byte>,
span<const uint8_t>,
pair<const byte*, const byte*>,
pair<const uint8_t*, const uint8_t*>,
vector<byte> ,
vector<uint8_t>,
Streams::InputStream::Ptr<byte>,
string>
264 template <
typename STRING_TYPE = Characters::String>
266#if !qCompilerAndStdLib_template_requires_doesnt_work_with_specialization_Buggy
282 template <
typename STRING_TYPE = Characters::String>
284#if !qCompilerAndStdLib_template_requires_doesnt_work_with_specialization_Buggy
288 template <
typename STRING_TYPE = Characters::String>
289 nonvirtual
STRING_TYPE AsBase64 (
const Cryptography::Encoding::Algorithm::Base64::Options&
o)
const
290#if !qCompilerAndStdLib_template_requires_doesnt_work_with_specialization_Buggy
307 nonvirtual
BLOB Repeat (
unsigned int count)
const;
322 nonvirtual
const byte*
begin ()
const;
329 nonvirtual
const byte*
end ()
const;
335 nonvirtual
size_t GetSize ()
const;
345 nonvirtual
bool operator== (
const BLOB&
rhs)
const;
354 nonvirtual
const byte*
data ()
const;
360 nonvirtual
size_t size ()
const;
366 nonvirtual
size_t length ()
const;
388 template <
typename T>
397 [[
deprecated (
"Since Stroika v3.0d4 use Attach")]]
static BLOB AttachApplicationLifetime (
const byte*
start,
const byte*
end)
401 template <
size_t SIZE>
402 [[
deprecated (
"Since Stroika v3.0d4 use Attach")]]
static BLOB AttachApplicationLifetime (
const byte (&
data)[
SIZE])
406 template <
typename...
ARGS>
411 template <
typename...
ARGS>
421 struct AdoptAndDeleteRep_;
425 shared_ptr<_IRep> fRep_;
427 static_assert (totally_ordered<BLOB>);
428 static_assert (regular<BLOB>);
429 static_assert (Common::explicitly_convertible_to<BLOB, span<const byte>>);
440 virtual ~_IRep () =
default;
441 virtual span<const byte> GetBounds ()
const = 0;
443 nonvirtual
const _IRep& operator= (
const _IRep&) =
delete;
446 inline namespace Literals {
458 inline BLOB operator""_blob (
const char* str,
size_t len);
#define Stroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE
[[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not b...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
nonvirtual size_t length() const
nonvirtual const byte * end() const
nonvirtual STRING_TYPE AsBase64() const
nonvirtual Characters::String ToString(size_t maxBytesToShow=80) const
nonvirtual BLOB Repeat(unsigned int count) const
static BLOB FromHex(const char *b)
Convert string of hex bytes to BLOB.
nonvirtual byte operator[](const size_t i) const
nonvirtual BLOB Slice(size_t startAt, size_t endAt) const
nonvirtual BLOB operator+(const BLOB &rhs) const
nonvirtual bool empty() const
nonvirtual const byte * begin() const
nonvirtual STRING_TYPE AsHex(size_t maxBytesToShow=numeric_limits< size_t >::max()) const
nonvirtual size_t GetSize() const
static BLOB FromBase64(const char *b)
Convert string of base64 bytes to BLOB.
static BLOB FromRaw(const T *s, const T *e)
Convert pointed to/referenced data to BLOB (treating the argument as raw bytes).
nonvirtual size_t size() const
nonvirtual const byte * data() const
Concept: trivial shorthand for variadic same_as A or same_as B, or ...