2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License) {
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 #include "query_parcelable.hh"
22 #include "pkgmgrinfo_private.h"
24 namespace pkgmgr_common {
27 QueryParcelable::QueryParcelable()
28 : AbstractParcelable(0, ParcelableType::Query), db_type_(AbstractDBHandler::DBType::DB_TYPE_NONE), op_type_(AbstractDBHandler::OperationType::OPERATION_TYPE_NONE) {}
31 QueryParcelable::QueryParcelable(uid_t uid, std::string query,
32 AbstractDBHandler::DBType db_type, AbstractDBHandler::OperationType op_type)
33 : AbstractParcelable(0, ParcelableType::Query), queries_(std::vector<std::string>{query}), db_type_(db_type), op_type_(op_type) {}
35 QueryParcelable::QueryParcelable(uid_t uid, std::vector<std::string> queries, AbstractDBHandler::DBType db_type, AbstractDBHandler::OperationType op_type)
36 : AbstractParcelable(uid, ParcelableType::Query), queries_(queries), db_type_(db_type), op_type_(op_type) {}
38 void QueryParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
39 AbstractParcelable::WriteToParcel(parcel);
40 WriteInt(parcel, queries_.size());
41 for (const auto& query : queries_)
42 parcel->WriteString(query);
43 WriteInt(parcel, db_type_);
44 WriteInt(parcel, op_type_);
47 void QueryParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
52 AbstractParcelable::ReadFromParcel(parcel);
53 ReadInt(parcel, &query_size);
54 for (int i = 0; i < query_size; ++i) {
55 queries_.emplace_back(parcel->ReadString());
57 ReadInt(parcel, &db_type);
58 db_type_ = static_cast<AbstractDBHandler::DBType>(db_type);
59 ReadInt(parcel, &op_type);
60 op_type_ = static_cast<AbstractDBHandler::OperationType>(op_type);
63 const std::vector<std::string>& QueryParcelable::GetQueries() {
67 AbstractDBHandler::DBType QueryParcelable::GetDBType() {
71 AbstractDBHandler::OperationType QueryParcelable::GetOpType() {
75 std::unique_ptr<AbstractParcelable> QueryParcelable::Factory::CreateParcel() {
80 } // namespace pkgmgr_common