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 RELATIONAL_STORE_IMPL_RDBPREDICATES_FFI_H 17 #define RELATIONAL_STORE_IMPL_RDBPREDICATES_FFI_H 18 19 #include "relational_store_utils.h" 20 #include <memory> 21 #include "ffi_remote_data.h" 22 #include "rdb_predicates.h" 23 #include <string> 24 #include "value_object.h" 25 26 namespace OHOS { 27 namespace Relational { 28 class RdbPredicatesImpl : public OHOS::FFI::FFIData { 29 public: GetRuntimeType()30 OHOS::FFI::RuntimeType* GetRuntimeType() override 31 { 32 return GetClassType(); 33 } 34 35 explicit RdbPredicatesImpl(const char* tableName); 36 37 explicit RdbPredicatesImpl(std::shared_ptr<NativeRdb::RdbPredicates> predicates); 38 39 void InDevices(const char** devicesArray, int64_t devicesSize); 40 41 void InAllDevices(); 42 43 void BeginWrap(); 44 45 void EndWrap(); 46 47 void Or(); 48 49 void And(); 50 51 void Contains(const char* field, const char* value); 52 53 void BeginsWith(const char* field, const char* value); 54 55 void EndsWith(const char* field, const char* value); 56 57 void IsNull(const char* field); 58 59 void IsNotNull(const char* field); 60 61 void Like(const char* field, const char* value); 62 63 void Glob(const char* field, const char* value); 64 65 void OrderByAsc(const char* field); 66 67 void OrderByDesc(const char* field); 68 69 void Distinct(); 70 71 void LimitAs(int32_t value); 72 73 void OffsetAs(int32_t rowOffset); 74 75 void GroupBy(const char** fieldsArray, int64_t fieldsSize); 76 77 void IndexedBy(const char* field); 78 79 void LessThanOrEqualTo(const char* field, ValueType value); 80 81 void EqualTo(const char* field, ValueType value); 82 83 void GreaterThanOrEqualTo(const char* field, ValueType value); 84 85 void GreaterThan(const char* field, ValueType value); 86 87 void NotBetween(const char* field, ValueType lowValue, ValueType highValue); 88 89 void LessThan(const char* field, ValueType value); 90 91 void Between(const char* field, ValueType lowValue, ValueType highValue); 92 93 void In(const char* field, ValueType* values, int64_t valuesSize); 94 95 void NotIn(const char* field, ValueType* values, int64_t valuesSize); 96 97 void NotEqualTo(const char* field, ValueType value); 98 99 std::shared_ptr<NativeRdb::RdbPredicates> GetPredicates(); 100 private: 101 std::shared_ptr<NativeRdb::RdbPredicates> predicates_; 102 103 friend class OHOS::FFI::RuntimeType; 104 105 friend class OHOS::FFI::TypeBase; 106 107 static OHOS::FFI::RuntimeType* GetClassType(); 108 }; 109 } 110 } 111 112 #endif