| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ | 5 #ifndef CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ |
| 6 #define CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ | 6 #define CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "chromeos/binder/buffer_reader.h" | 12 #include "chromeos/binder/buffer_reader.h" |
| 11 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
| 12 | 14 |
| 13 namespace binder { | 15 namespace binder { |
| 14 | 16 |
| 15 class TransactionData; | 17 class TransactionData; |
| 16 | 18 |
| 17 // Reads contents of a TransactionData. | 19 // Reads contents of a TransactionData. |
| 18 // Use this class to get parameters of incoming transactions, or to get values | 20 // Use this class to get parameters of incoming transactions, or to get values |
| 19 // from transaction replies. | 21 // from transaction replies. |
| 20 class CHROMEOS_EXPORT TransactionDataReader { | 22 class CHROMEOS_EXPORT TransactionDataReader { |
| 21 public: | 23 public: |
| 22 explicit TransactionDataReader(const TransactionData& data); | 24 explicit TransactionDataReader(const TransactionData& data); |
| 23 ~TransactionDataReader(); | 25 ~TransactionDataReader(); |
| 24 | 26 |
| 25 // Returns true when there is some data to read. | 27 // Returns true when there is some data to read. |
| 26 bool HasMoreData() const; | 28 bool HasMoreData() const; |
| 27 | 29 |
| 28 // Reads the specified number of bytes with appropriate padding. | 30 // Reads the specified number of bytes with appropriate padding. |
| 29 bool ReadData(void* buf, size_t n); | 31 bool ReadData(void* buf, size_t n); |
| 30 | 32 |
| 31 // Reads an int32 value. | 33 // Reads an int32_t value. |
| 32 bool ReadInt32(int32* value); | 34 bool ReadInt32(int32_t* value); |
| 33 | 35 |
| 34 // Reads an uint32 value. | 36 // Reads an uint32_t value. |
| 35 bool ReadUint32(uint32* value); | 37 bool ReadUint32(uint32_t* value); |
| 36 | 38 |
| 37 // Reads an int64 value. | 39 // Reads an int64_t value. |
| 38 bool ReadInt64(int64* value); | 40 bool ReadInt64(int64_t* value); |
| 39 | 41 |
| 40 // Reads an uint64 value. | 42 // Reads an uint64_t value. |
| 41 bool ReadUint64(uint64* value); | 43 bool ReadUint64(uint64_t* value); |
| 42 | 44 |
| 43 // Reads a float value. | 45 // Reads a float value. |
| 44 bool ReadFloat(float* value); | 46 bool ReadFloat(float* value); |
| 45 | 47 |
| 46 // Reads a double value. | 48 // Reads a double value. |
| 47 bool ReadDouble(double* value); | 49 bool ReadDouble(double* value); |
| 48 // TODO(hashimoto): Support more types (i.e. strings, FDs, objects). | 50 // TODO(hashimoto): Support more types (i.e. strings, FDs, objects). |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 const TransactionData& data_; | 53 const TransactionData& data_; |
| 52 BufferReader reader_; | 54 BufferReader reader_; |
| 53 | 55 |
| 54 DISALLOW_COPY_AND_ASSIGN(TransactionDataReader); | 56 DISALLOW_COPY_AND_ASSIGN(TransactionDataReader); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace binder | 59 } // namespace binder |
| 58 | 60 |
| 59 #endif // CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ | 61 #endif // CHROMEOS_BINDER_TRANSACTION_DATA_READER_H_ |
| OLD | NEW |