lin
2025-08-01 633231e833e21d5b8b1c00cb15aedb62b3b78e8f
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
// Copyright 2015 The Chromium OS 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 "buffer_reader.h"
 
#include <string.h>
 
namespace quipper {
 
bool BufferReader::ReadData(const size_t size, void* dest) {
  if (offset_ + size > size_) return false;
 
  memcpy(dest, buffer_ + offset_, size);
  offset_ += size;
  return true;
}
 
bool BufferReader::ReadString(size_t size, string* str) {
  if (offset_ + size > size_) return false;
 
  size_t actual_length = strnlen(buffer_ + offset_, size);
  *str = string(buffer_ + offset_, actual_length);
  offset_ += size;
  return true;
}
 
}  // namespace quipper