本文整理汇总了C++中VariableList::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableList::contains方法的具体用法?C++ VariableList::contains怎么用?C++ VariableList::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableList
的用法示例。
在下文中一共展示了VariableList::contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readPointVar
bool NSParser::readPointVar(Symbol* symbol, VariableList& variables, Tools::RPoint &point)
{
bool result = false;
QString varName = readVar(symbol);
if (variables.contains(varName))
{
DeclaredVariable& var = variables[varName];
if (var.isPoint())
{
point = var.toPoint();
result = true;
}
else
addError(NSParsingError::invalidVariableTypeError(varName, "point", symbol));
}
else
addError(NSParsingError::undeclaredVariableError(varName, symbol));
return result;
}
示例2: readRectVar
bool NSParser::readRectVar(Symbol* symbol, VariableList &variables, QRectF &r)
{
bool result = false;
QString varName = readVar(symbol);
if (variables.contains(varName))
{
DeclaredVariable& var = variables[varName];
if (var.isRect())
{
r = var.toRect();
result = true;
}
else
addError(NSParsingError::invalidVariableTypeError(varName, "rect", symbol));
}
else
addError(NSParsingError::undeclaredVariableError(varName, symbol));
return result;
}
示例3: readFixedRect
QRectF NSParser::readFixedRect(Symbol* symbol, VariableList& variables)
{
QRectF r(0,0,1,1);
Tools::RPoint center;
bool definedByCenter = false;
double radius = 0;
int nbParamRead = 0;
if (symbol->type == NON_TERMINAL)
{
NonTerminal* nt = static_cast<NonTerminal*>(symbol);
for(Symbol* child: nt->children)
{
switch(child->symbolIndex)
{
case SYM_NUM:
{
double value = readNum(child);
if (definedByCenter)
radius = value;
else if (nbParamRead == 0)
r.setX(value);
else if (nbParamRead == 1)
r.setY(value);
else if (nbParamRead == 2)
r.setWidth(value);
else
r.setHeight(value);
++nbParamRead;
break;
}
case SYM_POINT:
case SYM_FIXED_POINT:
{
definedByCenter = true;
center = readPoint(child);
break;
}
case SYM_VAR:
{
QString name = readVar(child);
if (variables.contains(name))
{
DeclaredVariable& var = variables[name];
if (var.isPoint())
{
center = var.toPoint();
definedByCenter = true;
}
else
addError(NSParsingError::invalidVariableTypeError(name, "point", child));
}
else
addError(NSParsingError::undeclaredVariableError(name, child));
break;
}
}
}
}
if (definedByCenter)
{
r.setWidth(radius * 2.0);
r.setHeight(radius * 2.0);
r.moveCenter(center.toQPointF());
}
return r;
}
示例4: readCondition
NSParser::ConditionInfo NSParser::readCondition(Symbol *symbol, VariableList& variables)
{
ConditionInfo info;
if (symbol->type == NON_TERMINAL)
{
Symbol* conditionSymbol = nullptr;
NonTerminal* nt = static_cast<NonTerminal*>(symbol);
switch(nt->ruleIndex)
{
case PROD_SENSORCONDITION:
case PROD_IFCONDITION: //sensor
conditionSymbol = searchChild(symbol, SYM_SENSORCONDITION);
break;
case PROD_ORIENTATIONCONDITION_ORIENTATION:
case PROD_IFCONDITION2: //orientation
info.type = ConditionInfo::RobotOrientationCondition;
conditionSymbol = searchChild(symbol, SYM_ORIENTATIONCONDITION);
break;
case PROD_POSITIONCONDITION_POSITION:
case PROD_IFCONDITION3: //position
info.type = ConditionInfo::RobotPosCondition;
conditionSymbol = searchChild(symbol, SYM_POSITIONCONDITION);
break;
case PROD_OPPONENTCONDITION_OPPONENT:
case PROD_IFCONDITION4: //opponent
info.type = ConditionInfo::OpponentPosCondition;
conditionSymbol = searchChild(symbol, SYM_OPPONENTCONDITION);
break;
case PROD_REVERSECONDITION_STRATEGY_REVERSED:
case PROD_IFCONDITION5: //strategy reversed
info.type = ConditionInfo::ReversedStrategyCondition;
conditionSymbol = searchChild(symbol, SYM_REVERSECONDITION);
break;
case PROD_IFCONDITION_TRUE: //strategy reversed
info.type = ConditionInfo::AlwaysTrueCondition;
break;
case PROD_IFCONDITION_FALSE: //strategy reversed
info.type = ConditionInfo::AlwaysFalseCondition;
break;
}
int sensorType = Comm::UnknownedSensor;
if (conditionSymbol && conditionSymbol->type == NON_TERMINAL)
{
NonTerminal* conditionSymbolNt = static_cast<NonTerminal*>(conditionSymbol);
for(Symbol* c: conditionSymbolNt->children)
{
switch(c->symbolIndex)
{
case SYM_SENSOR_IDENTIFIER:
case SYM_SENSOR_OR_VAR:
{
readSensorOrVar(c, variables, sensorType, info.sensorId);
if (sensorType == Comm::ColorSensor)
info.type = ConditionInfo::ColorSensorValueCondition;
else if (sensorType == Comm::SharpSensor)
info.type = ConditionInfo::SharpValueCondition;
else if (sensorType == Comm::MicroswitchSensor)
info.type = ConditionInfo::MicroswitchValueCondition;
break;
if (info.sensorId <= 0)
{
info.setInvalid();
addError(NSParsingError::invalidSensorId(c));
}
}
case SYM_COLORSENSORVALUE:
case SYM_MICROSWITCHVALUE:
case SYM_SHARPVALUE:
case SYM_SENSORVALUE:
{
Comm::SensorType valueSensorType;
info.sensorValue = readSensorValue(c, valueSensorType);
if (valueSensorType != sensorType)
{
addError(NSParsingError::invalidSensorValueError(readTerminals(c), c));
info.sensorValue = -1;
info.setInvalid();
}
break;
}
case SYM_RECT_OR_VAR:
case SYM_RECT2:
case SYM_FIXED_RECT:
readRectOrVar(c, variables, info.rect);
break;
case SYM_ANGLERANGE:
readAngleRangeInRadian(c, info.angleMin, info.angleMax);
break;
case SYM_VAR:
{
QString varName = readVar(c);
if (variables.contains(varName))
{
DeclaredVariable& var = variables[varName];
if (info.type == ConditionInfo::OpponentPosCondition || info.type == ConditionInfo::RobotPosCondition)
{
//expected rect
if (var.isRect())
//.........这里部分代码省略.........
示例5: readCallArg
bool NSParser::readCallArg(Symbol *symbol, VariableList &variables, NSParser::DeclaredVariable& callArgVariable)
{
bool result = true;
switch(symbol->symbolIndex)
{
case SYM_VAR:
{
QString name = readVar(symbol);
if (variables.contains(name))
callArgVariable = variables[name];
else
{
addError(NSParsingError::undeclaredVariableError(name, symbol));
result = false;
}
break;
}
case SYM_POINT:
case SYM_FIXED_POINT:
{
Tools::RPoint p = readPoint(symbol);
callArgVariable = DeclaredVariable::fromPoint(p);
break;
}
case SYM_RECT2:
case SYM_FIXED_RECT:
{
QRectF r = readRect(symbol, variables);
callArgVariable = DeclaredVariable::fromRect(r);
break;
}
case SYM_SENSOR_IDENTIFIER:
{
int type = -1, id = 0;
readSensorIdentifier(symbol, type, id);
callArgVariable = DeclaredVariable::fromSensor(id, type);
break;
}
case SYM_PARAMETER_IDENTIFIER:
{
int paramId = readSubId(symbol);
callArgVariable = DeclaredVariable::fromParameter(paramId);
break;
}
case SYM_AX12_IDENTIFIER:
{
int ax12Id = readSubId(symbol);
callArgVariable = DeclaredVariable::fromAx12(ax12Id);
break;
}
case SYM_ACTION2:
{
int actionId, param, time;
readAction(symbol, actionId, param, time);
callArgVariable = DeclaredVariable::fromAction(actionId, param, time);
break;
}
case SYM_STRING:
{
QString str = readString(symbol);
callArgVariable = DeclaredVariable::fromString(str);
break;
}
case SYM_CALLARG:
{
if (symbol->type == NON_TERMINAL)
{
result = false;
NonTerminal* nt = static_cast<NonTerminal*>(symbol);
for(Symbol* child: nt->children)
{
readCallArg(child, variables, callArgVariable);
if (callArgVariable.isValid())
{
result = true;
break;
}
}
}
}
}
return result;
}