void XmlMapHandler::Save(std::ostream& file, const Map& map) { wxXmlNode* root = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "Map"); const Tileset& tileset = map.GetTileset(); const std::vector<AnimatedTile>& animated_tiles = tileset.GetAnimatedTiles(); if (map.HasCollisionLayer()) WriteCollision(root, map); for (const auto& tile : animated_tiles) WriteAnimation(root, map, tile); for (const auto& background : map.GetBackgrounds()) WriteBackground(root, map, background); for (const auto& layer : map.GetLayers()) WriteLayer(root, map, layer); WriteProperties(root, map); wxXmlDocument* doc = new wxXmlDocument(); doc->SetRoot(root); wxOutputStream* fos = new wxFOutputStream(file); if (!doc->Save(*fos)) throw "Failed to save XML file"; delete fos; }
void SubversionLocalProperties::WriteProperty(const wxString& name, const wxString& val) { ReadProperties(); GroupTable::iterator iter = m_values.find(m_url); if(iter == m_values.end()) { SimpleTable tb; tb[name] = val; m_values[m_url] = tb; } else { m_values[m_url][name] = val; } // Update the properties WriteProperties(); }
int main(int argc, char **argv) { const char* properties_filename = nsnull; PLOptState* optstate = PL_CreateOptState(argc, argv, "p:"); while (PL_GetNextOpt(optstate) == PL_OPT_OK) { switch (optstate->option) { case 'p': // output properties file properties_filename = optstate->value; break; case '?': print_help(); exit(1); break; } } PL_DestroyOptState(optstate); NS_InitXPCOM2(nsnull, nsnull, nsnull); nsCOMPtr <nsIChromeRegistry> chromeReg = do_GetService(kChromeRegistryCID); if (!chromeReg) { NS_WARNING("chrome check couldn't get the chrome registry"); return NS_ERROR_FAILURE; } chromeReg->CheckForNewChrome(); // ok, now load the rdf that just got written if (properties_filename) WriteProperties(properties_filename); // release the chrome registry before we shutdown XPCOM chromeReg = 0; NS_ShutdownXPCOM(nsnull); return 0; }