26 template<
typename TYPE>
33 enum class opts{AND = 1, OR = 0, NOT = 2, LEFT_BRACKET = 3, RIGHT_BRACKET = 4};
156 template <
typename TYPE>
260 template <
typename TYPE>
263 template <
typename TYPE>
266 this->stream.pushBegin(nullFilter);
267 this->stream.pushEnd(nullFilter);
268 this->ops.pushBegin(opts::LEFT_BRACKET);
269 this->ops.pushEnd(opts::RIGHT_BRACKET);
272 template <
typename TYPE>
275 this->stream.pushEnd(nullFilter);
276 this->ops.pushEnd(opts::AND);
279 template <
typename TYPE>
282 this->stream.pushEnd(nullFilter);
283 this->ops.pushEnd(opts::OR);
286 template <
typename TYPE>
289 this->stream.pushBegin(nullFilter);
290 this->ops.pushBegin(opts::NOT);
293 template <
typename TYPE>
299 template <
typename TYPE>
302 for (
auto&
filter: fs.stream)
304 this->stream.pushEnd(
filter);
306 for (
auto& op: fs.ops)
308 this->ops.pushEnd(op);
312 template <
typename TYPE>
320 auto it_stream = this->stream.
begins();
321 auto it_ops = this->ops.begins();
323 while (it_stream->isValid()){
324 if (it_stream->get() != nullFilter){
325 stream_post.
pushEnd(it_stream->get());
326 }
else if (it_ops->isValid()){
327 switch (it_ops->get()) {
328 case opts::LEFT_BRACKET:
329 ops_tmp.
pushEnd(opts::LEFT_BRACKET);
331 case opts::RIGHT_BRACKET:
332 while (!ops_tmp.
empty() && ops_tmp[-1] != opts::LEFT_BRACKET){
333 stream_post.
pushEnd(nullFilter);
342 while (!ops_tmp.
empty()
343 && ops_tmp[-1] >= it_ops->
get()
344 && ops_tmp[-1] != opts::LEFT_BRACKET){
345 stream_post.
pushEnd(nullFilter);
348 ops_tmp.
pushEnd(it_ops->get());
356 while (!ops_tmp.
empty()){
357 stream_post.
pushEnd(nullFilter);
360 this->stream = stream_post;
361 this->ops = ops_post;
366 template <
typename TYPE>
374 template <
typename TYPE>
382 template <
typename TYPE>
390 template <
typename TYPE>
398 template <
typename TYPE>
406 template <
typename TYPE>
415 template <
typename TYPE>
416 auto original::operator&&(
const filter<TYPE> &f,
const filterStream<TYPE> &ofs) -> filterStream<TYPE> {
417 filterStream<TYPE> fs;
424 template<
typename TYPE>
430 template <
typename TYPE>
439 template <
typename TYPE>
448 template<
typename TYPE>
454 template <
typename TYPE>
462 template<
typename TYPE>
468 template<
typename TYPE>
476 template<
typename TYPE>
483 template <
typename TYPE>
488 auto it_stream = this->stream.
begins();
489 auto it_ops = this->ops.begins();
491 while (it_stream->isValid()){
492 if (it_stream->get() != nullFilter){
493 value_stack.
pushEnd(it_stream->get()->operator()(t));
494 }
else if (it_ops->isValid()){
495 switch (it_ops->get()) {
497 value_stack[-1] = !value_stack[-1];
500 const bool right = value_stack.
popEnd();
501 const bool left = value_stack.
popEnd();
502 value_stack.
pushEnd(it_ops->get() == opts::AND ?
503 left && right : left || right);
512 return value_stack[-1];
Non-cyclic doubly linked list implementation.
Non-cyclic doubly linked list container.
Definition chain.h:36
TYPE popEnd() override
Pops an element from the end of the chain.
Definition chain.h:836
Iterator * begins() const override
Gets an iterator to the beginning of the chain.
Definition chain.h:858
TYPE get(integer index) const override
Gets the element at the specified index.
Definition chain.h:698
void pushEnd(const TYPE &e) override
Pushes an element to the end of the chain.
Definition chain.h:776
bool empty() const
Checks if the container is empty.
Definition container.h:155
Composite filter builder with logical operator chaining.
Definition filterStream.h:28
friend filterStream< T > operator&&(const filter< T > &f, const filterStream< T > &ofs)
AND operator between filter and filterStream.
filterStream & operator&&(const filter< TYPE > &f)
AND operator with single filter.
Definition filterStream.h:367
void toPostFix() const
Convert infix notation to postfix.
Definition filterStream.h:313
friend filterStream< T > operator!(const filter< T > &f)
Create negated filterStream from filter.
void pushEnd(const filter< TYPE > &f)
Append filter to the stream.
Definition filterStream.h:294
friend filterStream< T > operator!(const filterStream< T > &ofs)
Create negated filterStream from existing stream.
friend filterStream< T > operator||(const filterStream< T > &ofs, const filter< T > &f)
OR operator between filterStream and filter.
void addNotOpt()
Add NOT operator to the stream.
Definition filterStream.h:287
void addBrackets()
Add bracket operators for grouping.
Definition filterStream.h:264
friend filterStream< T > operator||(const filter< T > &f1, const filter< T > &f2)
Create OR filterStream from two filters.
filterStream & operator!()
Logical NOT operator.
Definition filterStream.h:399
void addAndOpt()
Add AND operator to the stream.
Definition filterStream.h:273
friend filterStream< T > operator&&(const filterStream< T > &ofs, const filter< T > &f)
AND operator between filterStream and filter.
bool operator()(const TYPE &t) const
Filter evaluation operator.
Definition filterStream.h:484
friend filterStream< T > operator&&(const filter< T > &f1, const filter< T > &f2)
Create AND filterStream from two filters.
void pushAll(const filterStream &fs)
Merge another filterStream into this one.
Definition filterStream.h:300
friend filterStream< T > group(const filterStream< T > &ofs)
Create grouped filterStream from existing stream.
void addOrOpt()
Add OR operator to the stream.
Definition filterStream.h:280
friend filterStream< T > group(const filter< T > &f)
Create grouped filterStream from single filter.
friend filterStream< T > operator||(const filter< T > &f, const filterStream< T > &ofs)
OR operator between filter and filterStream.
filterStream & operator||(const filter< TYPE > &f)
OR operator with single filter.
Definition filterStream.h:383
filterStream()
Protected constructor for stream initialization.
Definition filterStream.h:261
Base class for filter operations.
Definition filter.h:31
Shared ownership smart pointer with strong references.
Definition refCntPtr.h:100
Filter base class and derived filter classes for various matching operations.
Main namespace for the project Original.
Definition algorithms.h:21
filterStream< T > operator&&(const filter< T > &f1, const filter< T > &f2)
Create AND filterStream from two filters.
filterStream< T > operator!(const filter< T > &f)
Create negated filterStream from filter.
filterStream< T > operator||(const filter< T > &f1, const filter< T > &f2)
Create OR filterStream from two filters.
filterStream< T > group(const filterStream< T > &ofs)
Create grouped filterStream from existing stream.
Reference-counted smart pointer hierarchy.