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