1 /* 2 * Copyright (c) 2023 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 RELATIONAL_PREDICATES_IMPL_H 17 #define RELATIONAL_PREDICATES_IMPL_H 18 19 #include "rdb_predicates.h" 20 #include "oh_predicates.h" 21 22 namespace OHOS { 23 namespace RdbNdk { 24 constexpr int RDB_PREDICATES_CID = 1234561; // The class id used to uniquely identify the OH_Predicates class. 25 class RelationalPredicate : public OH_Predicates { 26 public: 27 explicit RelationalPredicate(const char *table); 28 static RelationalPredicate *GetSelf(OH_Predicates *predicates); 29 OHOS::NativeRdb::RdbPredicates &Get(); 30 private: 31 static OH_Predicates *EqualTo(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 32 static OH_Predicates *NotEqualTo(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 33 static OH_Predicates *BeginWrap(OH_Predicates *predicates); 34 static OH_Predicates *EndWrap(OH_Predicates *predicates); 35 static OH_Predicates *Or(OH_Predicates *predicates); 36 static OH_Predicates *And(OH_Predicates *predicates); 37 static OH_Predicates *IsNull(OH_Predicates *predicates, const char *field); 38 static OH_Predicates *IsNotNull(OH_Predicates *predicates, const char *field); 39 static OH_Predicates *Like(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 40 static OH_Predicates *Between(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 41 static OH_Predicates *NotBetween(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 42 static OH_Predicates *GreaterThan(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 43 static OH_Predicates *LessThan(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 44 static OH_Predicates *GreaterThanOrEqualTo(OH_Predicates *predicates, const char *field, 45 OH_VObject *valueObject); 46 static OH_Predicates *LessThanOrEqualTo(OH_Predicates *predicates, const char *field, 47 OH_VObject *valueObject); 48 static OH_Predicates *OrderBy(OH_Predicates *predicates, const char *field, OH_OrderType type); 49 static OH_Predicates *Distinct(OH_Predicates *predicates); 50 static OH_Predicates *Limit(OH_Predicates *predicates, unsigned int value); 51 static OH_Predicates *Offset(OH_Predicates *predicates, unsigned int rowOffset); 52 static OH_Predicates *GroupBy(OH_Predicates *predicates, char const *const *fields, int length); 53 static OH_Predicates *In(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 54 static OH_Predicates *NotIn(OH_Predicates *predicates, const char *field, OH_VObject *valueObject); 55 static OH_Predicates *Clear(OH_Predicates *predicates); 56 static int Destroy(OH_Predicates *predicates); 57 static bool GetObjects(OH_Predicates *predicates, OH_VObject *valueObject, 58 std::vector<std::string> &values); 59 OHOS::NativeRdb::RdbPredicates predicates_; 60 }; 61 } // namespace RdbNdk 62 } // namespace OHOS 63 #endif // RELATIONAL_PREDICATES_IMPL_H 64