template <typename Byte, ::std::size_t kAlignment, ::std::size_t kOffset>

class ContiguousBuffer

Defined at line 305 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

ContiguousBuffer is a direct view of a fixed number of contiguous bytes in

memory. If Byte is a const type, it will be a read-only view; if Byte is

non-const, then writes will be allowed.

The kAlignment and kOffset parameters are used to optimize certain reads and

writes. static_cast

<uintptr

_t>(bytes_) % kAlignment must equal kOffset.

This class is used extensively by generated code, and is not intended to be

heavily used by hand-written code -- some interfaces can be tricky to call

correctly.

Public Methods

void ContiguousBuffer<Byte, kAlignment, kOffset> ()

Constructs a default ContiguousBuffer.

Defined at line 360 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename T, typename = typename ::std::enable_if<
                              IsAliasSafe<typename ::std::remove_cv<
                                  typename ::std::remove_reference<decltype(*(
                                      ::std::declval<T>().data()))>::type>::type>::value && ::std::
                                  is_same<typename AddSourceCV<
                                              decltype(*::std::declval<T>().data()), Byte>::Type,
                                          Byte>::value>::type>
void ContiguousBuffer<Byte, kAlignment, kOffset> (T * bytes)

Constructs a ContiguousBuffer from a contiguous container type over some

`char` type, such as std::string, std::vector

<signed

char>,

std::array

<unsigned

char, N>, or std::string_view.

This template is only enabled if:

1. bytes->data() returns a pointer to some char type.

2. Byte is at least as cv-qualified as decltype(*bytes->data()).

The first requirement means that this constructor won't work on, e.g.,

std::vector

<int

> -- this is mostly a precautionary measure, since

ContiguousBuffer only uses alias-safe operations anyway.

The second requirement means that const and volatile are respected in the

expected way: a ContiguousBuffer

<const

unsigned char, ...> may be

initialized from std::vector

<char

>, but a ContiguousBuffer

<unsigned

char,

...> may not be initialized from std::string_view.

Defined at line 388 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename T, typename = typename ::std::enable_if<
                                    IsAliasSafe<T>::value && ::std::is_same<
                                        typename AddSourceCV<T, Byte>::Type, Byte>::value>>
void ContiguousBuffer<Byte, kAlignment, kOffset> (T * bytes, ::std::size_t size)

Constructs a ContiguousBuffer from a pointer to a char type and a size. As

with the constructor from a container, above, Byte must be at least as

cv-qualified as T.

Defined at line 401 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

void ContiguousBuffer<Byte, kAlignment, kOffset> (::std::nullptr_t )

Constructs a ContiguousBuffer from nullptr. Equivalent to

ContiguousBuffer().

TODO(bolms): Update callers and remove this constructor.

Defined at line 412 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

void ContiguousBuffer<Byte, kAlignment, kOffset> (const ContiguousBuffer<Byte, kAlignment, kOffset> & other)

Defined at line 416 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

ContiguousBuffer<Byte, kAlignment, kOffset> & operator= (const ContiguousBuffer<Byte, kAlignment, kOffset> & other)

Defined at line 417 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset, typename = typename ::std::enable_if<
                              kOtherAlignment % kAlignment == 0 &&
                              kOtherOffset % kAlignment ==
                                  kOffset && ::std::is_same<
                                      typename AddSourceCV<OtherByte, Byte>::Type, Byte>::value &&
                              !::std::is_same<ContiguousBuffer,
                                              ContiguousBuffer<OtherByte, kOtherAlignment,
                                                               kOtherOffset>>::value>::type>
void ContiguousBuffer<Byte, kAlignment, kOffset> (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other)

Explicitly construct a ContiguousBuffers from another, compatible

ContiguousBuffer. A compatible ContiguousBuffer has an

equally-or-less-cv-qualified Byte type, an alignment that is an exact

multiple of this ContiguousBuffer's alignment, and an offset that is the

same when reduced to this ContiguousBuffer's alignment.

The final !::std::is_same

<

...> clause prevents this constructor from

overlapping with the *implicit* copy constructor.

Defined at line 457 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset, typename = typename ::std::enable_if<
                                    kOtherAlignment % kAlignment == 0 &&
                                    kOtherOffset % kAlignment ==
                                        kOffset && ::std::is_same<
                                            typename AddSourceCV<OtherByte, Byte>::Type,
                                            Byte>::value>::type>
bool operator== (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other)

Compare a ContiguousBuffers to another, compatible ContiguousBuffer.

Defined at line 471 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset, typename = typename ::std::enable_if<
                                    kOtherAlignment % kAlignment == 0 &&
                                    kOtherOffset % kAlignment ==
                                        kOffset && ::std::is_same<
                                            typename AddSourceCV<OtherByte, Byte>::Type,
                                            Byte>::value>::type>
bool operator!= (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other)

Compare a ContiguousBuffers to another, compatible ContiguousBuffer.

Defined at line 486 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset, typename = typename ::std::enable_if<
                                    kOtherAlignment % kAlignment == 0 &&
                                    kOtherOffset % kAlignment ==
                                        kOffset && ::std::is_same<
                                            typename AddSourceCV<OtherByte, Byte>::Type,
                                            Byte>::value>::type>
ContiguousBuffer<Byte, kAlignment, kOffset> & operator= (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other)

Assignment from a compatible ContiguousBuffer.

Defined at line 500 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kSubAlignment, ::std::size_t kSubOffset>
OffsetStorageType<kSubAlignment, kSubOffset> GetOffsetStorage (::std::size_t offset, ::std::size_t size)

Defined at line 524 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned ReadLittleEndianUInt ()

Defined at line 563 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned UncheckedReadLittleEndianUInt ()

Defined at line 569 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned ReadBigEndianUInt ()

Defined at line 578 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned UncheckedReadBigEndianUInt ()

Defined at line 584 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void WriteLittleEndianUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 600 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void UncheckedWriteLittleEndianUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 607 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void WriteBigEndianUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 616 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void UncheckedWriteBigEndianUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 623 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset>
void UncheckedCopyFrom (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other, ::std::size_t size)

Defined at line 634 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset>
void CopyFrom (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other, ::std::size_t size)

Defined at line 641 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename OtherByte, ::std::size_t kOtherAlignment, ::std::size_t kOtherOffset>
bool TryToCopyFrom (const ContiguousBuffer<OtherByte, kOtherAlignment, kOtherOffset> & other, ::std::size_t size)

Defined at line 653 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

::std::size_t SizeInBytes ()

Defined at line 663 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

bool Ok ()

Defined at line 664 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

Byte * data ()

Defined at line 665 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

Byte * begin ()

Defined at line 666 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

Byte * end ()

Defined at line 667 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <typename String>
typename ::std::enable_if<IsAliasSafe<typename ::std::remove_reference<decltype(*::std::declval<String>().data())>::type>::value, String>::type ToString ()

Constructs a string type from the underlying data; mostly intended to be

called as:

buffer.ToString

<std

::string>();

or:

buffer.ToString

<std

::string_view>();

... but it should also work with any similar-enough classes, such as

std::basic_string_view

<unsigned

char> or Google's absl::string_view.

Note that this may or may not make a copy of the underlying data,

depending on the behavior of the given string type.

Defined at line 684 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h