Add read/write methods for vectors
Also a readString16 with the expected semantics.
Change-Id: Idbeaff1b4337089b2a5a7124f77226a693b2be4f
Test: Unit tests pass
Bug: 25012838
Signed-off-by: Casey Dahlin <sadmac@google.com>
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 9bf62a3..5a37e6a 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_PARCEL_H
#define ANDROID_PARCEL_H
+#include <vector>
+
#include <cutils/native_handle.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
@@ -112,6 +114,15 @@
status_t writeChar(char16_t val);
status_t writeByte(int8_t val);
+ status_t writeByteVector(const std::vector<int8_t>& val);
+ status_t writeInt32Vector(const std::vector<int32_t>& val);
+ status_t writeInt64Vector(const std::vector<int64_t>& val);
+ status_t writeFloatVector(const std::vector<float>& val);
+ status_t writeDoubleVector(const std::vector<double>& val);
+ status_t writeBoolVector(const std::vector<bool>& val);
+ status_t writeCharVector(const std::vector<char16_t>& val);
+ status_t writeString16Vector(const std::vector<String16>& val);
+
template<typename T>
status_t write(const Flattenable<T>& val);
@@ -121,7 +132,7 @@
// Place a native_handle into the parcel (the native_handle's file-
// descriptors are dup'ed, so it is safe to delete the native_handle
- // when this function returns).
+ // when this function returns).
// Doesn't take ownership of the native_handle.
status_t writeNativeHandle(const native_handle* handle);
@@ -182,10 +193,20 @@
const char* readCString() const;
String8 readString8() const;
String16 readString16() const;
+ status_t readString16(String16* pArg) const;
const char16_t* readString16Inplace(size_t* outLen) const;
sp<IBinder> readStrongBinder() const;
wp<IBinder> readWeakBinder() const;
+ status_t readByteVector(std::vector<int8_t>* val) const;
+ status_t readInt32Vector(std::vector<int32_t>* val) const;
+ status_t readInt64Vector(std::vector<int64_t>* val) const;
+ status_t readFloatVector(std::vector<float>* val) const;
+ status_t readDoubleVector(std::vector<double>* val) const;
+ status_t readBoolVector(std::vector<bool>* val) const;
+ status_t readCharVector(std::vector<char16_t>* val) const;
+ status_t readString16Vector(std::vector<String16>* val) const;
+
template<typename T>
status_t read(Flattenable<T>& val) const;