1 /* 2 * Copyright (c) 2022 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 DATASHARE_ABSPREDICATES_H 17 #define DATASHARE_ABSPREDICATES_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 #include <list> 23 #include "datashare_predicates_def.h" 24 25 namespace OHOS { 26 namespace DataShare { 27 class DataShareAbsPredicates { 28 public: 29 struct JsProxy { 30 std::shared_ptr<DataShareAbsPredicates> predicates_; 31 }; 32 /** 33 * @brief Destructor. 34 */ ~DataShareAbsPredicates()35 virtual ~DataShareAbsPredicates() {} 36 37 /** 38 * @brief The EqualTo of the predicate. 39 * 40 * @param field Indicates the target field. 41 * @param value Indicates the queried value. 42 */ 43 virtual DataShareAbsPredicates *EqualTo(const std::string &field, const SingleValue &value) = 0; 44 45 /** 46 * @brief The NotEqualTo of the predicate. 47 * 48 * @param field Indicates the target field. 49 * @param value Indicates the queried value. 50 */ 51 virtual DataShareAbsPredicates *NotEqualTo(const std::string &field, const SingleValue &value) = 0; 52 53 /** 54 * @brief The GreaterThan of the predicate. 55 * 56 * @param field Indicates the target field. 57 * @param value Indicates the queried value. 58 */ 59 virtual DataShareAbsPredicates *GreaterThan(const std::string &field, const SingleValue &value) = 0; 60 61 /** 62 * @brief The LessThan of the predicate. 63 * 64 * @param field Indicates the target field. 65 * @param value Indicates the queried value. 66 */ 67 virtual DataShareAbsPredicates *LessThan(const std::string &field, const SingleValue &value) = 0; 68 69 /** 70 * @brief The GreaterThanOrEqualTo of the predicate. 71 * 72 * @param field Indicates the target field. 73 * @param value Indicates the queried value. 74 */ 75 virtual DataShareAbsPredicates *GreaterThanOrEqualTo(const std::string &field, const SingleValue &value) = 0; 76 77 /** 78 * @brief The LessThanOrEqualTo of the predicate. 79 * 80 * @param field Indicates the target field. 81 * @param value Indicates the queried value. 82 */ 83 virtual DataShareAbsPredicates *LessThanOrEqualTo(const std::string &field, const SingleValue &value) = 0; 84 85 /** 86 * @brief The In of the predicate. 87 * 88 * @param field Indicates the target field. 89 * @param value Indicates the queried value. 90 */ 91 virtual DataShareAbsPredicates *In(const std::string &field, const MutliValue &value) = 0; 92 93 /** 94 * @brief The NotIn of the predicate. 95 * 96 * @param field Indicates the target field. 97 * @param value Indicates the queried value. 98 */ 99 virtual DataShareAbsPredicates *NotIn(const std::string &field, const MutliValue &value) = 0; 100 101 /** 102 * @brief BeginWrap. 103 */ 104 virtual DataShareAbsPredicates *BeginWrap() = 0; 105 106 /** 107 * @brief EndWrap. 108 */ 109 virtual DataShareAbsPredicates *EndWrap() = 0; 110 111 /** 112 * @brief Or. 113 */ 114 virtual DataShareAbsPredicates *Or() = 0; 115 116 /** 117 * @brief And. 118 */ 119 virtual DataShareAbsPredicates *And() = 0; 120 121 /** 122 * @brief The Contains of the predicate. 123 * 124 * @param field Indicates the target field. 125 * @param value Indicates the queried value. 126 */ 127 virtual DataShareAbsPredicates *Contains(const std::string &field, const std::string &value) = 0; 128 129 /** 130 * @brief The BeginsWith of the predicate. 131 * 132 * @param field Indicates the target field. 133 * @param value Indicates the queried value. 134 */ 135 virtual DataShareAbsPredicates *BeginsWith(const std::string &field, const std::string &value) = 0; 136 137 /** 138 * @brief The EndsWith of the predicate. 139 * 140 * @param field Indicates the target field. 141 * @param value Indicates the queried value. 142 */ 143 virtual DataShareAbsPredicates *EndsWith(const std::string &field, const std::string &value) = 0; 144 145 /** 146 * @brief The IsNull of the predicate. 147 * 148 * @param field Indicates the target field. 149 * @param value Indicates the queried value. 150 */ 151 virtual DataShareAbsPredicates *IsNull(const std::string &field) = 0; 152 153 /** 154 * @brief The IsNotNull of the predicate. 155 * 156 * @param field Indicates the target field. 157 * @param value Indicates the queried value. 158 */ 159 virtual DataShareAbsPredicates *IsNotNull(const std::string &field) = 0; 160 161 /** 162 * @brief The Like of the predicate. 163 * 164 * @param field Indicates the target field. 165 * @param value Indicates the queried value. 166 */ 167 virtual DataShareAbsPredicates *Like(const std::string &field, const std::string &value) = 0; 168 169 /** 170 * @brief The Unlike of the predicate. 171 * 172 * @param field Indicates the target field. 173 * @param value Indicates the queried value. 174 */ 175 virtual DataShareAbsPredicates *Unlike(const std::string &field, const std::string &value) = 0; 176 177 /** 178 * @brief The Glob of the predicate. 179 * 180 * @param field Indicates the target field. 181 * @param value Indicates the queried value. 182 */ 183 virtual DataShareAbsPredicates *Glob(const std::string &field, const std::string &value) = 0; 184 185 /** 186 * @brief The Between of the predicate. 187 * 188 * @param field Indicates the target field. 189 * @param value Indicates the queried value. 190 */ 191 virtual DataShareAbsPredicates *Between(const std::string &field, 192 const std::string &low, const std::string &high) = 0; 193 194 /** 195 * @brief The NotBetween of the predicate. 196 * 197 * @param field Indicates the target field. 198 * @param value Indicates the queried value. 199 */ 200 virtual DataShareAbsPredicates *NotBetween(const std::string &field, 201 const std::string &low, const std::string &high) = 0; 202 203 /** 204 * @brief The OrderByAsc of the predicate. 205 * 206 * @param field Indicates the target field. 207 * @param value Indicates the queried value. 208 */ 209 virtual DataShareAbsPredicates *OrderByAsc(const std::string &field) = 0; 210 211 /** 212 * @brief The OrderByDesc of the predicate. 213 * 214 * @param field Indicates the target field. 215 * @param value Indicates the queried value. 216 */ 217 virtual DataShareAbsPredicates *OrderByDesc(const std::string &field) = 0; 218 219 /** 220 * @brief Distinct predicate condition. 221 */ 222 virtual DataShareAbsPredicates *Distinct() = 0; 223 224 /** 225 * @brief The Limit of the predicate. 226 * 227 * @param number Indicates the target number. 228 * @param offset Indicates the queried value. 229 */ 230 virtual DataShareAbsPredicates *Limit(const int number, const int offset) = 0; 231 232 /** 233 * @brief The GroupBy of the predicate. 234 * 235 * @param field Indicates the target field. 236 */ 237 virtual DataShareAbsPredicates *GroupBy(const std::vector<std::string> &fields) = 0; 238 239 /** 240 * @brief The IndexedBy of the predicate. 241 * 242 * @param indexName indicates the query condition. 243 */ 244 virtual DataShareAbsPredicates *IndexedBy(const std::string &indexName) = 0; 245 246 /** 247 * @brief The KeyPrefix of the predicate. 248 * 249 * @param Search by prefix conditions. 250 */ 251 virtual DataShareAbsPredicates *KeyPrefix(const std::string &prefix) = 0; 252 253 /** 254 * @brief The InKeys of the predicate. 255 * 256 * @param Query based on key conditions. 257 */ 258 virtual DataShareAbsPredicates *InKeys(const std::vector<std::string> &keys) = 0; 259 260 /** 261 * @brief The CrossJoin of the predicate. 262 * 263 * @param tableName indicates the query condition. 264 */ 265 virtual DataShareAbsPredicates *CrossJoin(const std::string &tableName) = 0; 266 267 /** 268 * @brief The InnerJoin of the predicate. 269 * 270 * @param tableName indicates the query condition. 271 */ 272 virtual DataShareAbsPredicates *InnerJoin(const std::string &tableName) = 0; 273 274 /** 275 * @brief The LeftOuterJoin of the predicate. 276 * 277 * @param tableName indicates the query condition. 278 */ 279 virtual DataShareAbsPredicates *LeftOuterJoin(const std::string &tableName) = 0; 280 281 /** 282 * @brief The Using of the predicate. 283 * 284 * @param field Indicates the target field. 285 */ 286 virtual DataShareAbsPredicates *Using(const std::vector<std::string> &fields) = 0; 287 288 /** 289 * @brief The On of the predicate. 290 * 291 * @param field Indicates the target field. 292 */ 293 virtual DataShareAbsPredicates *On(const std::vector<std::string> &fields) = 0; 294 295 /** 296 * @brief The GetOperationList of the predicate. 297 */ 298 virtual const std::vector<OperationItem>& GetOperationList() const = 0; 299 300 /** 301 * @brief The GetWhereClause of the predicate. 302 */ 303 virtual std::string GetWhereClause() const = 0; 304 305 /** 306 * @brief The SetWhereClause of the predicate. 307 * 308 * @param Query based on the whereClause. 309 */ 310 virtual int SetWhereClause(const std::string &whereClause) = 0; 311 312 /** 313 * @brief The GetWhereArgs of the predicate. 314 */ 315 virtual std::vector<std::string> GetWhereArgs() const = 0; 316 317 /** 318 * @brief The SetWhereArgs of the predicate. 319 * 320 * @param Query based on whereArgs conditions. 321 */ 322 virtual int SetWhereArgs(const std::vector<std::string> &whereArgs) = 0; 323 324 /** 325 * @brief The GetOrder of the predicate. 326 */ 327 virtual std::string GetOrder() const = 0; 328 329 /** 330 * @brief The SetOrder of the predicate. 331 * 332 * @param Query based on order conditions.. 333 */ 334 virtual int SetOrder(const std::string &order) = 0; 335 336 /** 337 * @brief The GetSettingMode of the predicate. 338 */ 339 virtual int16_t GetSettingMode() const = 0; 340 }; 341 } // namespace DataShare 342 } // namespace OHOS 343 344 #endif