2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef QUERY_HANDLER_HH_
18 #define QUERY_HANDLER_HH_
23 #include <sys/types.h>
25 #include "abstract_db_handler.hh"
27 #include "pkgmgrinfo_basic.h"
28 #include "pkgmgrinfo_private.h"
29 #include "query_parcelable.hh"
31 namespace pkgmgr_server {
35 #define EXPORT_API __attribute__((visibility("default")))
38 enum class CacheChangeFlag {
45 class EXPORT_API QueryHandler : public AbstractDBHandler {
47 QueryHandler(uid_t uid, int pid);
49 void SetQueryArgs(std::vector<pkgmgr_common::parcel::QueryArgs> query_args);
50 bool BindString(std::string value);
51 bool BindInt(int value);
52 std::string GetString();
55 int Execute() override;
56 std::vector<pkgmgr_common::parcel::StrArgs> GetResult();
59 int ExecuteReadQuery(const std::vector<std::string>& queries,
60 const std::vector<std::vector<std::optional<std::string>>>& args_list);
61 int ExecuteWriteQuery(const std::vector<std::string>& queries,
62 const std::vector<std::vector<std::optional<std::string>>>& args_list,
63 const std::vector<std::pair<CacheChangeFlag, std::string>>& changes);
66 std::vector<std::string> query_;
67 std::vector<pkgmgr_common::parcel::QueryArgs> query_args_;
68 std::vector<pkgmgr_common::parcel::StrArgs> result_;
71 } // namespace database
72 } // namespace pkgmgr_server
74 #endif // QUERY_HANDLER_HH_