Search Query Node. More...

#include <gsearchquerynode.h>

Inheritance diagram for GSearchQueryNode:
[legend]

Public Types

enum  tNode { nOperator, nToken }
 Query Node Type. More...
 
enum  tOperator {
  oNOP, oNOT, oOR, oAND,
  oINC, oSIB, oNAND, oNINC,
  oNSIB
}
 Query Operator Type. More...
 

Public Member Functions

 GSearchQueryNode (tOperator op)
 
 GSearchQueryNode (GConcept *concept, GSearchToken::tType type)
 
 GSearchQueryNode (GSession *session, const R::RString &token, GSearchToken::tType type)
 
int Compare (const GSearchQueryNode &node) const
 
GSearchQueryNodeGetFirst (void) const
 
GSearchQueryNodeGetLast (void) const
 
GSearchQueryNodeGetParent (void) const
 
size_t GetDepth (void) const
 
size_t GetNbNodes (void) const
 
tNode GetType (void) const
 
bool IsOperator (void) const
 
bool IsToken (void) const
 
tOperator GetOperator (void) const
 
R::RString GetOperatorName (void) const
 
GSearchTokenGetToken (void) const
 
 ~GSearchQueryNode (void)
 

Static Public Member Functions

static tOperator GetOperator (const R::RChar c)
 
static tOperator GetNotOperator (const R::RChar c)
 

Private Attributes

tNode Type
 
union {
   tOperator   Operator
 
   GSearchToken *   Token
 
Value
 

Detailed Description

Search Query Node.

The GSearchQueryNode class provides a representation of a query node. In practice, a node is either an operator or a token.

Member Enumeration Documentation

enum tNode

Query Node Type.

A query is a tree composed from nodes which are either operators or concepts.

Enumerator
nOperator 
nToken 

The node is an operator. The node is a token.

enum tOperator

Query Operator Type.

Several operators can be used in a structured query. Besides the classical Boolean operators, some operators allow hierarchical relations.

Enumerator
oNOP 
oNOT 

Invalid operator.

oOR 

NOT operator.

oAND 

OR operator.

oINC 

AND operator.

oSIB 

INCLUSION operator. "a INC b" supposes that 'b' is a concept that must appear in a child node of ones containing 'a'.

oNAND 

SIBLING operator. "a SIB b" supposes that 'a' and 'b' must appear in the same node.

oNINC 

NOT AND operator.

oNSIB 

NOT INCLUSION operator. NOT SUBLING operator.

Constructor & Destructor Documentation

Construct an operator node.

Parameters
opOperator.
GSearchQueryNode ( GConcept concept,
GSearchToken::tType  type 
)

Construct a token.

Parameters
sessionSession.
conceptConcept.
GSearchQueryNode ( GSession session,
const R::RString token,
GSearchToken::tType  type 
)

Construct a token.

Parameters
sessionSession.
tokenString containing the token.
typeType of the token.
~GSearchQueryNode ( void  )

Destructor.

Member Function Documentation

int Compare ( const GSearchQueryNode node) const

Compare two node. In practice, the method does nothing.

Parameters
nodeNode to compare with.
Returns
always -1
GSearchQueryNode* GetFirst ( void  ) const
Returns
the first child node. If null, the node has no children.
GSearchQueryNode* GetLast ( void  ) const
Returns
the last child node. If null, the node has no children.
GSearchQueryNode* GetParent ( void  ) const
Returns
the parent node. If null, the node is a top node.
size_t GetDepth ( void  ) const

Get the depth of the node.

Returns
the depth.
size_t GetNbNodes ( void  ) const

Get the number of child nodes.

Returns
the number of child nodes.
tNode GetType ( void  ) const

Get the type of the bode.

Returns
the type of the node.
bool IsOperator ( void  ) const

Look if the node is an operator.

Returns
true if the node is an operator.
bool IsToken ( void  ) const

Look if the node is a token.

Returns
true if the node is a token.
tOperator GetOperator ( void  ) const

Get the operator.

Returns
the operator of the node.
Exceptions
anexception is generated if the node doesn't contain an operator.
R::RString GetOperatorName ( void  ) const

Get the name of the operator.

Returns
a R::RString.
Exceptions
anexception is generated if the node doesn't contain an operator.
GSearchToken* GetToken ( void  ) const

Get the token corresponding to the node.

Returns
a string.
Exceptions
anexception is generated if the node doesn't contain a token.
static tOperator GetOperator ( const R::RChar  c)
static

Look if a character correspond to a given operator.

Parameters
cCharacter to look for.
Returns
the operator or toNOP if the character is an invalid one.
static tOperator GetNotOperator ( const R::RChar  c)
static

Look if a given character correspond to a operator that can be inverted.

Parameters
cCharacter to look for.
Returns
the operator or toNOP if the character is an invalid one or has no inverted version.

Member Data Documentation

tNode Type
private

Type of the node.

tOperator Operator

The node corresponds to an operator.

GSearchToken* Token

The node corresponds to a token.

union { ... } Value

Value of the node.