OpenProjectCreator/ConditionEvaluator.cpp
//longest condition is the one that gets picked. This is to solve issues with stuff like != and !
longest condition is the one that gets picked. This is to solve issues with stuff like != and !
longest condition is the one that gets picked . This is to solve issues with stuff like ! = and !
ConditionOperator SearchForOperator(const char* str, size_t length, ErrorCode& error)
{
	operator_t* longestOp = nullptr;
	int longestIndex = -1;
	for (int i = 0; i < (int)ConditionOperator::OPERATOR_COUNT; i++)
	{
		if (!g_operators->key)
		{
			error = ErrorCode::NOT_IMPLEMENTED;
			return ConditionOperator::NONE;
		}
		operator_t* op = &g_operators[i];
		if (op->keyLength > length)
			continue;
		if (strncmp(str, op->key, op->keyLength) == 0)
		{
			if (longestOp == nullptr || longestOp->keyLength <= op->keyLength)
			{
				longestOp = op;
				longestIndex = i;
			}
		}
	}
	if(longestOp == nullptr)
		error = ErrorCode::OPERATOR_NOT_FOUND;
	return (ConditionOperator)longestIndex;
}
ConditionOperator SearchForOperator ( const char * str , size_t length , ErrorCode & error ) { operator_t * longestOp = nullptr ; int longestIndex = -1 ; for ( int i = 0 ; i < ( int ) ConditionOperator :: OPERATOR_COUNT ; i ++ ) { if ( ! g_operators -> key ) { error = ErrorCode :: NOT_IMPLEMENTED ; return ConditionOperator :: NONE ; } operator_t * op = & g_operators [ i ] ; if ( op -> keyLength > length ) continue ; if ( strncmp ( str , op -> key , op -> keyLength ) == 0 ) { if ( longestOp == nullptr || longestOp -> keyLength <= op -> keyLength ) { longestOp = op ; longestIndex = i ; } } } if ( longestOp == nullptr ) error = ErrorCode :: OPERATOR_NOT_FOUND ; return ( ConditionOperator ) longestIndex ; }
longest condition is the one that gets picked.
longest condition is the one that gets picked .
//if we hit the 0, we have more enums than structs in this array...