int rpc_port_parcel_header_get_timestamp(rpc_port_parcel_header_h header, struct timespec *timestamp);
/**
+ * @brief Gets the raw data of the rpc port parcel handle.
+ * @since_tizen 6.5
+ * @remarks You MUST NOT release @a raw using free(). It's managed by platform.
+ * @param[in] h The rpc port parcel handle
+ * @param[out] raw The raw data
+ * @param[out] size The size of the raw data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_parcel_get_raw(rpc_port_parcel_h h, void **raw, unsigned int *size);
+
+/**
+ * @brief Creates the rpc port parcel handle with given the raw data.
+ * @since_tizen 6.5
+ * @remarks You must release @a h using rpc_port_parcel_destroy().
+ * @param[out] h The rpc port parcel handle
+ * @param[in] raw The raw data
+ * @param[in] size The size of the raw data
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_parcel_destroy()
+ */
+int rpc_port_parcel_create_from_raw(rpc_port_parcel_h *h, const void *raw, unsigned int size);
+
+/**
* @}
*/
*timestamp = parcel_header->GetTimeStamp();
return RPC_PORT_ERROR_NONE;
}
+
+RPC_API int rpc_port_parcel_get_raw(rpc_port_parcel_h h, void** raw,
+ unsigned int* size) {
+ if (h == nullptr || raw == nullptr || size == nullptr)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ auto* parcel = static_cast<internal::Parcel*>(h);
+ void* raw_data = nullptr;
+ uint32_t raw_size = 0;
+ parcel_get_raw(parcel->GetHandle(), &raw_data, &raw_size);
+
+ *raw = raw_data;
+ *size = static_cast<unsigned int>(raw_size);
+ return RPC_PORT_ERROR_NONE;
+}
+
+RPC_API int rpc_port_parcel_create_from_raw(rpc_port_parcel_h* h,
+ const void* raw, unsigned int size) {
+ if (h == nullptr || raw == nullptr || size == 0)
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+
+ rpc_port_parcel_h parcel;
+ int ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE)
+ return ret;
+
+ ret = rpc_port_parcel_from_array(parcel, raw, size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ rpc_port_parcel_destroy(parcel);
+ return ret;
+ }
+
+ *h = parcel;
+ return RPC_PORT_ERROR_NONE;
+}
int ret = rpc_port_parcel_header_get_timestamp(nullptr, nullptr);
ASSERT_EQ(ret, RPC_PORT_ERROR_INVALID_PARAMETER);
}
+
+/*
+ * @testcase rpc_port_parcel_get_raw_P
+ * @description Gets the raw data from the rpc port parcel handle
+ * @apicovered rpc_port_parcel_get_raw
+ */
+TEST_F(ParcelTest, rpc_port_parcel_get_raw_P) {
+ int ret = rpc_port_parcel_write_string(handle_, "test");
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+
+ void* raw = nullptr;
+ unsigned int raw_size = 0;
+ ret = rpc_port_parcel_get_raw(handle_, &raw, &raw_size);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+ ASSERT_NE(raw, nullptr);
+ ASSERT_NE(raw_size, 0);
+}
+
+/*
+ * @testcase rpc_port_parcel_get_raw_N
+ * @description Gets the raw data from the rpc port parcel handle
+ * @apicovered rpc_port_parcel_get_raw
+ */
+TEST_F(ParcelTest, rpc_port_parcel_get_raw_N) {
+ int ret = rpc_port_parcel_get_raw(nullptr, nullptr, nullptr);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_INVALID_PARAMETER);
+}
+
+/*
+ * @testcase rpc_port_parcel_create_from_raw_P
+ * @description Creates the rpc parcel handle with given the raw data.
+ * @apicovered rpc_port_parcel_create_from_raw
+ */
+TEST_F(ParcelTest, rpc_port_parcel_create_from_raw_P) {
+ int ret = rpc_port_parcel_write_string(handle_, "test");
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+
+ void* raw = nullptr;
+ unsigned int raw_size = 0;
+ ret = rpc_port_parcel_get_raw(handle_, &raw, &raw_size);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+
+ rpc_port_parcel_h parcel = nullptr;
+ ret = rpc_port_parcel_create_from_raw(&parcel, raw, raw_size);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+
+ std::unique_ptr<std::remove_pointer<rpc_port_parcel_h>::type,
+ decltype(rpc_port_parcel_destroy)*> parcel_auto(
+ parcel, rpc_port_parcel_destroy);
+
+ char* str = nullptr;
+ ret = rpc_port_parcel_read_string(parcel, &str);
+ std::unique_ptr<char, decltype(std::free)*> str_auto(str, std::free);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_NONE);
+ ASSERT_NE(str, nullptr);
+ ASSERT_EQ(std::string(str), "test");
+}
+
+/*
+ * @testcase rpc_port_parcel_create_from_raw_B
+ * @description Creates the rpc parcel handle with given the raw data.
+ * @apicovered rpc_port_parcel_create_from_raw
+ */
+TEST_F(ParcelTest, rpc_port_parcel_create_from_raw_N) {
+ int ret = rpc_port_parcel_create_from_raw(nullptr, nullptr, 0);
+ ASSERT_EQ(ret, RPC_PORT_ERROR_INVALID_PARAMETER);
+}