You've already forked openscreen

The license header presubmit check enforces the new license header format which removes the string "All Rights Reserved." Chromium was updated but not our repo, so doing this now so that unrelated changes aren't blocked on license headers. To pass cpplint, this also fixes a number of IWYU issues and also adds `noexcept` to move operators. Bug: b/288403513 Change-Id: I90b2e58dcc2bdd1762129c7b5894e3a2730da51b Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/4638621 Commit-Queue: Mark Foltz <mfoltz@chromium.org> Reviewed-by: Muyao Xu <muyaoxu@google.com>
34 lines
856 B
C++
34 lines
856 B
C++
// Copyright 2019 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "util/big_endian.h"
|
|
|
|
namespace openscreen {
|
|
|
|
BigEndianReader::BigEndianReader(const uint8_t* buffer, size_t length)
|
|
: BigEndianBuffer(buffer, length) {}
|
|
|
|
bool BigEndianReader::Read(size_t length, void* out) {
|
|
const uint8_t* read_position = current();
|
|
if (Skip(length)) {
|
|
memcpy(out, read_position, length);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
BigEndianWriter::BigEndianWriter(uint8_t* buffer, size_t length)
|
|
: BigEndianBuffer(buffer, length) {}
|
|
|
|
bool BigEndianWriter::Write(const void* buffer, size_t length) {
|
|
uint8_t* write_position = current();
|
|
if (Skip(length)) {
|
|
memcpy(write_position, buffer, length);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace openscreen
|