Clean up CursorWindow code.
Bug: 5332296
The code is functionally equivalent, but a little more efficient
and much easier to maintain.
Change-Id: I90670a13799df05831843a5137ab234929281b7c
diff --git a/include/binder/CursorWindow.h b/include/binder/CursorWindow.h
index f0b2909..d227244 100644
--- a/include/binder/CursorWindow.h
+++ b/include/binder/CursorWindow.h
@@ -143,8 +143,6 @@
*/
uint32_t alloc(size_t size, bool aligned = false);
- uint32_t read_field_slot(int row, int column, field_slot_t * slot);
-
/**
* Copy data into the window at the given offset.
*/
@@ -181,6 +179,32 @@
return ((field_slot_t *)offsetToPtr(fieldDirOffset)) + column;
}
+ int64_t getFieldSlotValueLong(field_slot_t* fieldSlot) {
+#if WINDOW_STORAGE_INLINE_NUMERICS
+ return fieldSlot->data.l;
+#else
+ return copyOutLong(fieldSlot->data.buffer.offset);
+#endif
+ }
+
+ double getFieldSlotValueDouble(field_slot_t* fieldSlot) {
+#if WINDOW_STORAGE_INLINE_NUMERICS
+ return fieldSlot->data.d;
+#else
+ return copyOutDouble(fieldSlot->data.buffer.offset);
+#endif
+ }
+
+#if WINDOW_STORAGE_UTF8
+ char* getFieldSlotValueString(field_slot_t* fieldSlot) {
+ return reinterpret_cast<char*>(offsetToPtr(fieldSlot->data.buffer.offset));
+ }
+#else
+ char16_t* getFieldSlotValueString(field_slot_t* fieldSlot) {
+ return reinterpret_cast<char16_t*>(offsetToPtr(fieldSlot->data.buffer.offset));
+ }
+#endif
+
private:
uint8_t * mData;
size_t mSize;