39 #define _TRACE(arg) ((void)0)
59 return (!a1 && a2) || (a1 && !a2);
167 TArgVector::const_iterator iter = m_argNodes.begin();
168 while(iter != m_argNodes.end()) {
184 if (it->GetDataType() !=
type)
196 if (it->GetDataType() != type1 && it->GetDataType() != type2) {
231 "Wrong number or type of argument", &node);
326 it->SetDouble(
double(it->GetInt()));
368 for (index = 1; index < arg_num; ++index) {
375 for (index = 1; index < arg_num; ++index) {
458 "Node type is not supported: " + node.
GetValue().GetNodeTypeAsString(), &node);
470 for (
int i = lo;
i < hi;
i++)
561 switch (node.
GetValue().GetType()) {
571 for (; iter != node.
SubNodeEnd() && res; ++iter) {
591 for (; iter != node.
SubNodeEnd() && !res; ++iter) {
620 TBase::Evaluate(*
m_QTree, node);
627 if (pTopUserNodeValue) {
643 if (query_parsenode) {
645 if (query_userobject) {
668 tr->ResetUserObject();
685 switch(node->GetType()) {
699 const string& strOrig = node.
GetValue().GetOriginalText();
701 if (
str == strOrig) {
710 bool is_int =
false, is_float =
false;
713 if (errno != 0 && !data_int) {
725 if (!is_int && !is_float) {
731 "Unknown identifier: '" +
str +
"'", &node);
735 }
else if ((strOrig.length() -
str.length() > 1) &&
736 (strOrig[0] ==
'"') &&
737 (strOrig[strOrig.length()-1] ==
'"')) {
739 string root, subfield;
744 "Unknown identifier: '" +
str +
"'", &node);
752 "Invalid string: '" + node->GetOriginalText() +
"'", &node);
758 const string& strOrig = node.
GetValue().GetOriginalText();
761 "Unknown identifier: '" + strOrig +
"'", &node);
767 "Incorrect node type: " + node.
GetValue().GetNodeTypeAsString(), &node);
806 _TRACE(
"number of arguments: " << arg_size);
807 _TRACE(
"For filtering to work, it must be 3");
814 _TRACE(
"Proceeding to filtering");
817 _TRACE(
"Going through # objects: " << objs.size());
819 for (
auto objs_iter = objs.begin(); objs_iter != objs.end(); ++objs_iter) {
833 const string tmp_obj_name = arg_node->
GetValue().GetOrig();
Query execution function for assignment operator.
Class implements functions calls in the do section of macro.
class CMQueryFunctionOps_Between
class CMQueryFunctionOps_BooleanNot
class CMQueryFunctionOps_Comparison
class CMQueryFunctionOps_In
class CMQueryFunctionOps_Like
Query execution function for run-time variables.
Query execution function for simple atomic values.
This class applies an operation to each node of the query tree to do necessary initialization (constr...
Subclass of the IQueryParseUserObject which is held as the user-defined object in each CQueryParseNod...
class CMacroExecException
Subclass of CQueryExec that adds: 1) Macro identifiers resolution 2) Where clause evaluation.
Query tree and associated utility methods.
definition of a Culling tree
Base class for query node user defined object.
Interface class for resolving entities during function execution.
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * str(char *buf, int n)
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
bool x_Validate(Uint4 number, CMQueryNodeValue::EType type1, CMQueryNodeValue::EType type2)
Checks the number of arguments, also their type should be one of the given types.
void SetString(const string &data)
Set/get underlying data type.
ETreeTraverseCode operator()(CTreeNode< CQueryParseNode > &tr, int delta)
Operator builds node values for each CQueryParseNode.
void ThrowCMacroExecException(const CDiagCompileInfo &info, CMacroExecException::EErrCode code, const string &message, const CQueryParseTree::TNode *treeNode, const CException *previous=nullptr)
Throws CMacroExecException with the specified message and error location from the TNode.
virtual void Evaluate(CQueryParseTree::TNode &node)
Function throws an exception about not implmented operation for the node.
bool m_Boolean
Type of result is boolean.
IResolver * m_Resolver
Variables resolver.
void EvaluateTree(CQueryParseTree &Qtree, IResolver &resolver, bool query_tree, bool case_sensitive=false)
Evaluates tree.
virtual CQueryParseTree * GetAssignmentWhereClause(int index) const =0
virtual void AddTmpRTVarObject(const string &name, CObjectInfo &oi)=0
list< SResolvedField > TObs
string m_String
Data String data, if data came from a string or data field in the tree.
void SetDouble(double data)
void AssignFromObjectInfo(const CObjectInfo &objinfo)
Assigns data from objinfo. It is used when storing evaluation result.
virtual CRef< CMQueryNodeValue > GetOrCreateRTVar(const string &name)=0
void Dereference()
If it is a reference it is resolved to the first non reference type in the hierarchy.
const TObs & GetObjects() const
bool m_CaseSensitive
Case sensitive flag for string comparisons.
virtual void Evaluate(CQueryParseTree::TNode &node)
Calculates node values for constants and resolved identifiers.
void SetDataType(EType dt)
bool m_Result
Boolean result of calculation.
bool IsCaseSensitive() const
Get function to access case sensitivity flag.
void x_InitReferences(CQueryParseTree::TNode &node)
Ininializes protected members to be used in derived classes.
CRef< CMQueryNodeValue > x_GetTopUserNodeValue()
EType GetDataType() const
virtual void Evaluate(CQueryParseTree::TNode &node)
Function implements functions calls in the do section of macro.
bool PassIdentifierToResolver(const string &identifier, CMQueryNodeValue &NodeValue, const CQueryParseTree::TNode *parent)
Identifier resolver function.
CRef< CMQueryNodeValue > x_GetUserObject(CQueryParseTree::TNode &node)
Gets user node value from CQueryParseTree node.
IResolver * GetResolver() const
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
EType m_DataType
Node value data type.
CRef< CMQueryNodeValue > m_Ref
Reference to similar object.
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
bool AssignToRef(const CMQueryNodeValue &source)
bool x_FindNotSet()
Find not set value.
void SetRef(CRef< CMQueryNodeValue > node)
bool IsNotSetType() const
Check/get functions result from the top node after calculation.
static bool BinOpsFunc(CQueryParseNode::EType op, const T &a1, const T &a2)
void x_ProcessInvalidParams(CQueryParseTree::TNode &node)
Throws exception for invalid number of types of arguments.
Int8 m_Int
For data that is an integer or converted into one.
bool m_Bool
For data that is a boolean or converted into one.
bool x_EvaluateQueryTree(CQueryParseTree::TNode &node)
virtual void ResetTmpRTVarObjects()=0
void x_Init()
class CMacroExec implementation
virtual void Evaluate(CQueryParseTree::TNode &node)
Function is a placeholder for run-time variable processing.
CRef< CMQueryNodeValue > m_Result
Node for result storage.
CMacroExec * GetContext()
class CMQueryFunctionBase
TUserArgs m_Arguments
Vector of argument node values.
bool x_ValidateAll(Uint4 number, CMQueryNodeValue::EType type)
Checks the number and type of arguments.
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
bool x_ConvertIntArgsToDouble()
Converts the integer arguments to double in order to perform comparisons.
void SetObjects(const TObs &obs)
bool GetBoolValue() const
double m_Double
For data that is a double or converted into one.
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
bool x_IsCaseSensitive()
Gets case sensitiveness flag from environment.
CRef< CMQueryNodeValue > GetOrCreateRTVar(const string &name)
bool m_NotSet
Type of result is not set.
virtual void Evaluate(CQueryParseTree::TNode &node)
Function implements the assignment operator.
virtual bool ResolveIdentifier(const string &identifier, CMQueryNodeValue &vi, const CQueryParseTree::TNode *parent)=0
virtual void CallFunction(const string &name, CQueryParseTree::TNode &qnode)=0
virtual void Evaluate(CQueryParseTree::TNode &node)
Abstract node evaluation function.
static bool BinOpsFuncString(CQueryParseNode::EType op, const string &s1, const string &s2, bool case_sensitive)
@ ePrimitiveValueString
string|char*|const char*
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
@ ePrimitiveValueChar
char
@ ePrimitiveValueBool
bool
@ ePrimitiveValueEnum
enum
@ ePrimitiveValueReal
float|double
bool GetPrimitiveValueBool(void) const
Get boolean data.
int GetPrimitiveValueInt(void) const
Get data as int.
ETypeFamily GetTypeFamily(void) const
Get data type family.
void GetPrimitiveValueString(string &value) const
Get string data.
double GetPrimitiveValueDouble(void) const
Get data as double.
Int4 GetPrimitiveValueInt4(void) const
Get data as Int4.
EPrimitiveValueType GetPrimitiveValueType(void) const
Get type of primitive value.
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
CQueryParseTree * m_QTree
string GetNodeTypeAsString() const
Return query node type as a string (for debugging output)
vector< CQueryParseTree::TNode * > TArgVector
Vector for easy argument access.
const TNode * GetQueryTree() const
void AddFunc(CQueryParseNode::EType func_type, CQueryFunctionBase *func)
Register function implementation.
void MakeArgVector(CQueryParseTree::TNode &qnode, TArgVector &args)
Created vector of arguments (translate sub-nodes to vector)
@ eNotSet
Produced by the (private) default constructor.
@ eIdentifier
Identifier like db.field (Org, Fld12, etc.)
@ eFloatConst
Floating point const.
@ eIntConst
Integer const.
@ eBoolConst
Boolean (TRUE or FALSE)
@ eString
String ("free text")
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static bool StringToBool(const CTempString str)
Convert string to bool.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static bool MatchesMask(CTempString str, CTempString mask, ECase use_case=eCase)
Match "str" against the "mask".
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static int CompareCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive compare of a substring with another string.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
TNodeList::iterator TNodeList_I
Fun TreeDepthFirstTraverse(TTreeNode &tree_node, Fun func)
Depth-first tree traversal algorithm.
ETreeTraverseCode
Tree traverse code returned by the traverse predicate function.
TNodeList_CI SubNodeBegin(void) const
Return first const iterator on subnode list.
bool IsLeaf() const
Report whether this is a leaf node.
TNodeList_CI SubNodeEnd(void) const
Return last const iterator on subnode list.
const TValue & GetValue(void) const
Return node's value.
const TTreeType * GetParent(void) const
Get node's parent.
@ eTreeTraverse
Keep traversal.
const CharType(& source)[N]
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Int4 delta(size_t dimension_, const Int4 *score_)
static CS_CONTEXT * context