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