Nebula
Loading...
Searching...
No Matches
Db::FilterSet Class Reference

#include <filterset.h>

Detailed Description

Implements a filter for datatbase data using a condition tree.

A filter can be compiled into a SQL WHERE statement.

Inherits Core::RefCounted.

Inherited by Db::Sqlite3FilterSet.

Classes

class  Token

Public Member Functions

 FilterSet ()
 constructor
virtual ~FilterSet ()
 destructor
void Clear ()
 clear the filter
void ClearDirtyFlag ()
 clear the dirty state of the filter (every op on the filter will make it dirty)
bool IsDirty () const
 return true if the filter is dirty
bool IsEmpty () const
 return true if the filter is empty
void BeginBlock ()
 begin a new level in the condition tree (opens a bracket)
void EndBlock ()
 end the current level in the condition tree (close current bracket)
void AddEqualCheck (const Attr::Attribute &attr)
 add an equality check
void AddGreaterThenCheck (const Attr::Attribute &attr)
 add a greater check
void AddLessThenCheck (const Attr::Attribute &attr)
 add a lesser check
void AddGreaterOrEqualCheck (const Attr::Attribute &attr)
 add a greater-equals check
void AddLessOrEqualCheck (const Attr::Attribute &attr)
 add a lesser-equals check
void AddAnd ()
 add a boolean AND
void AddOr ()
 add a boolean OR
void AddNot ()
 add a boolean NOT
virtual Util::String AsSqlWhere () const
 compile into an SQL WHERE statement
virtual void BindValuesToCommand (const Ptr< Command > &cmd, IndexT wildcardStartIndex)
 bind filter attribute values to command
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Protected Attributes

Util::SimpleTree< Tokentokens
Util::SimpleTree< Token >::Node * curToken
Util::Array< Attr::AttributebindAttrs
bool isDirty

Private Member Functions

 __DeclareClass (FilterSet)

Additional Inherited Members

Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Constructor & Destructor Documentation

◆ FilterSet()

Db::FilterSet::FilterSet ( )

constructor

◆ ~FilterSet()

Db::FilterSet::~FilterSet ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Db::FilterSet::__DeclareClass ( FilterSet )
private

◆ AddAnd()

void Db::FilterSet::AddAnd ( )

add a boolean AND

This adds an AND boolean operation.

This may not be the first or last token in a block (this is checked by the next End()).

◆ AddEqualCheck()

void Db::FilterSet::AddEqualCheck ( const Attr::Attribute & attr)

add an equality check

This adds an equal-check to the filter, where the attribute's id defines the column, and the attribute's value is the value to check the column's contents against.

◆ AddGreaterOrEqualCheck()

void Db::FilterSet::AddGreaterOrEqualCheck ( const Attr::Attribute & attr)

add a greater-equals check

This adds a greater-equal-check to the filter, where the attribute's id defines the column, and the attribute's value is the value to check the column's contents against.

◆ AddGreaterThenCheck()

void Db::FilterSet::AddGreaterThenCheck ( const Attr::Attribute & attr)

add a greater check

This adds an greater-check to the filter, where the attribute's id defines the column, and the attribute's value is the value to check the column's contents against.

◆ AddLessOrEqualCheck()

void Db::FilterSet::AddLessOrEqualCheck ( const Attr::Attribute & attr)

add a lesser-equals check

This adds a less-equal-check to the filter, where the attribute's id defines the column, and the attribute's value is the value to check the column's contents against.

◆ AddLessThenCheck()

void Db::FilterSet::AddLessThenCheck ( const Attr::Attribute & attr)

add a lesser check

This adds a less-check to the filter, where the attribute's id defines the column, and the attribute's value is the value to check the column's contents against.

◆ AddNot()

void Db::FilterSet::AddNot ( )

add a boolean NOT

This adds an NOT boolean operation.

This may not be last token in a block (this is checked by the next End()).

◆ AddOr()

void Db::FilterSet::AddOr ( )

add a boolean OR

This adds an OR boolean operation.

This may not be the first or last token in a block (this is checked by the next End()).

◆ AsSqlWhere()

String Db::FilterSet::AsSqlWhere ( ) const
virtual

compile into an SQL WHERE statement

This method should return a string fragment which contains the part behind an SQL WHERE representing the condition tree encoded in this Filter object.

Reimplemented in Db::Sqlite3FilterSet.

◆ BeginBlock()

void Db::FilterSet::BeginBlock ( )

begin a new level in the condition tree (opens a bracket)

This starts a new statement block (think of it as opening brackets) and makes it current token.

All following statements will go below this block, until the method End() is called.

◆ BindValuesToCommand()

void Db::FilterSet::BindValuesToCommand ( const Ptr< Command > & cmd,
IndexT wildcardStartIndex )
virtual

bind filter attribute values to command

This methods binds the actual WHERE values to a compiled command.

Reimplemented in Db::Sqlite3FilterSet.

◆ Clear()

void Db::FilterSet::Clear ( )

clear the filter

◆ ClearDirtyFlag()

void Db::FilterSet::ClearDirtyFlag ( )
inline

clear the dirty state of the filter (every op on the filter will make it dirty)

◆ EndBlock()

void Db::FilterSet::EndBlock ( )

end the current level in the condition tree (close current bracket)

This ends the current statement block.

The method will make sure that there is no dangling And/Or token, and that the root level isn't reached yet.

◆ IsDirty()

bool Db::FilterSet::IsDirty ( ) const
inline

return true if the filter is dirty

◆ IsEmpty()

bool Db::FilterSet::IsEmpty ( ) const
inline

return true if the filter is empty

Member Data Documentation

◆ bindAttrs

Util::Array<Attr::Attribute> Db::FilterSet::bindAttrs
protected

◆ curToken

Util::SimpleTree<Token>::Node* Db::FilterSet::curToken
protected

◆ isDirty

bool Db::FilterSet::isDirty
protected

◆ tokens

Util::SimpleTree<Token> Db::FilterSet::tokens
protected

The documentation for this class was generated from the following files: