1 /* 2 * Copyright (c) 2021 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 NATIVE_RDB_RDBPREDICATES_H 17 #define NATIVE_RDB_RDBPREDICATES_H 18 19 20 #include "abs_rdb_predicates.h" 21 22 namespace OHOS { 23 namespace NativeRdb { 24 class RdbPredicates : public AbsRdbPredicates { 25 public: 26 explicit RdbPredicates(std::string tableName); ~RdbPredicates()27 ~RdbPredicates() override {} 28 void Clear() override; 29 void InitialParam(); 30 std::vector<std::string> GetJoinTypes(); 31 void SetJoinTypes(const std::vector<std::string> joinTypes); 32 std::vector<std::string> GetJoinTableNames(); 33 void SetJoinTableNames(const std::vector<std::string> joinTableNames); 34 std::vector<std::string> GetJoinConditions(); 35 void SetJoinConditions(const std::vector<std::string> joinConditions); 36 std::string GetJoinClause(); 37 int GetJoinCount() const; 38 void SetJoinCount(int joinCount); 39 RdbPredicates *CrossJoin(std::string tableName); 40 RdbPredicates *InnerJoin(std::string tableName); 41 RdbPredicates *LeftOuterJoin(std::string tableName); 42 RdbPredicates *Using(std::vector<std::string> fields); 43 RdbPredicates *On(std::vector<std::string> clauses); 44 45 private: 46 std::vector<std::string> joinTypes; 47 std::vector<std::string> joinTableNames; 48 std::vector<std::string> joinConditions; 49 int joinCount; 50 std::string ProcessJoins(); 51 std::string GetGrammar(int type) const; 52 RdbPredicates *Join(int join, std::string tableName); 53 }; 54 } // namespace NativeRdb 55 } // namespace OHOS 56 57 #endif