pdfium/testing/string_write_stream.cpp
Tom Sepez 40dd828603 Introduce fxcrt::reinterpret_span<>()
Convert between different span types performing automatic size
adjustment. Try it in PDFium before arguing to inflict it elsewhere.

-- Introduce some bounds checks while at it.

Change-Id: I6ff7b92238b89eb3047c5f9d2cc2dd9cd7e33bf4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/114951
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-01-18 21:49:01 +00:00

20 lines
587 B
C++

// Copyright 2018 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/string_write_stream.h"
#include "core/fxcrt/bytestring.h"
#include "core/fxcrt/span_util.h"
#include "core/fxcrt/widestring.h"
StringWriteStream::StringWriteStream() = default;
StringWriteStream::~StringWriteStream() = default;
bool StringWriteStream::WriteBlock(pdfium::span<const uint8_t> buffer) {
auto chars = fxcrt::reinterpret_span<const char>(buffer);
stream_.write(chars.data(), chars.size());
return true;
}