blob: d56589003ae20cb470202afb710e986143ddec9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// 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
|