crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
QueryStruct.hpp
Go to the documentation of this file.
1 /*
2  *
3  * ---
4  *
5  * Copyright (C) 2020 Anselm Schmidt (ans[ät]ohai.su)
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version in addition to the terms of any
11  * licences already herein identified.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  *
21  * ---
22  *
23  * QueryStruct.hpp
24  *
25  * Structure to identify a query including its type and its result type(s).
26  *
27  * Created on: May 17, 2019
28  * Author: ans
29  */
30 
31 #ifndef STRUCT_QUERYSTRUCT_HPP_
32 #define STRUCT_QUERYSTRUCT_HPP_
33 
34 #include <cstddef> // std::size_t
35 #include <cstdint> // std::uint8_t
36 
37 namespace crawlservpp::Struct {
38 
40  struct QueryStruct {
41  /*
42  * CONSTANTS
43  */
44 
47 
49  inline static constexpr std::uint8_t typeNone{0};
50 
52  inline static constexpr std::uint8_t typeRegEx{1};
53 
55  inline static constexpr std::uint8_t typeXPath{2};
56 
58  inline static constexpr std::uint8_t typeJsonPointer{3};
59 
61  inline static constexpr std::uint8_t typeJsonPath{4};
62 
64  inline static constexpr std::uint8_t typeXPathJsonPointer{5};
65 
67  inline static constexpr std::uint8_t typeXPathJsonPath{6};
68 
72 
74  std::uint8_t type{QueryStruct::typeNone};
75 
77  std::size_t index{};
78 
80  bool resultBool{false};
81 
83  bool resultSingle{false};
84 
86  bool resultMulti{false};
87 
89 
93  bool resultSubSets{false};
94 
98 
100  QueryStruct() = default;
101 
103 
122  std::uint8_t setType,
123  std::size_t setIndex,
124  bool setResultBool,
125  bool setResultSingle,
126  bool setResultMulti,
127  bool setResultSubSets
128  ) : type(setType),
129  index(setIndex),
130  resultBool(setResultBool),
131  resultSingle(setResultSingle),
132  resultMulti(setResultMulti),
133  resultSubSets(setResultSubSets) {}
134 
138 
140 
145  [[nodiscard]] bool valid() const noexcept {
146  return this->index != 0;
147  }
148 
150  };
151 
152 } /* namespace crawlservpp::Struct */
153 
154 #endif /* STRUCT_QUERYSTRUCT_HPP_ */
static constexpr std::uint8_t typeJsonPointer
Query type identifying a JSONPointer query.
Definition: QueryStruct.hpp:58
bool resultBool
Indicates whether the query generates a boolean result.
Definition: QueryStruct.hpp:80
bool resultSingle
Indicates whether the query generates a single result.
Definition: QueryStruct.hpp:83
bool resultMulti
Indicates whether the query generates multiple results.
Definition: QueryStruct.hpp:86
static constexpr std::uint8_t typeJsonPath
Query type identifying a JSONPath query.
Definition: QueryStruct.hpp:61
bool valid() const noexcept
Gets whether the query is valid, i.e. whether a query ID has been identified.
Definition: QueryStruct.hpp:145
QueryStruct(std::uint8_t setType, std::size_t setIndex, bool setResultBool, bool setResultSingle, bool setResultMulti, bool setResultSubSets)
Constructor explicitly setting the properties.
Definition: QueryStruct.hpp:121
std::uint8_t type
The type of the query (see above).
Definition: QueryStruct.hpp:74
bool resultSubSets
Indicates whether the query generates subsets as results.
Definition: QueryStruct.hpp:93
static constexpr std::uint8_t typeNone
Unspecified query type.
Definition: QueryStruct.hpp:49
static constexpr std::uint8_t typeRegEx
Query type identifying a RegEx query.
Definition: QueryStruct.hpp:52
static constexpr std::uint8_t typeXPathJsonPointer
Query type identifying a combined XPath and JSONPointer query.
Definition: QueryStruct.hpp:64
std::size_t index
The index of the query inside its container.
Definition: QueryStruct.hpp:77
static constexpr std::uint8_t typeXPathJsonPath
Query type identifying a combined XPath and JSONPath query.
Definition: QueryStruct.hpp:67
QueryStruct()=default
Default constructor.
Structure to identify a query including its type and result type(s).
Definition: QueryStruct.hpp:40
Namespace for data structures.
Definition: AlgoThreadProperties.hpp:43
static constexpr std::uint8_t typeXPath
Query type identifying a XPath query.
Definition: QueryStruct.hpp:55