virtual void addConditionIn(string field, string values, bool inverse = false) { if (!inverse) addCondition(field + " IN (" + values + ")"); else addCondition(field + " NOT IN (" + values + ")"); }
virtual void addConditionLike(string field, string value, bool inverse = false) { if (!inverse) addCondition(field + " LIKE '" + value + "'"); else addCondition(field + " NOT LIKE '" + value + "'"); }
virtual void addConditionLessThanOrEqual(string field, string value, bool inverse = false) { if (!inverse) addCondition(field + "<='" + value + "'"); else addCondition(field + ">'" + value + "'"); }
virtual void addConditionGreaterThan(string field, string value, bool inverse = false) { if (!inverse) addCondition(field + ">'" + value + "'"); else addCondition(field + "<='" + value + "'"); }
virtual void addConditionBetween(string field, string startv, string endv, bool inverse = false) { if (!inverse) addCondition( field + " BETWEEN '" + startv + "' AND '" + endv + "'"); else addCondition( field + " NOT BETWEEN '" + startv + "' AND '" + endv + "'"); }
//-------------------------------------------------------------------------------- int QmvQueryWidget::initConditions( QWidget * parent, int minsize ) { // clear existing condition widgets (but not the condition objects) condition_list.setAutoDelete(TRUE); condition_list.clear(); // Scan existing condition objects and create widgets for them for ( int row = 0; row < query_object->countConditions(); row++ ) { QmvQueryCondition * query_condition = query_object->getCondition( row ); query_condition->setActive(TRUE); QmvQueryConditionWidget * cw; cw = new QmvQueryConditionWidget( query_condition, parent, QString( "conditionwidget-%1" ) .arg(row) ); condition_list.insert( query_condition, cw ); } // Extend the condition list to minsize with new condition // objects, complete with matching condition widgets for ( int row = condition_list.count(); row < minsize; row++) addCondition( parent, row); return condition_list.count(); }
void cNPC::save() { if ( changed_ ) { initSave; setTable( "npcs" ); addField( "serial", serial() ); addField( "summontime", summonTime_ ? summonTime_ - Server::instance()->time() : 0 ); addField( "additionalflags", additionalFlags_ ); addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL ); addField( "stablemaster", stablemasterSerial_ ); addStrField( "ai", aiid_ ); addField( "wandertype", ( Q_UINT8 ) wanderType() ); addField( "wanderx1", wanderX1() ); addField( "wanderx2", wanderX2() ); addField( "wandery1", wanderY1() ); addField( "wandery2", wanderY2() ); addField( "wanderradius", wanderRadius() ); addCondition( "serial", serial() ); saveFields; } cBaseChar::save(); }
FdmHestonHullWhiteSolver::FdmHestonHullWhiteSolver( const Handle<HestonProcess>& hestonProcess, const Handle<HullWhiteProcess>& hwProcess, Rate corrEquityShortRate, const boost::shared_ptr<FdmMesher>& mesher, const FdmBoundaryConditionSet& bcSet, const boost::shared_ptr<FdmStepConditionComposite> & condition, const boost::shared_ptr<FdmInnerValueCalculator>& calculator, const Time maturity, const Size timeSteps, const Size dampingSteps, FdmBackwardSolver::FdmSchemeType schemeType, Real theta, Real mu) : hestonProcess_(hestonProcess), hwProcess_(hwProcess), corrEquityShortRate_(corrEquityShortRate), mesher_(mesher), bcSet_(bcSet), thetaCondition_(new FdmSnapshotCondition( 0.99*std::min(1.0/365.0, condition->stoppingTimes().empty() ? maturity : condition->stoppingTimes().front()))), condition_(addCondition(thetaCondition_, condition)), maturity_(maturity), timeSteps_(timeSteps), dampingSteps_(dampingSteps), schemeType_(schemeType), theta_(theta), mu_(mu), initialValues_(mesher->layout()->size()), resultValues_(mesher->layout()->dim()[2], Matrix(mesher->layout()->dim()[1], mesher->layout()->dim()[0])), interpolation_(mesher->layout()->dim()[2]) { registerWith(hestonProcess); registerWith(hwProcess); x_.reserve(mesher->layout()->dim()[0]); v_.reserve(mesher->layout()->dim()[1]); r_.reserve(mesher->layout()->dim()[2]); const boost::shared_ptr<FdmLinearOpLayout> layout = mesher->layout(); const FdmLinearOpIterator endIter = layout->end(); for (FdmLinearOpIterator iter = layout->begin(); iter != endIter; ++iter) { initialValues_[iter.index()] = calculator->avgInnerValue(iter); if (!iter.coordinates()[1] && !iter.coordinates()[2]) { x_.push_back(mesher->location(iter, 0)); } if (!iter.coordinates()[0] && !iter.coordinates()[2]) { v_.push_back(mesher->location(iter, 1)); } if (!iter.coordinates()[0] && !iter.coordinates()[1]) { r_.push_back(mesher->location(iter, 2)); } } }
QString TenderSelect::where() const { QString where = Select::where(); if (id != INVALID_ID) addIdCondition(where, "tender_id", id); if (name != "") addStringCondition(where, "name", name); if (type != -1) addCondition(where, "tender_type = " + QString::number(type)); if (bankOnly) addCondition(where, "bank_id is not null"); return where; }
void cPlayer::save() { if ( changed_ ) { initSave; setTable( "players" ); addField( "serial", serial() ); if ( account_ ) { addStrField( "account", account_->login() ); } else { addStrField( "account", QString::null ); } addField( "additionalflags", additionalFlags_ ); addField( "visualrange", visualRange_ ); addStrField( "profile", profile_ ); addField( "fixedlight", fixedLightLevel_ ); addField( "strlock", strengthLock_ ); addField( "dexlock", dexterityLock_ ); addField( "intlock", intelligenceLock_ ); addField( "maxcontrolslots", maxControlSlots_ ); addCondition( "serial", serial() ); saveFields; } cBaseChar::save(); }
void cNPC::save() { if ( changed_ ) { initSave; setTable( "npcs" ); addField( "serial", serial() ); addField( "mindamage", minDamage_); addField( "maxdamage", maxDamage_); addField( "tamingminskill", tamingMinSkill_); addField( "summontime", summonTime_ ? summonTime_ - uiCurrentTime : 0 ); addField( "additionalflags", additionalFlags_ ); addField( "owner", owner_ ? owner_->serial() : INVALID_SERIAL ); addStrField( "carve", carve_); addStrField( "spawnregion", spawnregion_); addField( "stablemaster", stablemasterSerial_ ); addStrField( "lootlist", lootList_); addStrField( "ai", aiid_ ); addField( "wandertype", (UINT8)wanderType() ); addField( "wanderx1", wanderX1() ); addField( "wanderx2", wanderX2() ); addField( "wandery1", wanderY1() ); addField( "wandery2", wanderY2() ); addField( "wanderradius", wanderRadius() ); addField( "fleeat", criticalHealth() ); addField( "spellslow", spellsLow_ ); addField( "spellshigh", spellsHigh_ ); addField( "controlslots", controlSlots_ ); addCondition( "serial", serial() ); saveFields; } cBaseChar::save(); }
void PluginManager::operator<<(const QVariantMap& in) { const QVariantList conditions(in[Identifiers::keyConditions].toList()); const QVariantList actions(in[Identifiers::keyActions].toList()); foreach(const QVariant& condition, conditions) addCondition(condition.toString()); foreach(const QVariant& action, actions) addAction(action.toString()); }
/*! Performs persistency layer saves. */ void cUObject::save() { bool havetags_ = ( tags_.size() > 0 ); // uobjectmap fields initSave; // If the type is changed somewhere in the code // That part needs to take care of delete/recreate // So we never update the type EVER here.. if( !isPersistent ) { setTable( "uobjectmap" ); addField( "serial", serial_ ); addStrField( "type", objectID() ); addCondition( "serial", serial_ ); saveFields; clearFields; } // uobject fields if ( changed_ ) { setTable( "uobject" ); addStrField( "name", name_ ); addField( "serial", serial_ ); addField( "multis", multis_ ); addField( "pos_x", pos_.x ); addField( "pos_y", pos_.y ); addField( "pos_z", pos_.z ); addField( "pos_map", pos_.map ); addStrField( "events", eventList_.join( "," ) ); addStrField( "bindmenu", bindmenu_ ); addCondition( "serial", serial_ ); addField( "havetags", havetags_ ); saveFields; } if( havetags_ ) { tags_.save( serial_ ); } PersistentObject::save(); changed_ = false; }
/*! Performs persistency layer saves. */ void cUObject::save() { bool havetags_ = ( tags_.size() > 0 ); // uobjectmap fields // If the type is changed somewhere in the code // That part needs to take care of delete/recreate // So we never update the type EVER here.. if( !isPersistent ) { initSave; setTable( "uobjectmap" ); addField( "serial", serial_ ); addStrField( "type", QString( objectID() ) ); addCondition( "serial", serial_ ); saveFields; clearFields; } // uobject fields if ( changed_ ) { initSave; setTable( "uobject" ); addStrField( "name", name_ ); addField( "serial", serial_ ); addField( "multis", multis_ ); addField( "direction", dir_); addField( "pos_x", pos_.x ); addField( "pos_y", pos_.y ); addField( "pos_z", pos_.z ); addField( "pos_map", pos_.map ); addStrField( "events", eventList_ == QString::null ? QString( "" ) : eventList_ ); addStrField( "bindmenu", bindmenu_ ); addCondition( "serial", serial_ ); addField( "havetags", havetags_ ); saveFields; } if( havetags_ ) { tags_.save( serial_ ); } PersistentObject::save(); flagUnchanged(); // This is the botton of the chain, now go up and flag everyone unchanged. }
void SVConditionParam::createAddButton(int nRow) { WText(" " , (WContainerWidget*) m_pOperate->elementAt(nRow, 1)); WPushButton * pAdd = new WPushButton(SVResString::getResString("IDS_Add"), (WContainerWidget*) m_pOperate->elementAt(nRow, 1)); if(pAdd) { pAdd->setToolTip(SVResString::getResString("IDS_Add_Title")); WObject::connect(pAdd, SIGNAL(clicked()), this, SLOT(addCondition())); } }
bool Creature::addCombatCondition(Condition* condition) { bool hadCondition = hasCondition(condition->getType(), -1, false); //Caution: condition variable could be deleted after the call to addCondition ConditionType_t type = condition->getType(); if(!addCondition(condition)) return false; onAddCombatCondition(type, hadCondition); return true; }
bool Creature::addCombatCondition(Condition* condition) { //Caution: condition variable could be deleted after the call to addCondition ConditionType_t type = condition->getType(); if (!addCondition(condition)) { return false; } onAddCombatCondition(type); return true; }
QString GroupSelect::where() const { QString where = Select::where(); if (id != INVALID_ID) addIdCondition(where, "group_id", id); if (name != "") addStringCondition(where, "name", name, 20); if (type != -1) addCondition(where, "group_type = " + QString::number(type)); return where; }
void AntistringConfiguration::readConditions() { Conditions.clear(); QString conditionsString = config_file.readEntry("PowerKadu", "antistring conditions"); QStringList conditionsList = conditionsString.split("\t\t"); if (conditionsList.empty()) { readDefaultConditions(); return; } foreach (const QString &conditionItem, conditionsList) addCondition(conditionItem); }
void AntistringConfiguration::readDefaultConditions() { QFile defaultListFile(dataPath("kadu/modules/data/antistring/ant_conditions.conf")); if (!defaultListFile.open(QFile::ReadOnly)) { kdebug("Can't open file: %s", qPrintable(defaultListFile.fileName())); return; } QTextStream textStream(&defaultListFile); while (!textStream.atEnd()) addCondition(textStream.readLine()); defaultListFile.close(); }
QString StoreSelect::where() const { QString where = Select::where(); if (id != INVALID_ID) addIdCondition(where, "store_id", id); if (name != "") addStringCondition(where, "name", name); if (number != "") addStringCondition(where, "number", number); if (sellOnly) addCondition(where, "can_sell = 'Y'"); if (company_id != INVALID_ID) addIdCondition(where, "company_id", id); return where; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 创建添加按钮 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// void SVConditionParam::createAddButton(int nRow) { WTable *pSub = new WTable(m_pOperate->elementAt(nRow, 1)); if(pSub) { pSub->setStyleClass("widthauto"); new WText(SVResString::getResString("IDS_Condition"), m_pOperate->elementAt(nRow, 0)); m_pReturnList = new WComboBox(pSub->elementAt(0, 0)); if(m_pReturnList) { m_pReturnList->setStyleClass("cell_condition"); list<SVReturnItem*>::iterator lsItem; for(lsItem = m_lsReturn.begin(); lsItem != m_lsReturn.end(); lsItem++) m_pReturnList->addItem((*lsItem)->getLabel()); } new WText(" ", pSub->elementAt(0, 1)); m_pOperateList = new WComboBox(pSub->elementAt(0, 2)); if(m_pOperateList) { m_pOperateList->setStyleClass("cell_condition"); list<string>::iterator lsItem; for(lsItem = m_lsCondition.begin(); lsItem != m_lsCondition.end(); lsItem++) m_pOperateList->addItem((*lsItem)); } new WText(" ", pSub->elementAt(0, 3)); m_pParam = new WLineEdit("", pSub->elementAt(0, 4)); if(m_pParam) m_pParam->setStyleClass("cell_condition"); new WText(" ", pSub->elementAt(0, 5)); CEccButton * pAdd = new CEccButton(SVResString::getResString("IDS_Add"), SVResString::getResString("IDS_Add_Title"), "", pSub->elementAt(0, 6)); if(pAdd) { WObject::connect(pAdd, SIGNAL(clicked()), this, SLOT(addCondition())); } } }
void UContainerTag::menu(QMenu &menu) { QMenu *m; if(isIndependent()) { m=menu.addMenu("Insert within"); }else m=&menu; m->addAction(" - Insert -")->setEnabled(false); m->addAction("Condition",this,SLOT(addCondition())); m->addAction("Traverse",this,SLOT(addTraverse())); m->addAction("Loop",this,SLOT(addLoop())); m->addAction("Break loop",this,SLOT(addBreak())); m->addAction("Continue loop",this,SLOT(addContinue())); m->addAction("Function call",this,SLOT(addFunction())); m->addAction("Variable assign",this,SLOT(addAssign())); m->addAction("Return",this,SLOT(addReturn())); m->addAction("Python command",this,SLOT(addExec())); m->addAction("Comment",this,SLOT(addComment())); }
void AntistringConfigurationUiHandler::mainConfigurationWindowCreated(MainConfigurationWindow *mainConfigurationWindow) { ConfigGroupBox *groupBox = mainConfigurationWindow->widget()->configGroupBox("Chat", "Antistring", "Conditions"); QWidget *widget = new QWidget(groupBox->widget()); widget->setContentsMargins(0, 0, 0, 0); QGridLayout *layout = new QGridLayout(widget); ConditionListWidget = new QListWidget(widget); layout->addWidget(ConditionListWidget, 0, 0, 1, 4); ConditionWidget = new QLineEdit(widget); layout->addWidget(new QLabel(tr("Condition"), widget), 1, 0); layout->addWidget(ConditionWidget, 1, 1, 1, 3); FactorWidget = new QSpinBox(widget); FactorWidget->setMinimum(0); FactorWidget->setMaximum(5); FactorWidget->setSpecialValueText(tr("Don't use")); layout->addWidget(new QLabel(tr("Factor"), widget), 2, 0); layout->addWidget(FactorWidget, 2, 1, 1, 3); QPushButton *addConditionButton = new QPushButton(tr("Add"), widget); QPushButton *changeConditionButton = new QPushButton(tr("Change"), widget); QPushButton *deleteConditionButton = new QPushButton(tr("Delete"), widget); layout->addWidget(addConditionButton, 3, 1); layout->addWidget(changeConditionButton, 3, 2); layout->addWidget(deleteConditionButton, 3, 3); groupBox->addWidget(widget); connect(ConditionListWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(wordSelected(QListWidgetItem *))); connect(addConditionButton, SIGNAL(clicked()), this, SLOT(addCondition())); connect(changeConditionButton, SIGNAL(clicked()), this, SLOT(changeCondition())); connect(deleteConditionButton, SIGNAL(clicked()), this, SLOT(deleteCondition())); updateConditionList(); connect(mainConfigurationWindow, SIGNAL(configurationWindowApplied()), this, SLOT(applyConfiguration())); }
Where::Where(WhereCond* firstWhere){ numOfCond = 0; addCondition(0,firstWhere); }
/** * Create a script line from a syntax parser. */ ScriptLine* ScriptLineBlock::createLine(SyntaxParser* parser) { // create an anonymous block auto blockParser = parser->block(); if ( blockParser ) { auto block = new ScriptAnonymousBlock(this); block->addScript( blockParser->match() ); return block; } // create an expression auto exprParser = parser->expression(); if ( exprParser ) { Kernel::EParser expr; expr.parse( exprParser->match() ); if ( expr.name() == ":=" ) { if ( expr.size() != 2 ) { throw std::runtime_error("ScriptLineBlock:: syntax error: " + expr.str() ); } auto e = Expression_ptr(new Expression(m_local_namespace, expr[1]) ); auto setLine = new ScriptLineSet( m_local_namespace, expr[0].name(), e ); return setLine; } else { auto e = Expression_ptr(new Expression(m_local_namespace, expr) ); return new ScriptLineExpression( m_local_namespace, e ); } } // declare a variable auto varParser = parser->defVar(); if ( varParser ) { std::string value = varParser->value() ? varParser->value()->match() : ""; auto line = new ScriptLineDef(m_local_namespace, varParser->type()->match(), varParser->var()->match(), value); return line; } // an if-block auto ifParser = parser->ifBlock(); if ( ifParser ) { auto cond = ifParser->condition(); auto trueBlock = ifParser->trueBlock(); auto elseBlock = ifParser->elseBlock(); std::string condStr(cond->getInnerStart(), cond->getInnerEnd()); std::string trueScript(trueBlock->getInnerStart(), trueBlock->getInnerEnd()); // create the if line instance auto ifLine = new ScriptLineIf(m_local_namespace); // create the first condition expression Kernel::EParser expr; expr.parse( condStr ); auto e = Expression_ptr(new Expression(m_local_namespace, expr) ); // add first condition auto block = new ScriptAnonymousBlock(this); block->addScript( trueScript ); ifLine->addCondition(e, ScriptLine_ptr(block) ); // add the else block std::string elseScript; if ( elseBlock ) { elseScript.assign(elseBlock->getInnerStart(), elseBlock->getInnerEnd()); auto block = new ScriptAnonymousBlock(this); block->addScript( trueScript ); ifLine->addDefault( ScriptLine_ptr(block) ); } return ifLine; } return nullptr; }
/** * Switch case sur un noeud permettant de définir sa nature et extraire les * champs utiles afin de les ajouter à la liste chainée de rules * \param node le noeud à parser */ void fillRules(xmlNodePtr node) { // Ajout d'une regle if(strcmp((char *)node->name, "rule") == 0) { xmlAttrPtr attr = getAttrByName(node, "name"); if(attr != NULL && attr->children != NULL) { xmlChar *content = xmlNodeGetContent(attr->children); addRule((char *)content); } } // Ajout d'une action if(strcmp((char *)node->name, "activate") == 0) { xmlAttrPtr devicePtr = getAttrByName(node, "device"); xmlAttrPtr fieldPtr = getAttrByName(node, "field"); if(node->children != NULL && node->children->type == XML_TEXT_NODE && devicePtr != NULL && devicePtr->children != NULL && fieldPtr !=NULL && fieldPtr->children != NULL) { xmlChar *state = xmlNodeGetContent(node); xmlChar *device = xmlNodeGetContent(devicePtr->children); xmlChar *field = xmlNodeGetContent(fieldPtr->children); addAction((char *) device, (char *) state, (char *) field); xmlFree(state); xmlFree(device); xmlFree(field); } } // Ajout d'une alerte if(strcmp((char *)node->name, "alert") == 0) { xmlAttrPtr attr = getAttrByName(node, "recipient"); if(attr != NULL && attr->children != NULL && node->children != NULL && node->children->type == XML_TEXT_NODE) { xmlChar *message = xmlNodeGetContent(node); xmlChar *recipient = xmlNodeGetContent(attr->children); addAlert((char *)recipient, (char *) message); xmlFree(recipient); } } // Ajout d'une condition if(strcmp((char *)node->name, "condition") == 0) { xmlAttrPtr devicePtr = getAttrByName(node, "device"); xmlAttrPtr fieldPtr = getAttrByName(node, "field"); xmlAttrPtr typePtr = getAttrByName(node, "type"); if(node->children != NULL && node->children->type == XML_TEXT_NODE && devicePtr != NULL && devicePtr->children != NULL && fieldPtr !=NULL && fieldPtr->children != NULL && typePtr !=NULL && typePtr->children != NULL) { xmlChar *value = xmlNodeGetContent(node); xmlChar *device = xmlNodeGetContent(devicePtr->children); xmlChar *field = xmlNodeGetContent(fieldPtr->children); xmlChar *type = xmlNodeGetContent(typePtr->children); addCondition((char *)device, (char *) field, (char *) type, (char *) value); xmlFree(value); xmlFree(device); xmlFree(field); xmlFree(type); } } }