1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_KVDB_QUERY_H 17 #define OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_KVDB_QUERY_H 18 19 #include "query.h" 20 #include "query_helper.h" 21 #include "store/general_value.h" 22 #include "store_types.h" 23 24 namespace OHOS::DistributedKv { 25 class KVDBQuery : public DistributedData::GenQuery { 26 public: 27 static constexpr uint64_t TYPE_ID = 0x20000002; KVDBQuery(const std::string & query)28 explicit KVDBQuery(const std::string &query) : query_(query) 29 { 30 dbQuery_ = QueryHelper::StringToDbQuery(query, isSuccess_); 31 } 32 ~KVDBQuery() = default; IsEqual(uint64_t tid)33 bool IsEqual(uint64_t tid) 34 { 35 return tid == TYPE_ID; 36 } 37 GetTables()38 std::vector<std::string> GetTables() 39 { 40 return {}; 41 } 42 IsValidQuery()43 bool IsValidQuery() 44 { 45 return isSuccess_; 46 } 47 IsEmpty()48 bool IsEmpty() 49 { 50 return query_.empty(); 51 } 52 GetDBQuery()53 DistributedDB::Query GetDBQuery() 54 { 55 return dbQuery_; 56 } 57 58 bool isSuccess_ = false; 59 std::string query_; 60 DistributedDB::Query dbQuery_; 61 }; 62 } // namespace OHOS::DistributedKv 63 64 #endif //OHOS_DISTRIBUTED_DATA_DATAMGR_SERVICE_KVDB_QUERY_H 65