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 #include "query_handler.hh"
19 #include "pkgmgrinfo_internal.h"
21 namespace pkgmgr_common {
24 QueryHandler::QueryHandler(uid_t uid) : AbstractDBHandler(uid), uid_(uid) {}
26 QueryHandler::~QueryHandler() {}
28 void QueryHandler::SetQuery(std::string query) {
32 std::string QueryHandler::GetString() { return std::string(); }
33 int QueryHandler::GetInt() { return 0; }
34 int QueryHandler::GetRecordCount() { return 0; }
36 std::vector<std::vector<std::string>>&& QueryHandler::GetResult() {
37 return std::move(result_);
40 bool QueryHandler::Execute() {
41 if (!Connect()) return false;
43 // TODO: db handle should be delivered
47 int ret = get_query_result(GetConnection(), query_.c_str(), &list, &row, &col);
48 if (ret != PMINFO_R_OK) {
56 for (int i = 0; i < row; ++i) {
57 for (int j = 0; j < col; ++j) {
58 result_[i].emplace_back(reinterpret_cast<char *>(tmp->data));
67 } // namespace database
68 } // namespace pkgmgr_common