7#include "core/fxcrt/binary_buffer.h"
12#include "core/fxcrt/fx_safe_types.h"
13#include "core/fxcrt/span_util.h"
34 m_AllocStep = that.m_AllocStep;
35 m_DataSize = that.m_DataSize;
36 m_buffer = std::move(that.m_buffer);
43 if (m_buffer.empty() || count > GetSize() || start_index > GetSize() - count)
46 auto buffer_span = pdfium::make_span(m_buffer).first(GetSize());
47 fxcrt::spanmove(buffer_span.subspan(start_index),
48 buffer_span.subspan(start_index + count));
53 return {m_buffer.data(), GetSize()};
57 return {m_buffer.data(), GetSize()};
69 m_buffer.resize(GetSize());
71 return std::move(m_buffer);
75 if (m_buffer.size() < size)
76 ExpandBuf(size - GetSize());
80 FX_SAFE_SIZE_T new_size = GetSize();
82 if (m_buffer.size() >= new_size.ValueOrDie())
85 size_t alloc_step = std::max(
static_cast<size_t>(128),
86 m_AllocStep ? m_AllocStep : m_buffer.size() / 4);
87 new_size += alloc_step - 1;
88 new_size /= alloc_step;
89 new_size *= alloc_step;
90 m_buffer.resize(new_size.ValueOrDie());
97 ExpandBuf(span.size());
98 fxcrt::spancpy(pdfium::make_span(m_buffer).subspan(GetSize()), span);
99 m_DataSize += span.size();
111 AppendSpan(pdfium::as_bytes(pdfium::span_from_ref(value))
);
115 AppendSpan(pdfium::as_bytes(pdfium::span_from_ref(value))
);
119 AppendSpan(pdfium::as_bytes(pdfium::span_from_ref(value))
);
virtual size_t GetLength() const
void AppendUint8(uint8_t value)
void AppendUint16(uint16_t value)
void AppendSpan(pdfium::span< const uint8_t > span)
pdfium::span< const uint8_t > GetSpan() const
void DeleteBuf(size_t start_index, size_t count)
void AppendDouble(double value)
void ExpandBuf(size_t size)
void AppendString(const ByteString &str)
void EstimateSize(size_t size)
BinaryBuffer & operator=(BinaryBuffer &&that) noexcept
BinaryBuffer(BinaryBuffer &&that) noexcept
void AppendUint32(uint32_t value)
pdfium::span< uint8_t > GetMutableSpan()
DataVector< uint8_t > DetachBuffer()