blob: 0de70c12270284b6ca7a221b287c8ec080f9bd1c [file] [log] [blame]
hashimotoc6bd5122015-12-14 06:41:491// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
hashimoto32e9f8bb2015-12-18 08:06:125#ifndef CHROMEOS_BINDER_BUFFER_READER_H_
6#define CHROMEOS_BINDER_BUFFER_READER_H_
hashimotoc6bd5122015-12-14 06:41:497
8#include "base/macros.h"
hashimoto32e9f8bb2015-12-18 08:06:129#include "chromeos/chromeos_export.h"
hashimotoc6bd5122015-12-14 06:41:4910
11namespace binder {
12
13// BufferReader reads data from the given buffer.
hashimoto32e9f8bb2015-12-18 08:06:1214class CHROMEOS_EXPORT BufferReader {
hashimotoc6bd5122015-12-14 06:41:4915 public:
16 BufferReader(const char* data, size_t size);
17 ~BufferReader();
18
19 const char* data() const { return data_; }
20 size_t size() const { return size_; }
21 size_t position() const { return position_; }
22
23 // Returns true when there is some data to read.
24 bool HasMoreData() const;
25
26 // Copies the specified number of bytes from the buffer to |out|.
27 // |out| shouldn't overlap with |data_|.
28 bool Read(void* out, size_t num_bytes);
29
30 // Moves the position |num_bytes| forward.
31 bool Skip(size_t num_bytes);
32
33 private:
34 const char* data_;
35 size_t size_;
36 size_t position_;
37
38 DISALLOW_COPY_AND_ASSIGN(BufferReader);
39};
40
41} // namespace binder
42
hashimoto32e9f8bb2015-12-18 08:06:1243#endif // CHROMEOS_BINDER_BUFFER_READER_H_