C++  1.4.6
CloudBackend Software Development Kit - SDK API for C++
Filter.h
1 /*
2  Copyright © CloudBackend AB 2020 - 2022..
3 */
4 
5 #ifndef INCLUDE_CBE_FILTER_H_
6 #define INCLUDE_CBE_FILTER_H_
7 
8 #include <string>
9 #include <map>
10 
11 #include "CBE/Types.h"
12 #include <vector>
13 
14 
15 namespace CBE {
16 
17  // enum FilterOrder : uint32_t {
18  // Title = 1,
19  // Relevance = 2,
20  // Published = 3,
21  // Updated = 4,
22  // Length = 5,
23  // S1 = 6,
24  // S2 = 7,
25  // S3 = 8,
26  // S4 = 9
27  // };
28  class Filter {
29 
30  public:
31  Filter();
32 
33 
34 
41  CBE::item_t getDataType() const;
42 
50  std::string getQuery() const;
51 
60  bool getAscending() const;
61 
68  bool getDeleted() const;
69 
76  bool getContainerFirst() const;
77 
84  bool isJoinedResult() const;
85 
92  uint32_t getOffset() const;
93 
101  uint32_t getCount() const;
102 
109  bool getByPassCache() const;
110 
116  CBE::FilterOrder getItemOrder() const;
117 
125  CBE::ContainerPtr container();
126 
130  void setDataType(CBE::item_t);
131 
132 
133 
139  void setQuery(std::string);
140 
146  void setAscending(bool);
147 
151  void setDeleted(bool);
152 
156  void setContainerFirst(bool);
157 
161  void setOffset(uint32_t);
162 
165  void setCount(uint32_t);
166 
168  void setItemOrder(CBE::FilterOrder order);
169 
171  void setByPassCache(bool);
172 
173  protected:
174 
179  static std::vector<std::string> _approvedOrder;
180  std::map<FilterOrder, std::string> orderStrings = {
181  { FilterOrder::Title, "title"},
182  { FilterOrder::Relevance, "relevance"},
183  { FilterOrder::Published, "published"},
184  { FilterOrder::Updated, "updated"},
185  { FilterOrder::Length, "length"},
186  { FilterOrder::S1, "s1"},
187  { FilterOrder::S2, "s2"},
188  { FilterOrder::S3, "s3"},
189  { FilterOrder::S4, "s4"}
190  };
191  uint32_t offset;
192  uint32_t count;
193  bool ascending;
194  bool deleted;
195  bool containerFirst;
196  bool isJoined;
197  std::string query;
198  CBE::item_t dataType;
199  std::string _order;
200  bool bypassCache;
201  void parseQueryString();
202  CBE::ContainerPtr _container;
203 
204  struct Term {
205  std::string modifier;
206  std::string prefix;
207  std::string str;
208  };
209 
210  std::vector<Term> _parsedQueryString;
211 
212 
213  };
214 }
215 
216 #endif // INCLUDE_CBE_FILTER_H_
CBE::Filter::setQuery
void setQuery(std::string)
CBE::Filter::getOffset
uint32_t getOffset() const
Get the Offset counter i.e. number of items to skip in the resultset returned.
CBE::Filter::setByPassCache
void setByPassCache(bool)
CBE::Filter::Term
Definition: Filter.h:204
CBE::Filter::setItemOrder
void setItemOrder(CBE::FilterOrder order)
CBE::Filter::setCount
void setCount(uint32_t)
CBE::Filter::setDataType
void setDataType(CBE::item_t)
Set the CBE::ItemType to filter on in the query.
CBE::Filter::getItemOrder
CBE::FilterOrder getItemOrder() const
Get the Item CBE::FilterOrder.
CBE::Filter::getQuery
std::string getQuery() const
Get the Query object Returns the query string that was set on the filter. I.e. key:value (name:*) wou...
CBE::Filter::getAscending
bool getAscending() const
Use the Ascending sorting in the resultset. Returns the settings on how the data is sorted and displa...
CBE::Filter::setOffset
void setOffset(uint32_t)
CBE::Filter::setContainerFirst
void setContainerFirst(bool)
Sort any Containers on top before Objects.
CBE::Filter::getDataType
CBE::item_t getDataType() const
Get the Data Type object I.E CBE::ItemType::Container, Object, Tag, ...
CBE::Filter::container
CBE::ContainerPtr container()
Returns the parent container / container that was queried, if it is in the cache. If not available,...
CBE::Filter
Definition: Filter.h:28
CBE::Filter::setAscending
void setAscending(bool)
Set the sorting order for the resultset, true=ascending false=descending.
CBE::Filter::isJoinedResult
bool isJoinedResult() const
If a join resultset.
CBE::Filter::getByPassCache
bool getByPassCache() const
Get the By Pass Cache seting.
CBE::Filter::getDeleted
bool getDeleted() const
Include any deleted objects.
CBE::Filter::getCount
uint32_t getCount() const
Get the Count object i.e. maximum number of items in the resultset. System has maximum limit of 1000 ...
CBE::Filter::getContainerFirst
bool getContainerFirst() const
Get the Container First filter order.
CBE::Filter::setDeleted
void setDeleted(bool)
Include any deleted objects.