1 /*
2  * Copyright (c) 2023-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 #ifndef HIVIEW_BASE_EVENT_STORE_INCLUDE_DOC_QUERY_H
16 #define HIVIEW_BASE_EVENT_STORE_INCLUDE_DOC_QUERY_H
17 
18 #include <string>
19 
20 namespace OHOS {
21 namespace HiviewDFX {
22 namespace EventStore {
23 class Cond;
24 class FieldValue;
25 
26 class DocQuery {
27 public:
28     std::pair<std::string, bool> GetOrderField();
29     void And(const Cond& cond);
30     bool IsContainExtraConds(uint8_t* content) const;
31     bool IsContainInnerConds(uint8_t* content) const;
32     std::string ToString() const;
33 
34 private:
35 #pragma pack(1)
36     /* for internal field query */
37     struct InnerFieldStruct {
38         int64_t seq;
39         uint64_t ts;
40         uint8_t tz;
41         uint32_t uid;
42         uint32_t pid;
43         uint32_t tid;
44     };
45     using InnerFieldStruct = struct InnerFieldStruct;
46 #pragma pack()
47 
48     bool IsContainInnerCond(const InnerFieldStruct& innerField, const Cond& cond) const;
49     bool IsContainCond(const Cond& cond, const FieldValue& value) const;
50     bool IsInnerCond(const Cond& cond) const;
51 
52     std::vector<Cond> innerConds_;
53     std::vector<Cond> extraConds_;
54 }; // DocQuery
55 } // EventStore
56 } // HiviewDFX
57 } // OHOS
58 #endif // HIVIEW_BASE_EVENT_STORE_INCLUDE_DOC_QUERY_H
59