当前位置: 首页>>代码示例>>C++>>正文


C++ ExpressionResult类代码示例

本文整理汇总了C++中ExpressionResult的典型用法代码示例。如果您正苦于以下问题:C++ ExpressionResult类的具体用法?C++ ExpressionResult怎么用?C++ ExpressionResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExpressionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BOOST_THROW_EXCEPTION

ExpressionResult ImportExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	if (frame.Sandboxed)
		BOOST_THROW_EXCEPTION(ScriptError("Imports are not allowed in sandbox mode.", m_DebugInfo));

	String type = VMOps::GetField(frame.Self, "type", frame.Sandboxed, m_DebugInfo);
	ExpressionResult nameres = m_Name->Evaluate(frame);
	CHECK_RESULT(nameres);
	Value name = nameres.GetValue();

	if (!name.IsString())
		BOOST_THROW_EXCEPTION(ScriptError("Template/object name must be a string", m_DebugInfo));

	ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(Type::GetByName(type), name);

	if (!item)
		BOOST_THROW_EXCEPTION(ScriptError("Import references unknown template: '" + name + "'", m_DebugInfo));

	Dictionary::Ptr scope = item->GetScope();

	if (scope)
		scope->CopyTo(frame.Locals);

	ExpressionResult result = item->GetExpression()->Evaluate(frame, dhint);
	CHECK_RESULT(result);

	return Empty;
}
开发者ID:wopfel,项目名称:icinga2,代码行数:28,代码来源:expression.cpp

示例2: loadPage

std::list<Index*> IndexPage::find(BufferManager* manager, FilterParser* parser) {
	if (!isLoaded()) {
		loadPage(manager);
	}
	std::list<Index*> result;
	for (int x = 0; x < size; x++) {
		BSONObj* key = elements[x]->key;
		if (key->getString("_id").compare("c597-43e1-ae9b-6f5451b28295") == 0) {
			cout << "Hey!" << endl;
		}
		bool match = false;
		ExpressionResult* expresult = parser->eval(*key);
		if (expresult->type() == ExpressionResult::RT_BOOLEAN) {
			match = *expresult;
		}
		delete expresult;
		if (match) {
			result.push_back(elements[x]);
		}
	}
	for (int x = 0; x <= size; x++) {
		IndexPage* innerPage = pointers[x];
		if (innerPage != NULL) {
			std::list<Index*> inner = innerPage->find(manager, parser);
			result.insert(result.begin(), inner.begin(), inner.end());
		}
	}
	return result;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:29,代码来源:bplusindexp.cpp

示例3: Dictionary

ExpressionResult DictExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	Value self;

	if (!m_Inline) {
		self = frame.Self;
		frame.Self = new Dictionary();
	}

	Value result;

	try {
		for (Expression *aexpr : m_Expressions) {
			ExpressionResult element = aexpr->Evaluate(frame, m_Inline ? dhint : NULL);
			CHECK_RESULT(element);
			result = element.GetValue();
		}
	} catch (...) {
		if (!m_Inline)
			std::swap(self, frame.Self);
		throw;
	}

	if (m_Inline)
		return result;
	else {
		std::swap(self, frame.Self);
		return self;
	}
}
开发者ID:wopfel,项目名称:icinga2,代码行数:30,代码来源:expression.cpp

示例4: DoEvaluate

ExpressionResult LogicalNegateExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	ExpressionResult operand = m_Operand->Evaluate(frame);
	CHECK_RESULT(operand);

	return !operand.GetValue().ToBool();
}
开发者ID:Nadahar,项目名称:icinga2,代码行数:7,代码来源:expression.cpp

示例5: DoEvaluate

ExpressionResult ThrowExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	ExpressionResult messageres = m_Message->Evaluate(frame);
	CHECK_RESULT(messageres);
	Value message = messageres.GetValue();
	BOOST_THROW_EXCEPTION(ScriptError(message, m_DebugInfo, m_IncompleteExpr));
}
开发者ID:wopfel,项目名称:icinga2,代码行数:7,代码来源:expression.cpp

示例6: throw

BSONObj* DBController::findFirst(const char* db, const char* ns, const char* select, const char* filter, const BSONObj* options) throw(ParseException) {
	if (_logger->isDebug()) _logger->debug(2, "DBController::findFirst db: %s, ns: %s, select: %s, filter: %s", db, ns, select, filter);
	std::string filedir = _dataDir + db;
	filedir = filedir + FILESEPARATOR;

	std::stringstream ss;
	ss << filedir << ns << ".dat";

	std::string filename = ss.str();

	// Execute open on streammanager, just to check that the file was alrady opened
	StreamManager::getStreamManager()->open(db, ns, DATA_FTYPE);

	MMapInputStream* mmis = new MMapInputStream(filename.c_str(), 0);
	DBFileInputStream* dbStream = new DBFileInputStream(mmis);
	BSONArrayObj result;

	BSONInputStream* bis = new BSONInputStream(mmis);

	FilterParser* parser = FilterParser::parse(filter);

	BSONBufferedObj* obj = NULL;
	BSONObj* bsonResult = NULL;
	mmis->seek(29);
	while (!mmis->eof()) {
		if (obj == NULL) {
			obj = new BSONBufferedObj(mmis->pointer(), mmis->length() - mmis->currentPos());
		} else {
			obj->reset(mmis->pointer(), mmis->length() - mmis->currentPos());
		}
		mmis->seek(mmis->currentPos() + obj->bufferLength());
		// Only "active" Records
		if (obj->getInt("_status") == 1) {
			ExpressionResult* result = parser->eval(*obj);
			if (result->type() == ExpressionResult::RT_BOOLEAN) {
				bool bres = *result;
				if (bres) {
					bsonResult = obj->select(select);
					break;
				}
			}
			delete result;
		}
		if (bsonResult) {
			break;
		}
	}

	if (obj != NULL) delete obj;
	dbStream->close();
	delete dbStream;

	mmis->close();
	delete mmis;
	delete parser;
	delete bis;
	return bsonResult;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:58,代码来源:dbcontroller.cpp

示例7: evalEqual

ExpressionResult* evalEqual(const BSONObj& bson, BaseExpression* left, BaseExpression* right) {
	ExpressionResult* valLeft = left->eval(bson);
	ExpressionResult* valRight= right->eval(bson);
	
	bool result = false;
	if (valLeft->type() != valRight->type()) {
		result = false;
	} else if (((valLeft->type() != ExpressionResult::RT_NULL) && (valRight->type() == ExpressionResult::RT_NULL)) ||
			((valLeft->type() == ExpressionResult::RT_NULL) && (valRight->type() != ExpressionResult::RT_NULL))) {
		result = false;
	} else {

		// the types are ensured to be equal
		switch (valLeft->type()) {
			case ExpressionResult::RT_INT:
				result = ((__int32)*valLeft == (__int32)*valRight);
				break;
			case ExpressionResult::RT_LONG:
			case ExpressionResult::RT_LONG64:
				result = ((__int64)*valLeft == (__int64)*valRight);
				break;
			case ExpressionResult::RT_DOUBLE:
				result = ((double)*valLeft == (double)*valRight);
				break;
			case ExpressionResult::RT_BOOLEAN:
				result = ((bool)*valLeft == (bool)*valRight);
				break;
			case ExpressionResult::RT_PTRCHAR:
				{
					result = ((djondb::string)*valLeft == (djondb::string)*valRight);
					break;
				}
				break;
			case ExpressionResult::RT_STRINGDB:
				{
					std::string leftS = *valLeft;
					std::string rightS = *valRight;
					result = (leftS.compare(rightS) == 0);
				}
				break;
			case ExpressionResult::RT_BSON: 
				{
					BSONObj* bleft = (BSONObj*)*valLeft;
					BSONObj* bright = (BSONObj*)*valRight;
					result = (*bleft == *bright);
					break;
				}
		}
	}

	delete valLeft;
	delete valRight;
	return new ExpressionResult(result);
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:54,代码来源:binaryexpression.cpp

示例8: not_expression

ExpressionResult* not_expression(BaseExpression* expression, const BSONObj& bson) {
	ExpressionResult* tmpresult = expression->eval(bson);
	ExpressionResult* result = NULL;
	if (tmpresult->type() == ExpressionResult::RT_BOOLEAN) {
		bool bres = *tmpresult;
		result = new ExpressionResult(!bres);	
	} else {
		throw ParseException(D_ERROR_PARSEERROR, "Exists signature is wrong. Use Exists($'field').");
	}
	delete tmpresult;
	return result;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:12,代码来源:unaryexpression.cpp

示例9: evalComparison

ExpressionResult* evalComparison(const BSONObj& bson, const FILTER_OPERATORS& oper, BaseExpression* left, BaseExpression* right) {
	ExpressionResult* valLeft = left->eval(bson);
	ExpressionResult* valRight= right->eval(bson);

	if (valLeft->type() != valRight->type()) {
		// ERROR types does not match
		delete valLeft;
		delete valRight;

		return new ExpressionResult(false);
	}

	bool resultGreather = false; // this will compare only greather than, and at the end will invert
	// based on the sign
	if ((valLeft->type() != ExpressionResult::RT_NULL) && (valRight->type() == ExpressionResult::RT_NULL)) {
		resultGreather = true;
	} else if (((valLeft->type() == ExpressionResult::RT_NULL) && (valRight->type() != ExpressionResult::RT_NULL))) {
		resultGreather = false;
	} else {
		switch (valLeft->type()) {
			case ExpressionResult::RT_INT:
				resultGreather = ((__int32)*valLeft > (__int32)*valRight);
				break;
			case ExpressionResult::RT_LONG:
			case ExpressionResult::RT_LONG64:
				resultGreather = ((__int64)*valLeft > (__int64)*valRight);
				break;
			case ExpressionResult::RT_DOUBLE:
				resultGreather = ((double)*valLeft > (double)*valRight);
				break;
		}
	}

	ExpressionResult* result = NULL;
	if ((!resultGreather  && (oper == FO_GREATEREQUALTHAN)) || 
			(resultGreather && (oper == FO_LESSEQUALTHAN))) {
		result = evalEqual(bson, left, right);
	} else {
		bool bres;
		if ((oper == FO_LESSTHAN) || (oper == FO_LESSEQUALTHAN)) {
			bres = !resultGreather;
		}else {
			bres = resultGreather;
		}
		result = new ExpressionResult(bres);
	}

	delete valLeft;
	delete valRight;
	return result;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:51,代码来源:binaryexpression.cpp

示例10: Array

ExpressionResult ArrayExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
	Array::Ptr result = new Array();
	result->Reserve(m_Expressions.size());

	for (Expression *aexpr : m_Expressions) {
		ExpressionResult element = aexpr->Evaluate(frame);
		CHECK_RESULT(element);

		result->Add(element.GetValue());
	}

	return result;
}
开发者ID:wopfel,项目名称:icinga2,代码行数:14,代码来源:expression.cpp

示例11: setResultForContribution

void setResultForContribution(
    const fvMesh &mesh,
    ExpressionResult &result,
    const scalarField &values
) {
    result.setResult(values);
}
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder2.0-libraries-swak4Foam,代码行数:7,代码来源:ContributionScalarFunctionPlugin.C

示例12: volScalarField

void setResultForContribution<FieldValuePluginFunction>(
    const fvMesh &mesh,
    ExpressionResult &result,
    const scalarField &values
) {
    autoPtr<volScalarField> pResult(
        new volScalarField(
            IOobject(
                "contributionFrom_", // +Driver::driverName(),
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh,
            dimensionedScalar("contribution",dimless,0)
        )
    );

#ifdef FOAM_NO_DIMENSIONEDINTERNAL_IN_GEOMETRIC
    const_cast<scalarField&>(pResult->internalField().field())
#else
    pResult->internalField()
#endif
        =values;
    pResult->correctBoundaryConditions();

    result.setObjectResult(pResult);
}
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder2.0-libraries-swak4Foam,代码行数:29,代码来源:ContributionScalarFunctionPlugin.C

示例13: FatalErrorIn

void StackExpressionResult::push(ExpressionResult &atEnd)
{
    if(debug) {
        Info << "StackExpressionResult::push(ExpressionResult &atEnd)" << endl;
        Info << "Pushing: " << atEnd << endl;
    }
    if(!hasValue()) {
        // this is the first push
        //        static_cast<ExpressionResult>(*this)=atEnd;
        ExpressionResult::operator=(atEnd);
    } else {
        if(valueType()!=atEnd.valueType()) {
            FatalErrorIn("StackExpressionResult::push(const ExpressionResult &atEnd)")
                << "Type of pushed value " << atEnd.valueType()
                    << " is not the expected type " << valueType()
                    << endl
                    << abort(FatalError);
        }
        if(valueType()==pTraits<scalar>::typeName) {
            pushInternal<scalar>(atEnd);
        } else if(valueType()==pTraits<vector>::typeName) {
            pushInternal<vector>(atEnd);
        } else if(valueType()==pTraits<tensor>::typeName) {
            pushInternal<tensor>(atEnd);
        } else if(valueType()==pTraits<symmTensor>::typeName) {
            pushInternal<symmTensor>(atEnd);
        } else if(valueType()==pTraits<sphericalTensor>::typeName) {
            pushInternal<sphericalTensor>(atEnd);
        } else {
            FatalErrorIn("StackExpressionResult::push(const ExpressionResult &atEnd)")
                << " Unsopported value type " << valueType()
                    << endl
                    << abort(FatalError);
        }
    }
    if(debug) {
        Info << "After push: " << *this << endl;
    }
}
开发者ID:adimako,项目名称:swak4foam,代码行数:39,代码来源:StackExpressionResult.C

示例14:

std::list<Index*> IndexPage::find(FilterParser* parser) const {
	std::list<Index*> result;
	for (int x = 0; x < size; x++) {
		BSONObj* key = elements[x]->key;
		bool match = false;
		ExpressionResult* expresult = parser->eval(*key);
		if (expresult->type() == ExpressionResult::RT_BOOLEAN) {
			match = *expresult;
		}
		delete expresult;
		if (match) {
			result.push_back(elements[x]);
		}
	}
	for (int x = 0; x <= size; x++) {
		IndexPage* innerPage = pointers[x];
		if (innerPage != NULL) {
			std::list<Index*> inner = innerPage->find(parser);
			result.insert(result.begin(), inner.begin(), inner.end());
		}
	}
	return result;
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:23,代码来源:bplusindex.cpp

示例15: last

void StackExpressionResult::operator=(const ExpressionResult& rhs)
{
    if(debug) {
        Info << "StackExpressionResult::operator=(const ExpressionResult& rhs)" << endl;
    }
    ExpressionResult last(
        rhs.getUniform(
            1,
            false // issue a warning if the other result is not really uniform
        )
    );

    this->push(
        last
    );
}
开发者ID:adimako,项目名称:swak4foam,代码行数:16,代码来源:StackExpressionResult.C


注:本文中的ExpressionResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。