Begin processing read commands.
[minibind.git] / jni / minibind / parcel.h
1 // 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
5 #ifndef MINIBIND_PARCEL_H_
6 #define MINIBIND_PARCEL_H_
7
8 #include <stdint.h>
9 #include <sys/types.h>
10
11 #include <linux/binder.h>
12
13 #include <string>
14 #include <vector>
15
16 namespace minibind {
17
18 class Parcel {
19 public:
20 Parcel();
21 ~Parcel();
22
23 void WriteInterfaceToken(const std::string& str);
24 void WriteUTF8(const std::string& str);
25 void WriteUInt32(uint32_t ui32);
26
27 bool ReadUInt32(uint32_t* ui32);
28 bool ReadBytes(size_t count, void* buffer);
29
30 binder_uintptr_t DataPointer() const;
31
32 size_t DataSize() const;
33 void SetDataSize(size_t size);
34
35 size_t DataPosition() const;
36 void SetDataPosition(size_t pos);
37
38 void Print() const;
39
40 private:
41 size_t data_position_;
42 std::vector<uint8_t> data_;
43 std::vector<struct flat_binder_object> objects_;
44 };
45
46 } // namespace minibind
47
48 #endif // MINIBIND_PARCEL_H_