*/
int parcel_reset_reader(parcel_h parcel);
+/**
+ * @brief Sets the reader pointer of the handle to the given position.
+ * @since_tizen 10.0
+ * @param[in] parcel The parcel handle
+ * @param[in] pos The position to set
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PARCEL_ERROR_NONE Successful
+ * @retval #PARCEL_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int parcel_set_reader(parcel_h parcel, uint32_t pos);
+
/**
* @brief Clears the data of the parcel handle.
* @since_tizen 6.5
reader_ = 0;
}
+bool Parcel::Impl::SetReader(uint32_t pos) {
+ if (pos > data_size_)
+ return false;
+ reader_ = pos;
+ return true;
+}
+
void Parcel::Impl::Clear() {
data_size_ = 0;
reader_ = 0;
impl_->ResetReader();
}
+bool Parcel::SetReader(uint32_t pos) {
+ return impl_->SetReader(pos);
+}
+
void Parcel::Clear() {
impl_->Clear();
}
*/
void ResetReader();
+ /**
+ * @brief Sets the reader pointer of the handle to the given position.
+ * @since_tizen 10.0
+ * @param[in] pos The position to set
+ * @return @c true on success,
+ * otherwise false
+ */
+ bool SetReader(uint32_t pos);
+
/**
* @brief Clears the data of the parcel.
* @since_tizen 6.5
void Write(const void* buf, uint32_t size);
int Read(void* buf, uint32_t size);
void ResetReader();
+ bool SetReader(uint32_t pos);
void Clear();
void Reset(const void* buf, uint32_t size);
bool IsEmpty();
return PARCEL_ERROR_NONE;
}
+extern "C" EXPORT int parcel_set_reader(parcel_h parcel, uint32_t pos) {
+ if (parcel == nullptr) {
+ _E("Invalid parameter");
+ return PARCEL_ERROR_INVALID_PARAMETER;
+ }
+
+ auto* h = static_cast<Parcel*>(parcel);
+ if (h->SetReader(pos))
+ return PARCEL_ERROR_NONE;
+ return PARCEL_ERROR_INVALID_PARAMETER;
+}
+
extern "C" EXPORT int parcel_clear(parcel_h parcel) {
if (parcel == nullptr) {
_E("Invalid parameter");
ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
}
+TEST_F(ParcelTest, parcel_set_reader_P) {
+ parcel_write_uint32(GetHandle(), 1);
+ parcel_write_uint32(GetHandle(), 2);
+ parcel_write_uint32(GetHandle(), 3);
+ int ret = parcel_set_reader(GetHandle(), 4);
+ int32_t val = 0;
+ parcel_read_int32(GetHandle(), &val);
+ ASSERT_EQ(ret, PARCEL_ERROR_NONE);
+ ASSERT_EQ(val, 2);
+}
+
+TEST_F(ParcelTest, parcel_set_reader_N1) {
+ int ret = parcel_set_reader(nullptr, 0);
+ ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(ParcelTest, parcel_set_reader_N2) {
+ int ret = parcel_set_reader(GetHandle(), 100);
+ ASSERT_EQ(ret, PARCEL_ERROR_INVALID_PARAMETER);
+}
+
TEST_F(ParcelTest, parcel_clear_P) {
int ret = parcel_clear(GetHandle());
ASSERT_EQ(ret, PARCEL_ERROR_NONE);