NCBI C++ ToolKit
Classes | Typedefs | Enumerations | Enumerator | Functions | Variables
BDB library queries
+ Collaboration diagram for BDB library queries:

Classes

class  CBDB_QueryNode
 Query node class. More...
 
class  CBDB_Query
 Query class incapsulates query tree (query clause) and implements set of utility methods to construct query trees. More...
 
class  CBDB_FileScanner
 Scans the BDB file, searches the matching records. More...
 

Typedefs

typedef CTreeNode< CBDB_QueryNodeCBDB_Query::TQueryClause
 

Enumerations

enum  CBDB_QueryNode::ENodeType {
  CBDB_QueryNode::eLogical , CBDB_QueryNode::eOperator , CBDB_QueryNode::eFunction , CBDB_QueryNode::eValue ,
  CBDB_QueryNode::eDBField
}
 
enum  CBDB_QueryNode::ELogicalType { CBDB_QueryNode::eAnd , CBDB_QueryNode::eOr , CBDB_QueryNode::eNot }
 Subtype of ENodeType - eLogical. More...
 
enum  CBDB_QueryNode::EOperatorType {
  CBDB_QueryNode::eEQ , CBDB_QueryNode::eGT , CBDB_QueryNode::eGE , CBDB_QueryNode::eLT ,
  CBDB_QueryNode::eLE
}
 Subtype of ENodeType - eOperator. More...
 
enum  CBDB_FileScanner::EScanAction { CBDB_FileScanner::eContinue , CBDB_FileScanner::eStop }
 Scanner control codes. More...
 

Functions

 CBDB_QueryNode::CBDB_QueryNode (string value=kEmptyStr)
 Constuction of value type node. More...
 
 CBDB_QueryNode::CBDB_QueryNode (ELogicalType ltype)
 Construction of logical (AND, OR, etc) node. More...
 
 CBDB_QueryNode::CBDB_QueryNode (EOperatorType otype, bool not_flag=false)
 Construction of operator node. More...
 
 CBDB_QueryNode::CBDB_QueryNode (const CBDB_QueryNode &qnode)
 
CBDB_QueryNodeCBDB_QueryNode::operator= (const CBDB_QueryNode &qnode)
 
 CBDB_QueryNode::~CBDB_QueryNode ()
 
ENodeType CBDB_QueryNode::GetType () const
 
ELogicalType CBDB_QueryNode::GetLogicType () const
 
EOperatorType CBDB_QueryNode::GetOperatorType () const
 
bool CBDB_QueryNode::IsNot () const
 
void CBDB_QueryNode::SetNot ()
 Set NOT flag (NOT EQ, etc) More...
 
const stringCBDB_QueryNode::GetValue () const
 
stringCBDB_QueryNode::GetValue ()
 
void CBDB_QueryNode::SetValue (const string &value)
 
bool CBDB_QueryNode::HasValue () const
 
void CBDB_QueryNode::SetField (int field_idx)
 Set node type to eDBField. More...
 
int CBDB_QueryNode::GetFiledIdx () const
 
void CBDB_QueryNode::SetAltValue (const string &v)
 Set alternative value. More...
 
const stringCBDB_QueryNode::GetAltValue () const
 Get alternative value. More...
 
 CBDB_Query::CBDB_Query (TQueryClause *qc=0)
 Contruct the query. More...
 
 CBDB_Query::~CBDB_Query ()
 
TQueryClauseCBDB_Query::GetQueryClause ()
 
const TQueryClauseCBDB_Query::GetQueryClause () const
 
void CBDB_Query::SetQueryClause (TQueryClause *query_clause)
 Replace current query clause with the new one. More...
 
void CBDB_Query::ResetQueryClause ()
 
static TQueryClauseCBDB_Query::NewOperatorNode (CBDB_QueryNode::EOperatorType otype, const string &arg1, const string &arg2)
 Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree). More...
 
static TQueryClauseCBDB_Query::NewLogicalNode (CBDB_QueryNode::ELogicalType otype, TQueryClause *arg1, TQueryClause *arg2)
 Creates new logical node of the query. More...
 
static TQueryClauseCBDB_Query::NewOperatorNode (CBDB_QueryNode::EOperatorType ltype, TQueryClause *arg1, TQueryClause *arg2)
 Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree). More...
 
 CBDB_Query::CBDB_Query (const CBDB_Query &query)
 
CBDB_QueryCBDB_Query::operator= (const CBDB_Query &query)
 
 CBDB_FileScanner::CBDB_FileScanner (CBDB_File &db_file)
 
virtual CBDB_FileScanner::~CBDB_FileScanner ()
 
void CBDB_FileScanner::Scan (CBDB_Query &query)
 Scan the BDB file, search the qualified records When record found function calls OnRecordFound. More...
 
void CBDB_FileScanner::Scan (CBDB_FileCursor &cur, CBDB_Query &query)
 Scan the BDB file cursor, search the qualified records When record found function calls OnRecordFound. More...
 
bool CBDB_FileScanner::StaticEvaluate (CBDB_Query &query)
 Static query evaluation without changing current position in the database file. More...
 
virtual EScanAction CBDB_FileScanner::OnRecordFound ()
 Called when scanner finds a record matching the query terms Function returns a control code (EScanAction) to confirm or interrupt scanning process. More...
 
bool CBDB_FileScanner::Evaluate (CBDB_Query &query)
 Returns TRUE if file record matches the query. More...
 
void CBDB_FileScanner::ResolveFields (CBDB_Query &query)
 
 CBDB_FileScanner::CBDB_FileScanner (const CBDB_FileScanner &)
 
CBDB_FileScannerCBDB_FileScanner::operator= (const CBDB_FileScanner &)
 
void BDB_PrintQueryTree (CNcbiOstream &os, const CBDB_Query &query)
 Function prints the query tree on the specified ostream (Intended more for debugging purposes) More...
 
void BDB_ParseQuery (const char *query_str, CBDB_Query *query)
 Parse query string, build the correct the query statement. More...
 

Variables

ENodeType CBDB_QueryNode::m_NodeType
 
ELogicalType   CBDB_QueryNode::LogicalType
 
EOperatorType   CBDB_QueryNode::OperatorType
 
int   CBDB_QueryNode::FieldIdx
 
union {
   ELogicalType   CBDB_QueryNode::LogicalType
 
   EOperatorType   CBDB_QueryNode::OperatorType
 
   int   CBDB_QueryNode::FieldIdx
 
CBDB_QueryNode::m_SubType
 
bool CBDB_QueryNode::m_NotFlag
 Inverted function. More...
 
string CBDB_QueryNode::m_Value
 
string CBDB_QueryNode::m_AltValue
 Alternative value. More...
 
TQueryClauseCBDB_Query::m_QueryClause
 
CBDB_FileCBDB_FileScanner::m_File
 Searched BDB file. More...
 

Detailed Description

Typedef Documentation

◆ TQueryClause

Definition at line 141 of file bdb_query.hpp.

Enumeration Type Documentation

◆ ELogicalType

Subtype of ENodeType - eLogical.

Enumerator
eAnd 
eOr 
eNot 

Definition at line 63 of file bdb_query.hpp.

◆ ENodeType

Enumerator
eLogical 
eOperator 
eFunction 
eValue 
eDBField 

Definition at line 53 of file bdb_query.hpp.

◆ EOperatorType

Subtype of ENodeType - eOperator.

Enumerator
eEQ 
eGT 
eGE 
eLT 
eLE 

Definition at line 71 of file bdb_query.hpp.

◆ EScanAction

Scanner control codes.

Enumerator
eContinue 

Keep scanning.

eStop 

Stop search process.

Definition at line 212 of file bdb_query.hpp.

Function Documentation

◆ BDB_ParseQuery()

void BDB_ParseQuery ( const char *  query_str,
CBDB_Query query 
)

Parse query string, build the correct the query statement.

Parameters
query_str- source query string
query- query object owns the statement (query clause tree) after successful parsing.

Definition at line 187 of file bdb_query_parser_main.cpp.

References env, CResourcePool_Base< Value, Lock, CF >::ForgetAll(), CResourcePool_Base< Value, Lock, CF >::GetFreeList(), query, and yyparse.

Referenced by CBDB_FileDumper::SetQuery().

◆ BDB_PrintQueryTree()

void BDB_PrintQueryTree ( CNcbiOstream os,
const CBDB_Query query 
)

Function prints the query tree on the specified ostream (Intended more for debugging purposes)

Definition at line 1112 of file bdb_query.cpp.

References query, and TreeDepthFirstTraverse().

◆ CBDB_FileScanner() [1/2]

CBDB_FileScanner::CBDB_FileScanner ( CBDB_File db_file)

Definition at line 765 of file bdb_query.cpp.

◆ CBDB_FileScanner() [2/2]

CBDB_FileScanner::CBDB_FileScanner ( const CBDB_FileScanner )
private

◆ CBDB_Query() [1/2]

CBDB_Query::CBDB_Query ( const CBDB_Query query)
private

◆ CBDB_Query() [2/2]

CBDB_Query::CBDB_Query ( TQueryClause qc = 0)

Contruct the query.

If QueryClause is NOT NULL takes the ownership.

Parameters
qcQuery clause. (Should be created by new)

Definition at line 121 of file bdb_query.cpp.

References CBDB_Query::m_QueryClause.

◆ CBDB_QueryNode() [1/4]

CBDB_QueryNode::CBDB_QueryNode ( const CBDB_QueryNode qnode)

◆ CBDB_QueryNode() [2/4]

CBDB_QueryNode::CBDB_QueryNode ( ELogicalType  ltype)

Construction of logical (AND, OR, etc) node.

Definition at line 53 of file bdb_query.cpp.

References CBDB_QueryNode::m_SubType.

◆ CBDB_QueryNode() [3/4]

CBDB_QueryNode::CBDB_QueryNode ( EOperatorType  otype,
bool  not_flag = false 
)

Construction of operator node.

Definition at line 60 of file bdb_query.cpp.

References CBDB_QueryNode::m_SubType.

◆ CBDB_QueryNode() [4/4]

CBDB_QueryNode::CBDB_QueryNode ( string  value = kEmptyStr)

Constuction of value type node.

Definition at line 47 of file bdb_query.cpp.

◆ Evaluate()

bool CBDB_FileScanner::Evaluate ( CBDB_Query query)
protected

◆ GetAltValue()

const string& CBDB_QueryNode::GetAltValue ( ) const
inline

Get alternative value.

Definition at line 120 of file bdb_query.hpp.

References CBDB_QueryNode::m_AltValue.

Referenced by CBDB_FileScanner::Evaluate().

◆ GetFiledIdx()

int CBDB_QueryNode::GetFiledIdx ( ) const
inline

Definition at line 114 of file bdb_query.hpp.

References CBDB_QueryNode::m_SubType.

Referenced by CScannerFunctorArgN::GetArguments().

◆ GetLogicType()

CBDB_QueryNode::ELogicalType CBDB_QueryNode::GetLogicType ( ) const

◆ GetOperatorType()

CBDB_QueryNode::EOperatorType CBDB_QueryNode::GetOperatorType ( ) const

◆ GetQueryClause() [1/2]

TQueryClause& CBDB_Query::GetQueryClause ( )
inline

Definition at line 149 of file bdb_query.hpp.

References CBDB_Query::m_QueryClause.

◆ GetQueryClause() [2/2]

const TQueryClause& CBDB_Query::GetQueryClause ( ) const
inline

Definition at line 150 of file bdb_query.hpp.

References CBDB_Query::m_QueryClause.

◆ GetType()

ENodeType CBDB_QueryNode::GetType ( void  ) const
inline

◆ GetValue() [1/2]

string& CBDB_QueryNode::GetValue ( void  )
inline

Definition at line 104 of file bdb_query.hpp.

References CBDB_QueryNode::m_Value.

◆ GetValue() [2/2]

const string& CBDB_QueryNode::GetValue ( void  ) const
inline

◆ HasValue()

bool CBDB_QueryNode::HasValue ( void  ) const
inline

◆ IsNot()

bool CBDB_QueryNode::IsNot ( ) const
inline
Returns
TRUE when node is an inverted operator (not EQ)

Definition at line 99 of file bdb_query.hpp.

References CBDB_QueryNode::m_NotFlag.

Referenced by CQueryTreePrintFunc::operator()(), and CScannerEvaluateFunc::operator()().

◆ NewLogicalNode()

CBDB_Query::TQueryClause * CBDB_Query::NewLogicalNode ( CBDB_QueryNode::ELogicalType  otype,
TQueryClause arg1,
TQueryClause arg2 
)
static

Creates new logical node of the query.

See also
NewOperatorNode

Definition at line 191 of file bdb_query.cpp.

Referenced by yyparse().

◆ NewOperatorNode() [1/2]

CBDB_Query::TQueryClause * CBDB_Query::NewOperatorNode ( CBDB_QueryNode::EOperatorType  ltype,
TQueryClause arg1,
TQueryClause arg2 
)
static

Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree).

Function receives two argument nodes which are attached to the result clause. In terms of memory management caller does not need to deallocate them.

Parameters
otype- type of the operator to create
arg1- argument node.
arg2- argument node.

Definition at line 177 of file bdb_query.cpp.

◆ NewOperatorNode() [2/2]

CBDB_Query::TQueryClause * CBDB_Query::NewOperatorNode ( CBDB_QueryNode::EOperatorType  otype,
const string arg1,
const string arg2 
)
static

Creates new operator node of the query Caller is responsible for destruction (in most cases the result is immediately added to the query tree).

Definition at line 164 of file bdb_query.cpp.

Referenced by yyparse().

◆ OnRecordFound()

CBDB_FileScanner::EScanAction CBDB_FileScanner::OnRecordFound ( )
virtual

Called when scanner finds a record matching the query terms Function returns a control code (EScanAction) to confirm or interrupt scanning process.

Reimplemented in CBDB_DumpScanner.

Definition at line 776 of file bdb_query.cpp.

References CBDB_FileScanner::eContinue.

Referenced by CBDB_FileScanner::Scan().

◆ operator=() [1/3]

CBDB_FileScanner& CBDB_FileScanner::operator= ( const CBDB_FileScanner )
private

◆ operator=() [2/3]

CBDB_Query& CBDB_Query::operator= ( const CBDB_Query query)
private

◆ operator=() [3/3]

CBDB_QueryNode & CBDB_QueryNode::operator= ( const CBDB_QueryNode qnode)

◆ ResetQueryClause()

void CBDB_Query::ResetQueryClause ( )

◆ ResolveFields()

void CBDB_FileScanner::ResolveFields ( CBDB_Query query)
protected

◆ Scan() [1/2]

void CBDB_FileScanner::Scan ( CBDB_FileCursor cur,
CBDB_Query query 
)

Scan the BDB file cursor, search the qualified records When record found function calls OnRecordFound.

See also
OnRecordFound

Definition at line 801 of file bdb_query.cpp.

References eBDB_Ok, CBDB_FileScanner::eStop, CBDB_FileScanner::Evaluate(), CBDB_FileCursor::Fetch(), CBDB_FileScanner::OnRecordFound(), query, and CBDB_FileScanner::ResolveFields().

◆ Scan() [2/2]

void CBDB_FileScanner::Scan ( CBDB_Query query)

◆ SetAltValue()

void CBDB_QueryNode::SetAltValue ( const string v)
inline

Set alternative value.

Definition at line 117 of file bdb_query.hpp.

References CBDB_QueryNode::m_AltValue.

Referenced by CScannerEvaluateFunc::operator()(), and s_ResetQueryNode().

◆ SetField()

void CBDB_QueryNode::SetField ( int  field_idx)

Set node type to eDBField.

Parameters
field_idxdatabase field index

Definition at line 111 of file bdb_query.cpp.

References CBDB_QueryNode::eDBField, CBDB_QueryNode::m_NodeType, and CBDB_QueryNode::m_SubType.

Referenced by CQueryTreeFieldResolveFunc::operator()().

◆ SetNot()

void CBDB_QueryNode::SetNot ( )
inline

Set NOT flag (NOT EQ, etc)

Definition at line 101 of file bdb_query.hpp.

References CBDB_QueryNode::m_NotFlag.

◆ SetQueryClause()

void CBDB_Query::SetQueryClause ( TQueryClause query_clause)

Replace current query clause with the new one.

CBDB_Query object takes ownership on the passed argument.

Definition at line 157 of file bdb_query.cpp.

References CBDB_Query::m_QueryClause.

◆ SetValue()

void CBDB_QueryNode::SetValue ( const string value)
inline

◆ StaticEvaluate()

bool CBDB_FileScanner::StaticEvaluate ( CBDB_Query query)
inline

Static query evaluation without changing current position in the database file.

Intended purpose: debugging

Definition at line 234 of file bdb_query.hpp.

References CBDB_FileScanner::Evaluate(), and query.

Referenced by CBDB_FileDumper::Dump().

◆ ~CBDB_FileScanner()

CBDB_FileScanner::~CBDB_FileScanner ( )
virtual

Definition at line 771 of file bdb_query.cpp.

◆ ~CBDB_Query()

CBDB_Query::~CBDB_Query ( )

Definition at line 130 of file bdb_query.cpp.

References CBDB_Query::m_QueryClause.

◆ ~CBDB_QueryNode()

CBDB_QueryNode::~CBDB_QueryNode ( )

Definition at line 88 of file bdb_query.cpp.

Variable Documentation

◆ FieldIdx [1/2]

int CBDB_QueryNode::FieldIdx

Definition at line 128 of file bdb_query.hpp.

◆  [2/2]

int { ... } ::FieldIdx

Definition at line 128 of file bdb_query.hpp.

◆  [1/2]

ELogicalType { ... } ::LogicalType

Definition at line 126 of file bdb_query.hpp.

◆ LogicalType [2/2]

ELogicalType CBDB_QueryNode::LogicalType

Definition at line 126 of file bdb_query.hpp.

Referenced by CBDB_QueryNode::CBDB_QueryNode(), and CBDB_QueryNode::operator=().

◆ m_AltValue

string CBDB_QueryNode::m_AltValue
protected

Alternative value.

Definition at line 132 of file bdb_query.hpp.

Referenced by CBDB_QueryNode::GetAltValue(), and CBDB_QueryNode::SetAltValue().

◆ m_File

CBDB_File& CBDB_FileScanner::m_File
protected

Searched BDB file.

Definition at line 254 of file bdb_query.hpp.

Referenced by CBDB_FileScanner::Evaluate(), CBDB_FileScanner::ResolveFields(), and CBDB_FileScanner::Scan().

◆ m_NodeType

ENodeType CBDB_QueryNode::m_NodeType
protected

◆ m_NotFlag

bool CBDB_QueryNode::m_NotFlag
protected

◆ m_QueryClause

TQueryClause* CBDB_Query::m_QueryClause

◆ 

union { ... } CBDB_QueryNode::m_SubType

◆ m_Value

string CBDB_QueryNode::m_Value
protected

◆ OperatorType [1/2]

EOperatorType CBDB_QueryNode::OperatorType

Definition at line 127 of file bdb_query.hpp.

◆  [2/2]

EOperatorType { ... } ::OperatorType

Definition at line 127 of file bdb_query.hpp.

Modified on Fri Sep 20 14:58:19 2024 by modify_doxy.py rev. 669887