bool XCScheme::initFromXML(const pugi::xml_document& doc)
{
  // Create an error reporter for parsing
  ErrorReporter reporter(SB_INFO, "Error parsing \"" + m_name + "\" scheme for \"" + m_parentProject->getName() + "\" project. ");
  
  // Find and process all BuildActionEntry nodes
  pugi::xpath_node_set baSet = doc.select_nodes("/Scheme/BuildAction/BuildActionEntries/BuildActionEntry");
  for (pugi::xpath_node_set::const_iterator it = baSet.begin(); it != baSet.end(); ++it)
    parseBuildAction(it->node(), reporter);
    
  // Find and process all ArchiveAction nodes
  pugi::xpath_node_set aaSet = doc.select_nodes("/Scheme/ArchiveAction");
  for (pugi::xpath_node_set::const_iterator it = aaSet.begin(); it != aaSet.end(); ++it)
    parseArchiveAction(it->node(), reporter);
  
  // Make sure we got enough information
  if (m_targets.empty()) {
    reporter.reportError("Failed to read any archiveable targets.");
    return false;
  } else if (m_configName.empty()) {
    reporter.reportError("Failed to read a valid build configuration name.");
    return false;
  } else {
    return true;
  }
}
예제 #2
0
pugi::xml_node appendValue(pugi::xml_document & doc, string tag, string attribute, string newValue, bool overwriteMultiple){

    if (overwriteMultiple == true){
        // find the existing node...
        char xpathExpression[1024];
        sprintf(xpathExpression, "//%s[@%s='%s']", tag.c_str(), attribute.c_str(), newValue.c_str());
        pugi::xpath_node node = doc.select_single_node(xpathExpression);
        if(string(node.node().attribute(attribute.c_str()).value()).size() > 0){ // for some reason we get nulls here?
            // ...delete the existing node
            cout << "DELETING: " << node.node().name() << ": " << " " << node.node().attribute(attribute.c_str()).value() << endl;
            node.node().parent().remove_child(node.node());
        }
    }

    if (!doesTagAndAttributeExist(doc, tag, attribute, newValue)){
        // otherwise, add it please:
        char xpathExpression[1024];
        sprintf(xpathExpression, "//%s[@%s]", tag.c_str(), attribute.c_str());
        //cout << xpathExpression << endl;
        pugi::xpath_node_set add = doc.select_nodes(xpathExpression);
        pugi::xml_node node = add[add.size()-1].node();
        pugi::xml_node nodeAdded = node.parent().append_copy(node);
        nodeAdded.attribute(attribute.c_str()).set_value(newValue.c_str());
        return nodeAdded;
    }else{
    	return pugi::xml_node();
    }

}
template <typename T> void
setAllValuesXMLNodeMadrid(pugi::xml_document & doc, std::string xpath_query, T new_value)
{
    pugi::xpath_node_set nodes = doc.select_nodes(xpath_query.c_str());
    for (pugi::xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it)
    {
        pugi::xpath_node node = *it;
        node.node().first_child().set_value(std::to_string(new_value).c_str());
    }
}
예제 #4
0
	bool FontExportSerializer::deserialization(pugi::xml_document& _doc)
	{
		if (_doc.select_single_node("MyGUI[@type=\"Resource\"]").node().empty())
			return false;

		pugi::xpath_node_set nodes = _doc.select_nodes("MyGUI/Resource[@type=\"ResourceTrueTypeFont\"]");
		for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
			parseFont((*node).node());

		return true;
	}
예제 #5
0
bool doesTagAndAttributeExist(pugi::xml_document & doc, string tag, string attribute, string newValue){
    char xpathExpressionExists[1024];
    sprintf(xpathExpressionExists, "//%s[@%s='%s']", tag.c_str(), attribute.c_str(), newValue.c_str());
    //cout <<xpathExpressionExists <<endl;
    pugi::xpath_node_set set = doc.select_nodes(xpathExpressionExists);
    if (set.size() != 0){
        return true;
    } else {
        return false;
    }
}
예제 #6
0
	bool ImageExportSerializer::deserialization(pugi::xml_document& _doc)
	{
		if (_doc.select_single_node("MyGUI[@type=\"Resource\"]").node().empty())
			return false;

		pugi::xpath_node_set nodes = _doc.select_nodes("MyGUI/Resource[@type=\"ResourceImageSet\"]");
		for (pugi::xpath_node_set::const_iterator node = nodes.begin(); node != nodes.end(); node ++)
			parseImage((*node).node());

		updateImageProperty(DataManager::getInstance().getRoot());
		return true;
	}
예제 #7
0
파일: Engine.cpp 프로젝트: Mokon/mfit
  void Engine::getNodes( const pugi::xml_document& cfg,
      const std::string xpath, std::list<std::string>& nodes ) {
    pugi::xpath_node_set xnodes = cfg.select_nodes(xpath.c_str());

    for ( auto xpnode : xnodes ) {
      DLOG(INFO) << xpath << " " <<  xpnode.node().name() << " "
        << xpnode.node().last_child().value() << std::endl ;

      std::string ret(xpnode.node().last_child().value());
      if( ret.size( ) == 0 ) {
        throw StatMissingException( "xpath [" + xpath + "] returns no value." ) ;
      }
      nodes.push_back( ret ) ;
    }
  }
예제 #8
0
pugi::xml_node appendValue(pugi::xml_document & doc, string tag, string attribute, string newValue){

    if (!doesTagAndAttributeExist(doc, tag, attribute, newValue)){
        // otherwise, add it please:
        char xpathExpression[1024];
        sprintf(xpathExpression, "//%s[@%s]", tag.c_str(), attribute.c_str());
        pugi::xpath_node_set add = doc.select_nodes(xpathExpression);
        pugi::xml_node node = add[add.size()-1].node();
        pugi::xml_node nodeAdded = node.parent().append_copy(node);
        nodeAdded.attribute(attribute.c_str()).set_value(newValue.c_str());
        return nodeAdded;
    }else{
    	return pugi::xml_node();
    }

}
예제 #9
0
파일: task.cpp 프로젝트: hermixy/qtplatz
bool
iTask::setConfiguration( const pugi::xml_document& dom )
{
    status_current_ = status_being_ = ControlServer::eNotConfigured;

    pugi::xpath_node_set set = dom.select_nodes( "//Configuration[@name='InstrumentConfiguration']/Configuration" );
    if ( set.size() > 0 ) {
        for ( const pugi::xpath_node& node : set ) {
            adportable::Configuration child;

			for ( const auto& att: node.node().attributes() )
				child.attribute( att.name(), att.value() );

			child.xml( pugi::helper::to_string( node.node() ) );

            config_.append( child );

        }
        return true;
    }
    return false;
}
예제 #10
0
void Column::init(const pugi::xml_document &doc, const std::string &alias, bool aggregate) throw(std::invalid_argument)
{
	this->format = NULL;
	this->parse = NULL;

	/* search xml for an alias */
	pugi::xpath_node column = doc.select_single_node(("/configuration/columns/column[alias='"+alias+"']").c_str());
	/* check what we found */
	if (column == NULL) {
		throw std::invalid_argument(std::string("Column '") + alias + "' not defined");
	}

	/* set default value */
	if (column.node().child("default-value") != NULL) {
		this->nullStr = column.node().child_value("default-value");
	}

	this->setName(column.node().child_value("name"));
	this->setAggregation(aggregate);

#ifdef DEBUG
	std::cerr << "Creating column '" << this->name << "'" << std::endl;
#endif

	/* set alignment */
	if (column.node().child("alignLeft") != NULL) {
		this->setAlignLeft(true);
	}

	/* set width */
	if (column.node().child("width") != NULL) {
		this->setWidth(atoi(column.node().child_value("width")));
	}

	/* set value according to type */
	if (column.node().child("value").attribute("type").value() == std::string("plain")) {
		/* simple element */
		this->setAST(createValueElement(column.node().child("value").child("element"), doc));
	} else if (column.node().child("value").attribute("type").value() == std::string("operation")) {
		/* operation */
		this->setAST(createOperationElement(column.node().child("value").child("operation"), doc));
	}

	/* add aliases from XML to column (with starting %) */
	pugi::xpath_node_set aliases = column.node().select_nodes("alias");
	for (pugi::xpath_node_set::const_iterator it = aliases.begin(); it != aliases.end(); ++it) {
		this->addAlias(it->node().child_value());
	}

	/* element is name of the file, which contains actual data for this column */
	if (column.node().child("value").child("element") != 0) {
		this->element = column.node().child("value").child_value("element");
	}

	/* check whether this is a summary column */
	pugi::xpath_node_set sumColumns = doc.select_nodes("/configuration/summary/column");
	for (stringSet::const_iterator it = this->aliases.begin(); it != this->aliases.end(); it++) {
		for (pugi::xpath_node_set::const_iterator i = sumColumns.begin(); i != sumColumns.end(); ++i) {
			if (*it == i->node().child_value()) {
				this->summary = true;
			
				if (!i->node().attribute("type")) {
					throw std::invalid_argument("Summary column '" + alias + "' without specified summary type!");
				}

				this->summaryType = i->node().attribute("type").value();
			}
		}
	}
	
	/* set alias for select clause */
	if (this->getSemantics() == "flows") {
		this->selectName = "flows";
	} else if (this->isOperation()) {
		this->selectName = alias.substr(1);
	} else {
		this->selectName = this->element;
	}
}
void setExpRuleMadrid(pugi::xml_document & doc, int lu_index, int function_index, double I, double a, double b)
{
    std::string xpath_query =
        "/GeonamicaSimulation/model/modelBlocks/modelBlock[@library=\"\" and @name=\"MB_Land_use_model\"]/CompositeModelBlock/modelBlocks/modelBlock[@name=\"MB_Rules\"]/RulesBlock/Rules/value/vector/elem[" +
            std::to_string(function_index) + "]/vector/elem[" + std::to_string(lu_index) + "]/spline";
    pugi::xpath_node_set nodes = doc.select_nodes(xpath_query.c_str());
    pugi::xml_node parentNode = nodes.begin()->parent();
    for (pugi::xpath_node_set::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
        pugi::xpath_node node = *it;
        parentNode.remove_child(node.node());
    }
    pugi::xml_node new_parent = parentNode.append_child("spline");
    addPointElementMadrid(new_parent, 0, I);

//            // Calculate exponential decay values
    double y1 = a * exp(-b * 1);
    double y2 = a * exp(-b * 2);
    double y3 = a * exp(-b * 3);
    double y4 = a * exp(-b * 4);
    double y5 = a * exp(-b * 5);
    double y6 = a * exp(-b * 6);
    double y7 = a * exp(-b * 7);
    // double //y8=a*exp(-b*8);
    // Calculate absolute values of exponential decay
    double z1 = std::abs(y1);
    double z2 = std::abs(y2);
    double z3 = std::abs(y3);
    double z4 = std::abs(y4);
    double z5 = std::abs(y5);
    double z6 = std::abs(y6);
    double z7 = std::abs(y7);

    double default_y = 0.0;
    if (z1 > 0.0001) {
        addPointElementMadrid(new_parent, 1, y1);
    } else {
        addPointElementMadrid(new_parent, 1, default_y);
    }
    if (z2 > 0.0001) {
        addPointElementMadrid(new_parent, 2, y2);
    } else {
        addPointElementMadrid(new_parent, 2, default_y);
    }
    if (z3 > 0.0001) {
        addPointElementMadrid(new_parent, 3, (y3));
    } else {
        addPointElementMadrid(new_parent, 3, default_y);
    }
    // Add
    if (z4 > 0.0001) {
        addPointElementMadrid(new_parent, 4, (y4));
    } else {
        addPointElementMadrid(new_parent, 4, default_y);
    }
    if (z5 > 0.0001) {
        addPointElementMadrid(new_parent, 5, (y5));
    } else {
        addPointElementMadrid(new_parent, 5, default_y);
    }
    if (z6 > 0.0001) {
        addPointElementMadrid(new_parent, 6, (y6));
    } else {
        addPointElementMadrid(new_parent, 6, default_y);
    }
    if (z7 > 0.0001) {
        addPointElementMadrid(new_parent, 7, (y7));
    } else {
        addPointElementMadrid(new_parent, 7, default_y);
    }
    addPointElementMadrid(new_parent, 8, default_y);

}