Ejemplo n.º 1
0
void Parser::parseStrategiesFromFile(QWidget *parent, std::vector<Strategy*> &res, QString filename) {

    QFile* file = new QFile(filename);
    if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::critical(parent,"Load XML File Problem",
            "Couldn't open xml file: " + filename,
            QMessageBox::Ok);
    }

    QXmlStreamReader xml(file);
    while (!xml.atEnd() && !xml.hasError()) {
        QXmlStreamReader::TokenType token = xml.readNext();
        if (token == QXmlStreamReader::StartElement) {
            if (xml.name().toString() == "strategy") {
                //parse strategy header..
                QXmlStreamAttributes str_attr = xml.attributes();
                QString pos = str_attr.value("position").toString();
                std::pair<int, int> from_to = parseStack(str_attr.value("stack").toString());
                Strategy *st = new Strategy(pos, from_to.first, from_to.second);

                //parse strategy body..
                parseStrategy(xml, st);

                res.push_back(st);
            }
        }
    }
}
Ejemplo n.º 2
0
bool PlannerStrategy::setStrategy(const QString& strStrategy) {

	strategyString = strStrategy;

	bool parsed = parseStrategy(strategyString);

	// Notify that the strategy has changed
//	emit sigStrategySchanged(parsed);

	return parsed;
}