Exemplo n.º 1
0
void iom_file::writeAttrs(XmlWriter &out, IomObject &obj)
{
	tagv_type::iterator tag=tagList.find(obj->getTag());
	// class not found?
	if(tag==tagList.end()){
		std::string msg="unknown type <";
		msg+=+obj->getTag_c();
		msg+=">";
		iom_issueerr(msg.c_str());
		// write all attributes
		for(int attri=0;attri<obj->getAttrCount();attri++){
			int attr=obj->getAttrName(attri);
			writeAttr(out, obj,attr);
		}
	}else{
		// class found
		attrv_type attrv=tag->second;
		for(attrv_type::size_type attri=0;attri<attrv.size();attri++){
			int attr=attrv[attri].second;
			writeAttr(out, obj,attr);
		}
	}
}
Exemplo n.º 2
0
bool
BinaryFormatter::writeXMLHeader(std::ostream& into,
                                const std::string& rootElement,
                                const std::map<SumoXMLAttr, std::string>& attrs) {
    if (myXMLStack.empty()) {
        writeStaticHeader(into);
        writeStringList(into, std::vector<std::string>());
        writeStringList(into, std::vector<std::string>());
        if (SUMOXMLDefinitions::Tags.hasString(rootElement)) {
            openTag(into, rootElement);
            for (std::map<SumoXMLAttr, std::string>::const_iterator it = attrs.begin(); it != attrs.end(); ++it) {
                writeAttr(into, it->first, it->second);
            }
            return true;
        }
    }
    return false;
}
Exemplo n.º 3
0
    void Configuration::save() const {
        FILE* file = fopen(FILENAME.c_str(), "w");
        if (!file) {
            throw ConfigurationError("Error opening " + FILENAME);
        }

        fprintf(file, "<server-configuration>\n");
        writeAttr(file, "serverPort", serverPort);
        writeAttr(file, "shouldStartServer", shouldStartServer);
        writeAttr(file, "windowPositionX", windowPosition.x);
        writeAttr(file, "windowPositionY", windowPosition.y);
        writeAttr(file, "windowSizeWidth", windowSize.GetWidth());
        writeAttr(file, "windowSizeHeight", windowSize.GetHeight());
        writeAttr(file, "map", map);
        fprintf(file, "</server-configuration>\n");

        fclose(file);
    }