ddc
Public Attributes | List of all members
CQuery Class Reference

Truly abstract (index-independent) representation of a parsed query Should eventually replace old ad-hoc QueryNode.h. More...

#include <Query.h>

Inheritance diagram for CQuery:
Inheritance graph
[legend]
Collaboration diagram for CQuery:
Collaboration graph
[legend]

Public Member Functions

Constructors etc.
 CQuery (const string &label=string(""))
 Default constructor. More...
 
virtual ~CQuery (void)
 
API
virtual bool CheckSatisfiable (CQueryCompiler *compiler)
 
virtual bool Compile (CQueryCompiler *compiler)
 
virtual bool CompileOptions (CQueryCompiler *compiler=NULL)
 
virtual void Evaluate ()
 
virtual bool Negated ()
 For sanity checks. Default just returns false. More...
 
virtual bool Negate ()
 Toggle negation flag, returns new value. Default throws an exception. More...
 
virtual BYTE GetMatchId () const
 Get current match-id (should return a nontrivial match-id if any was used, else 0; default just returns 0) More...
 
virtual BYTE SetMatchId (BYTE matchId)
 Set match-id, returns new value. Default throws an exception. More...
 
virtual bool HasMatchId () const
 Returns true iff this query uses a nontrival match-id operator; default checks (this->GetMatchId() != 0) More...
 
virtual bool RootOK ()
 Is this query an admissible root of a compiled parse tree (default returns !this->Negated()) More...
 
Object Substructure (ddcObject API)
virtual ddcObjectList Children () const
 
virtual void DisownChildren ()
 
Stringification (ddcObject API & associated utilities)
virtual string toString ()
 DEBUG: return a canonical string form for this query (default just returns m_Label) More...
 
virtual string optionsToString ()
 DEBUG: return canonical option string More...
 
virtual string optionsToJson ()
 return json format option string More...
 
virtual string toJson ()
 
virtual string jsonClass ()
 
virtual string jsonData ()
 
Misc Utilities
void SetCompiler (CQueryCompiler *compiler)
 
virtual void ClearNode ()
 deletes m_Node if non-NULL More...
 
virtual void ClearOptions ()
 deletes m_Options if non-NULL More...
 
virtual void Clear (bool deep=true)
 clear query contents. if deep is true, propagates operation to daughters More...
 
virtual void SetOptions (CQueryOptions *opts)
 set global query options ; deletes any pre-existing m_Options More...
 
- Public Member Functions inherited from ddcObject
 ddcObject ()
 Default constructor. More...
 
virtual ~ddcObject ()
 virtual destructor does nothing More...
 
template<typename Visit >
ddcObjectTraverse (Visit &visit)
 
template<typename Visit >
ddcObjectTraverse (Visit &visit) const
 
template<typename Visit >
ddcObjectTraverseR (Visit &visit)
 
template<typename Visit >
ddcObjectTraverseR (Visit &visit) const
 
virtual ddcObjectList Descendants () const
 

Public Attributes

string m_Label
 arbitrary name for this query node (e.g. string from which it was parsed) More...
 
CQueryCompilerm_Compiler
 associated query compiler (only set on Compile()) More...
 
CQueryNodem_Node
 underlying CQueryNode (DDC-v1.x API) More...
 
CQueryOptionsm_Options
 root-level options (root queries only) More...
 
- Public Attributes inherited from ddcObject
void * m_User
 user data associated with this object (for use e.g. by perl wrappers) More...
 

Detailed Description

Truly abstract (index-independent) representation of a parsed query Should eventually replace old ad-hoc QueryNode.h.

Constructor & Destructor Documentation

◆ CQuery()

CQuery::CQuery ( const string &  label = string(""))
inline

Default constructor.

◆ ~CQuery()

CQuery::~CQuery ( void  )
virtual

Default destructor.

  • child classes should propagate deletion to daughter nodes
  • default implementation calls CQuery::Clear(true) [i.e. ClearNode() and ClearOptions()]

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ CheckSatisfiable()

bool CQuery::CheckSatisfiable ( CQueryCompiler compiler)
virtual

Run fast (un)satisfiability checks for query before Compile() is called.

  • called via CQueryCompiler::CheckSatisfiable()
  • default implementation just wraps m_Options->CheckSatisfiable(compiler)
    Returns
    false if this query is trivially unsatisfiable for compiler

Reimplemented in CQCount.

References CQueryOptions::CheckSatisfiable(), and m_Options.

Referenced by CQueryCompiler::CheckSatisfiable(), and CQCount::CheckSatisfiable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Compile()

bool CQuery::Compile ( CQueryCompiler compiler)
virtual

◆ CompileOptions()

bool CQuery::CompileOptions ( CQueryCompiler compiler = NULL)
virtual

Compile index-dependent options in m_Options. Optional.

  • compiler defaults to this->m_Compiler

References CQueryOptions::Compile(), m_Compiler, and m_Options.

Referenced by CQueryCompiler::Compile(), and CQueryCompiler::CompileFilters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Evaluate()

void CQuery::Evaluate ( )
virtual

Wrapper for m_Node->Evaluate()

Reimplemented in CQKeys, and CQCount.

References CQueryNode::Evaluate(), CQueryOptions::m_bSeparateHits, m_Node, and m_Options.

Referenced by CQueryCompiler::Evaluate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Negated()

virtual bool CQuery::Negated ( )
inlinevirtual

For sanity checks. Default just returns false.

Reimplemented in CQNegatable.

References GetMatchId(), HasMatchId(), Negate(), and SetMatchId().

Referenced by Negate(), and RootOK().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Negate()

bool CQuery::Negate ( void  )
virtual

Toggle negation flag, returns new value. Default throws an exception.

Reimplemented in CQNegatable.

References errParseError, Negated(), and toString().

Referenced by Negated(), and CQNegatable::~CQNegatable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMatchId()

BYTE CQuery::GetMatchId ( ) const
virtual

Get current match-id (should return a nontrivial match-id if any was used, else 0; default just returns 0)

Reimplemented in CQSeq, CQNear, CQKeys, CQToken, CQCount, CQWith, CQCountKeyExprList, CQCountKeyExprToken, and CQBinOp.

Referenced by CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), HasMatchId(), Negated(), CQToken::~CQToken(), and CQWith::~CQWith().

Here is the caller graph for this function:

◆ SetMatchId()

BYTE CQuery::SetMatchId ( BYTE  matchId)
virtual

Set match-id, returns new value. Default throws an exception.

Reimplemented in CQSeq, CQNear, CQKeys, CQToken, CQWith, CQCountKeyExprToken, and CQBinOp.

References errParseError, and toString().

Referenced by CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), Negated(), CQToken::~CQToken(), and CQWith::~CQWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasMatchId()

bool CQuery::HasMatchId ( ) const
virtual

Returns true iff this query uses a nontrival match-id operator; default checks (this->GetMatchId() != 0)

References GetMatchId().

Referenced by Negated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RootOK()

virtual bool CQuery::RootOK ( )
inlinevirtual

Is this query an admissible root of a compiled parse tree (default returns !this->Negated())

Reimplemented in CQOr, and CQAnd.

References Children(), DisownChildren(), m_Label, Negated(), optionsToJson(), optionsToString(), and toString().

Referenced by CQueryCompiler::Compile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Children()

ddcObjectList CQuery::Children ( ) const
virtual

get a list of direct non-NULL CQuery direct daughters of this node

  • default just returns an empty list

Reimplemented from ddcObject.

Reimplemented in CQSeq, CQNear, CQKeys, CQCount, CQCountKeyExprList, CQBinOp, and CQCountKeyExprRegex.

References m_Options.

Referenced by CQCountKeyExprRegex::Children(), CQBinOp::Children(), CQCountKeyExprList::Children(), CQCount::Children(), CQKeys::Children(), CQNear::Children(), CQSeq::Children(), CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), and RootOK().

Here is the caller graph for this function:

◆ DisownChildren()

void CQuery::DisownChildren ( )
virtual

"disown" any direct child nodes, preventing their destruction if the current object is deleted

  • default implementation does nothing

Reimplemented from ddcObject.

Reimplemented in CQSeq, CQNear, CQKeys, CQCount, CQCountKeyExprList, CQBinOp, and CQCountKeyExprRegex.

References m_Options.

Referenced by CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), CQCountKeyExprRegex::DisownChildren(), CQBinOp::DisownChildren(), CQCountKeyExprList::DisownChildren(), CQCount::DisownChildren(), CQKeys::DisownChildren(), CQNear::DisownChildren(), CQSeq::DisownChildren(), and RootOK().

Here is the caller graph for this function:

◆ toString()

virtual string CQuery::toString ( void  )
inlinevirtual

◆ optionsToString()

string CQuery::optionsToString ( )
virtual

DEBUG: return canonical option string

References m_Options, and CQueryOptions::toString().

Referenced by CConcSession::GetHits(), CQueryCompiler::QueryToString(), and RootOK().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ optionsToJson()

string CQuery::optionsToJson ( )
virtual

return json format option string

References m_Options, and ddcObject::toJson().

Referenced by CQueryCompiler::QueryToJson(), and RootOK().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toJson()

virtual string CQuery::toJson ( )
inlinevirtual

return a JSON representation of this query

  • default just returns this->toString()
  • JSON query structures relflect C++ class structures with an additional "class" key

Reimplemented from ddcObject.

References jsonClass(), jsonData(), and jsonStr().

Referenced by CQFPrune::jsonData(), and CQueryCompiler::QueryToJson().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jsonClass()

virtual string CQuery::jsonClass ( void  )
inlinevirtual

◆ jsonData()

virtual string CQuery::jsonData ( void  )
inlinevirtual

instance data for json stringification

  • default implementation returns "NODATA":1, for strict syntax compliance

Reimplemented from ddcObject.

Reimplemented in CQSeq, CQNear, CQTokInfl, CQKeys, CQToken, CQCount, CQWith, CQCountKeyExprList, CQCountKeyExprToken, CQBinOp, CQCountKeyExprRegex, CQNegatable, CQCountKeyExprDateSlice, and CQCountKeyExpr.

References Clear(), ClearNode(), ClearOptions(), SetCompiler(), and SetOptions().

Referenced by CQBinOp::jsonClass(), CQWith::jsonClass(), CQToken::jsonClass(), CQNear::jsonClass(), CQSeq::jsonClass(), CQTokInfl::jsonValue(), and toJson().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCompiler()

void CQuery::SetCompiler ( CQueryCompiler compiler)

References ClearNode(), and m_Compiler.

Referenced by CQBinOp::Compile(), CQToken::Compile(), CQNear::Compile(), CQSeq::Compile(), and jsonData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearNode()

void CQuery::ClearNode ( )
virtual

deletes m_Node if non-NULL

Reimplemented in CQSeq, CQNear, CQKeys, CQCount, and CQBinOp.

References m_Node.

Referenced by Clear(), CQBinOp::Clear(), CQNear::Clear(), CQSeq::Clear(), CQBinOp::ClearNode(), CQCount::ClearNode(), CQKeys::ClearNode(), CQNear::ClearNode(), CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), jsonData(), and SetCompiler().

Here is the caller graph for this function:

◆ ClearOptions()

void CQuery::ClearOptions ( )
virtual

deletes m_Options if non-NULL

References m_Options.

Referenced by Clear(), CQBinOp::Clear(), CQNear::Clear(), CQSeq::Clear(), and jsonData().

Here is the caller graph for this function:

◆ Clear()

void CQuery::Clear ( bool  deep = true)
virtual

clear query contents. if deep is true, propagates operation to daughters

Reimplemented in CQSeq, CQNear, CQKeys, CQCount, and CQBinOp.

References ClearNode(), and ClearOptions().

Referenced by CQBinOp::CQBinOp(), CQNear::CQNear(), CQSeq::CQSeq(), jsonData(), CQBinOp::~CQBinOp(), CQNear::~CQNear(), CQSeq::~CQSeq(), and ~CQuery().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOptions()

void CQuery::SetOptions ( CQueryOptions opts)
virtual

set global query options ; deletes any pre-existing m_Options

References m_Options.

Referenced by jsonData(), and CQueryCompiler::SetQuery().

Here is the caller graph for this function:

Member Data Documentation

◆ m_Label

string CQuery::m_Label

arbitrary name for this query node (e.g. string from which it was parsed)

Referenced by RootOK().

◆ m_Compiler

CQueryCompiler* CQuery::m_Compiler

◆ m_Node

CQueryNode* CQuery::m_Node

◆ m_Options

CQueryOptions* CQuery::m_Options

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