wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src filesystem.cpp filesystem.hpp game....


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src filesystem.cpp filesystem.hpp game....
Date: Sat, 26 Mar 2005 09:07:18 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/03/26 14:07:18

Modified files:
        src            : filesystem.cpp filesystem.hpp game.cpp 
                         gamestatus.cpp help.cpp preferences.cpp 
                         publish_campaign.cpp 
        src/campaign_server: campaign_server.cpp 
        src/editor     : editor.cpp 
        src/serialization: binary_or_text.cpp binary_or_text.hpp 
                           parser.cpp parser.hpp preprocessor.cpp 

Log message:
        Switch to streaming output files too.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/filesystem.cpp.diff?tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/filesystem.hpp.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.218&tr2=1.219&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/help.cpp.diff?tr1=1.83&tr2=1.84&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.cpp.diff?tr1=1.146&tr2=1.147&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/publish_campaign.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/campaign_server/campaign_server.cpp.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor.cpp.diff?tr1=1.100&tr2=1.101&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.hpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/parser.cpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/parser.hpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/preprocessor.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: wesnoth/src/campaign_server/campaign_server.cpp
diff -u wesnoth/src/campaign_server/campaign_server.cpp:1.13 
wesnoth/src/campaign_server/campaign_server.cpp:1.14
--- wesnoth/src/campaign_server/campaign_server.cpp:1.13        Fri Mar 25 
19:35:27 2005
+++ wesnoth/src/campaign_server/campaign_server.cpp     Sat Mar 26 14:07:18 2005
@@ -44,7 +44,7 @@
 
 int campaign_server::load_config()
 {
-       scoped_istream stream = stream_file(file_);
+       scoped_istream stream = istream_file(file_);
        read(cfg_, *stream);
        return lexical_cast_default<int>(cfg_["port"], 15002);
 }
@@ -63,7 +63,8 @@
                try {
                        //write config to disk every ten minutes
                        if((increment%(60*10*2)) == 0) {
-                               write_file(file_, write(cfg_));
+                               scoped_ostream cfgfile = ostream_file(file_);
+                               write(*cfgfile, cfg_);
                        }
 
                        network::process_send_queue();
@@ -91,7 +92,7 @@
                                                
network::send_data(construct_error("Campaign not found."),sock);
                                        } else {
                                                config cfg;
-                                               scoped_istream stream = 
stream_file((*campaign)["filename"]);
+                                               scoped_istream stream = 
istream_file((*campaign)["filename"]);
                                                read_compressed(cfg, *stream);
                                                network::queue_data(cfg,sock);
 
@@ -127,13 +128,17 @@
 
                                                const config* const data = 
upload->child("data");
                                                if(data != NULL) {
-                                                       std::ostringstream 
filedata;
-                                                       
write_compressed(filedata, *data);
-                                                       
write_file((*campaign)["filename"], filedata.str());
-                                                       (*campaign)["size"] = 
lexical_cast<std::string>(filedata.str().size());
+                                                       std::string filename = 
(*campaign)["filename"];
+                                                       {
+                                                               scoped_ostream 
campaign_file = ostream_file(filename);
+                                                               
write_compressed(*campaign_file, *data);
+                                                       }
+                                                       (*campaign)["size"] = 
lexical_cast<std::string>(
+                                                               
file_size(filename));
                                                }
 
-                                               write_file(file_, write(cfg_));
+                                               scoped_ostream cfgfile = 
ostream_file(file_);
+                                               write(*cfgfile, cfg_);
                                                
network::send_data(construct_message("Campaign accepted."),sock);
                                        }
                                } else if(const config* erase = 
data.child("delete")) {
@@ -154,7 +159,8 @@
                                        const config::child_list& 
campaigns_list = campaigns().get_children("campaign");
                                        const size_t index = 
std::find(campaigns_list.begin(),campaigns_list.end(),campaign) - 
campaigns_list.begin();
                                        
campaigns().remove_child("campaign",index);
-                                       write_file(file_, write(cfg_));
+                                       scoped_ostream cfgfile = 
ostream_file(file_);
+                                       write(*cfgfile, cfg_);
                                        
network::send_data(construct_message("Campaign erased."),sock);
                                }
                        }
Index: wesnoth/src/editor/editor.cpp
diff -u wesnoth/src/editor/editor.cpp:1.100 wesnoth/src/editor/editor.cpp:1.101
--- wesnoth/src/editor/editor.cpp:1.100 Fri Mar 25 18:19:20 2005
+++ wesnoth/src/editor/editor.cpp       Sat Mar 26 14:07:18 2005
@@ -99,7 +99,7 @@
                // Perform some initializations that should only be performed
                // the first time the editor object is created.
                try {
-                       scoped_istream stream = stream_file(prefs_filename);
+                       scoped_istream stream = istream_file(prefs_filename);
                        read(prefs_, *stream);
                }
                catch (config::error e) {
@@ -136,7 +136,8 @@
        old_bg_terrain_ = palette_.selected_bg_terrain();
        old_brush_size_ = brush_.selected_brush_size();
        try {
-               write_file(prefs_filename, write(prefs_));
+               scoped_ostream prefs_file = ostream_file(prefs_filename);
+               write(*prefs_file, prefs_);
        }
        catch (io_exception& e) {
                std::cerr << "Error when writing to " << prefs_filename << ": "
Index: wesnoth/src/filesystem.cpp
diff -u wesnoth/src/filesystem.cpp:1.63 wesnoth/src/filesystem.cpp:1.64
--- wesnoth/src/filesystem.cpp:1.63     Fri Mar 25 18:19:20 2005
+++ wesnoth/src/filesystem.cpp  Sat Mar 26 14:07:16 2005
@@ -1,4 +1,4 @@
-/* $Id: filesystem.cpp,v 1.63 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: filesystem.cpp,v 1.64 2005/03/26 14:07:16 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -489,9 +489,9 @@
        }
 }
 
-std::istream *stream_file(std::string const &fname)
+std::istream *istream_file(std::string const &fname)
 {
-       LOG_G << "Streaming " << fname << "\n";
+       LOG_G << "Streaming " << fname << " for reading.\n";
 #ifdef USE_ZIPIOS
        if (!fname.empty() && fname[0] != '/') {
                zipios::ConstEntryPointer p = the_collection->getEntry(fname);
@@ -513,6 +513,12 @@
        return new std::ifstream(fname.c_str());
 }
 
+std::ostream *ostream_file(std::string const &fname)
+{
+       LOG_G << "Streaming " << fname << " for writing.\n";
+       return new std::ofstream(fname.c_str(), std::ios_base::binary);
+}
+
 //throws io_exception if an error occurs
 void write_file(const std::string& fname, const std::string& data)
 {
@@ -835,3 +841,14 @@
 {
        delete stream;
 }
+
+void scoped_ostream::operator=(std::ostream *s)
+{
+       delete stream;
+       stream = s;
+}
+
+scoped_ostream::~scoped_ostream()
+{
+       delete stream;
+}
Index: wesnoth/src/filesystem.hpp
diff -u wesnoth/src/filesystem.hpp:1.34 wesnoth/src/filesystem.hpp:1.35
--- wesnoth/src/filesystem.hpp:1.34     Fri Mar 25 18:19:20 2005
+++ wesnoth/src/filesystem.hpp  Sat Mar 26 14:07:16 2005
@@ -1,4 +1,4 @@
-/* $Id: filesystem.hpp,v 1.34 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: filesystem.hpp,v 1.35 2005/03/26 14:07:16 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -59,7 +59,8 @@
 //basic disk I/O
 bool filesystem_init();
 std::string read_file(const std::string& fname);
-std::istream *stream_file(std::string const &fname);
+std::istream *istream_file(std::string const &fname);
+std::ostream *ostream_file(std::string const &fname);
 //throws io_exception if an error occurs
 void write_file(const std::string& fname, const std::string& data);
 std::string read_stdin();
@@ -150,4 +151,14 @@
        ~scoped_istream();
 };
 
+class scoped_ostream {
+       std::ostream *stream;
+public:
+       scoped_ostream(std::ostream *s): stream(s) {}
+       void operator=(std::ostream *);
+       std::ostream &operator*() { return *stream; }
+       std::ostream *operator->() { return stream; }
+       ~scoped_ostream();
+};
+
 #endif
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.218 wesnoth/src/game.cpp:1.219
--- wesnoth/src/game.cpp:1.218  Fri Mar 25 19:48:48 2005
+++ wesnoth/src/game.cpp        Sat Mar 26 14:07:16 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.218 2005/03/25 19:48:48 silene Exp $ */
+/* $Id: game.cpp,v 1.219 2005/03/26 14:07:16 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -94,7 +94,7 @@
                //if the starting state is specified, then use that,
                //otherwise get the scenario data and start from there.
                if(state.starting_pos.empty() == false) {
-                       std::cerr << "loading starting position: '" << 
write(state.starting_pos) << "'\n";
+                       std::cerr << "loading starting position...\n";
                        starting_pos = state.starting_pos;
                        scenario = &starting_pos;
                } else {
@@ -257,7 +257,7 @@
                                        try {
                                                if(file_exists(fname_checksum)) 
{
                                                        config checksum_cfg;
-                                                       scoped_istream stream = 
stream_file(fname_checksum);
+                                                       scoped_istream stream = 
istream_file(fname_checksum);
                                                        read(checksum_cfg, 
*stream);
                                                        dir_checksum = 
file_tree_checksum(checksum_cfg);
                                                }
@@ -272,7 +272,7 @@
                                        std::cerr << "found valid cache at '" 
<< fname << "' using it\n";
                                        log_scope("read cache");
                                        try {
-                                               scoped_istream stream = 
stream_file(fname);
+                                               scoped_istream stream = 
istream_file(fname);
                                                read_compressed(cfg, *stream);
                                                return;
                                        } catch(config::error&) {
@@ -288,14 +288,12 @@
                                scoped_istream stream = 
preprocess_file("data/game.cfg", &defines, &line_src);
                                read(cfg, *stream, &line_src);
                                try {
-                                       std::ostringstream cache;
-                                       write_compressed(cache, cfg);
-                                       write_file(fname, cache.str());
-
+                                       scoped_ostream cache = 
ostream_file(fname);
+                                       write_compressed(*cache, cfg);
                                        config checksum_cfg;
                                        
data_tree_checksum().write(checksum_cfg);
-                                       std::cerr << "wrote checksum: '" << 
write(checksum_cfg) << "'\n";
-                                       write_file(fname_checksum, 
write(checksum_cfg));
+                                       scoped_ostream checksum = 
ostream_file(fname_checksum);
+                                       write(*checksum, checksum_cfg);
                                } catch(io_exception&) {
                                        std::cerr << "could not write to cache 
'" << fname << "'\n";
                                }
@@ -1527,7 +1525,7 @@
                        const std::string input(argv[arg+1]);
                        const std::string output(argv[arg+2]);
 
-                       scoped_istream stream = stream_file(input);
+                       scoped_istream stream = istream_file(input);
                        if (stream->fail()) {
                                std::cerr << "could not read file '" << input 
<< "'\n";
                                return 0;
@@ -1546,7 +1544,8 @@
                                        return 0;
                                }
 
-                               write_possibly_compressed(output, cfg, 
compress);
+                               scoped_ostream output_stream = 
ostream_file(output);
+                               write_possibly_compressed(*output_stream, cfg, 
compress);
                        } catch(config::error& e) {
                                std::cerr << input << " is not a valid Wesnoth 
file: " << e.message << "\n";
                        } catch(io_exception& e) {
Index: wesnoth/src/gamestatus.cpp
diff -u wesnoth/src/gamestatus.cpp:1.65 wesnoth/src/gamestatus.cpp:1.66
--- wesnoth/src/gamestatus.cpp:1.65     Fri Mar 25 19:48:48 2005
+++ wesnoth/src/gamestatus.cpp  Sat Mar 26 14:07:16 2005
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.65 2005/03/25 19:48:48 silene Exp $ */
+/* $Id: gamestatus.cpp,v 1.66 2005/03/26 14:07:16 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -419,9 +419,9 @@
        std::replace(modified_name.begin(),modified_name.end(),' ','_');
 
        //try reading the file both with and without underscores
-       scoped_istream file_stream = stream_file(get_saves_dir() + "/" + 
modified_name);
+       scoped_istream file_stream = istream_file(get_saves_dir() + "/" + 
modified_name);
        if (file_stream->fail())
-               file_stream = stream_file(get_saves_dir() + "/" + name);
+               file_stream = istream_file(get_saves_dir() + "/" + name);
 
        cfg.clear();
        detect_format_and_read(cfg, *file_stream);
@@ -455,7 +455,10 @@
                write_game(state,cfg);
 
                const std::string fname = get_saves_dir() + "/" + name;
-               write_possibly_compressed(fname, cfg, 
preferences::compress_saves());
+               {
+                       scoped_ostream savefile = ostream_file(fname);
+                       write_possibly_compressed(*savefile, cfg, 
preferences::compress_saves());
+               }
 
                config& summary = save_summary(state.label);
                extract_summary_data_from_save(state,summary);
@@ -478,7 +481,7 @@
 {
        if(save_index_loaded == false) {
                try {
-                       scoped_istream stream = 
stream_file(get_save_index_file());
+                       scoped_istream stream = 
istream_file(get_save_index_file());
                        detect_format_and_read(save_index_cfg, *stream);
                } catch(io_exception& e) {
                        std::cerr << "error reading save index: '" << e.what() 
<< "'\n";
@@ -520,9 +523,8 @@
 {
        log_scope("write_save_index()");
        try {
-               std::ostringstream index;
-               write_compressed(index, save_index());
-               write_file(get_save_index_file(), index.str());
+               scoped_ostream stream = ostream_file(get_save_index_file());
+               write_compressed(*stream, save_index());
        } catch(io_exception& e) {
                std::cerr << "error writing to save index file: '" << e.what() 
<< "'\n";
        }
Index: wesnoth/src/help.cpp
diff -u wesnoth/src/help.cpp:1.83 wesnoth/src/help.cpp:1.84
--- wesnoth/src/help.cpp:1.83   Fri Mar 25 18:19:20 2005
+++ wesnoth/src/help.cpp        Sat Mar 26 14:07:16 2005
@@ -1733,17 +1733,20 @@
        if (find_topic(toplevel_, dst) == NULL && !force) {
                show_ref = false;
                if (game_config::debug) {
-                       std::string msg = "Reference to non-existent topic '" + 
dst +
-                               "'. Please submit a bug report if you have not 
modified the game files yourself. Errornous config: ";
-                       msg += write(cfg);
-                       throw parse_error(msg);
+                       std::stringstream msg;
+                       msg << "Reference to non-existent topic '" << dst
+                           << "'. Please submit a bug report if you have not"
+                              "modified the game files yourself. Errornous 
config: ";
+                       write(msg, cfg);
+                       throw parse_error(msg.str());
                }
        }
        if (dst == "") {
-               std::string msg = 
-                       "Ref markup must have dst attribute. Please submit a 
bug report if you have not modified the game files yourself. Errornous config: 
";
-               msg += write(cfg);
-               throw parse_error(msg);
+               std::stringstream msg;
+               msg << "Ref markup must have dst attribute. Please submit a bug"
+                      " report if you have not modified the game files 
yourself. Errornous config: ";
+               write(msg, cfg);
+               throw parse_error(msg.str());
        }
        if (show_ref) {
                add_text_item(text, dst);
Index: wesnoth/src/preferences.cpp
diff -u wesnoth/src/preferences.cpp:1.146 wesnoth/src/preferences.cpp:1.147
--- wesnoth/src/preferences.cpp:1.146   Fri Mar 25 18:19:20 2005
+++ wesnoth/src/preferences.cpp Sat Mar 26 14:07:16 2005
@@ -1,4 +1,4 @@
-/* $Id: preferences.cpp,v 1.146 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: preferences.cpp,v 1.147 2005/03/26 14:07:16 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -68,7 +68,7 @@
 
 manager::manager()
 {
-       scoped_istream stream = stream_file(get_prefs_file());
+       scoped_istream stream = istream_file(get_prefs_file());
        read(prefs, *stream);
        set_music_volume(music_volume());
        set_sound_volume(sound_volume());
@@ -98,7 +98,8 @@
        encountered_units_set.clear();
        encountered_terrains_set.clear();
        try {
-               write_file(get_prefs_file(), write(prefs));
+               scoped_ostream prefs_file = ostream_file(get_prefs_file());
+               write(*prefs_file, prefs);
        } catch(io_exception&) {
                std::cerr << "error writing to preferences file '" << 
get_prefs_file() << "'\n";
        }
Index: wesnoth/src/publish_campaign.cpp
diff -u wesnoth/src/publish_campaign.cpp:1.7 
wesnoth/src/publish_campaign.cpp:1.8
--- wesnoth/src/publish_campaign.cpp:1.7        Fri Mar 25 18:19:20 2005
+++ wesnoth/src/publish_campaign.cpp    Sat Mar 26 14:07:16 2005
@@ -26,13 +26,14 @@
 
 void get_campaign_info(const std::string& campaign_name, config& cfg)
 {
-       scoped_istream stream = stream_file(campaign_dir() + "/" + 
campaign_name + ".pbl");
+       scoped_istream stream = istream_file(campaign_dir() + "/" + 
campaign_name + ".pbl");
        read(cfg, *stream);
 }
 
 void set_campaign_info(const std::string& campaign_name, const config& cfg)
 {
-       write_file(campaign_dir() + "/" + campaign_name + ".pbl", write(cfg));
+       scoped_ostream stream = ostream_file(campaign_dir() + "/" + 
campaign_name + ".pbl");
+       write(*stream, cfg);
 }
 
 std::vector<std::string> available_campaigns()
Index: wesnoth/src/serialization/binary_or_text.cpp
diff -u wesnoth/src/serialization/binary_or_text.cpp:1.6 
wesnoth/src/serialization/binary_or_text.cpp:1.7
--- wesnoth/src/serialization/binary_or_text.cpp:1.6    Sat Mar 26 11:11:10 2005
+++ wesnoth/src/serialization/binary_or_text.cpp        Sat Mar 26 14:07:18 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.cpp,v 1.6 2005/03/26 11:11:10 silene Exp $ */
+/* $Id: binary_or_text.cpp,v 1.7 2005/03/26 14:07:18 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -31,14 +31,10 @@
        }
 }
 
-void write_possibly_compressed(std::string const &filename, config &cfg, bool 
compress)
+void write_possibly_compressed(std::ostream &out, config &cfg, bool compress)
 {
-
-       std::string savefile;
-       if (compress) {
-               std::ostringstream stream;
-               write_compressed(stream, cfg);
-               savefile = stream.str();
-       } else savefile = write(cfg);
-       write_file(filename, savefile);
+       if (compress)
+               write_compressed(out, cfg);
+       else
+               write(out, cfg);
 }
Index: wesnoth/src/serialization/binary_or_text.hpp
diff -u wesnoth/src/serialization/binary_or_text.hpp:1.1 
wesnoth/src/serialization/binary_or_text.hpp:1.2
--- wesnoth/src/serialization/binary_or_text.hpp:1.1    Fri Mar 25 19:48:48 2005
+++ wesnoth/src/serialization/binary_or_text.hpp        Sat Mar 26 14:07:18 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.hpp,v 1.1 2005/03/25 19:48:48 silene Exp $ */
+/* $Id: binary_or_text.hpp,v 1.2 2005/03/26 14:07:18 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -25,6 +25,6 @@
 bool detect_format_and_read(config &cfg, std::istream &in); //throws 
config::error
 
 //function which writes a file, compressed or not depending on a flag
-void write_possibly_compressed(std::string const &filename, config &cfg, bool 
compress);
+void write_possibly_compressed(std::ostream &out, config &cfg, bool compress);
 
 #endif
Index: wesnoth/src/serialization/parser.cpp
diff -u wesnoth/src/serialization/parser.cpp:1.6 
wesnoth/src/serialization/parser.cpp:1.7
--- wesnoth/src/serialization/parser.cpp:1.6    Fri Mar 25 18:19:20 2005
+++ wesnoth/src/serialization/parser.cpp        Sat Mar 26 14:07:18 2005
@@ -1,4 +1,4 @@
-/* $Id: parser.cpp,v 1.6 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: parser.cpp,v 1.7 2005/03/26 14:07:18 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -386,9 +386,7 @@
        }
 }
 
-std::string write(config const &cfg)
+void write(std::ostream &out, config const &cfg)
 {
-       std::stringstream res;
-       write_internal(cfg, res);
-       return res.str();
+       write_internal(cfg, out);
 }
Index: wesnoth/src/serialization/parser.hpp
diff -u wesnoth/src/serialization/parser.hpp:1.4 
wesnoth/src/serialization/parser.hpp:1.5
--- wesnoth/src/serialization/parser.hpp:1.4    Fri Mar 25 19:48:48 2005
+++ wesnoth/src/serialization/parser.hpp        Sat Mar 26 14:07:18 2005
@@ -1,4 +1,4 @@
-/* $Id: parser.hpp,v 1.4 2005/03/25 19:48:48 silene Exp $ */
+/* $Id: parser.hpp,v 1.5 2005/03/26 14:07:18 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -25,6 +25,6 @@
 //read data in, clobbering existing data.
 void read(config &cfg, std::istream &in, std::vector< line_source > const 
*lines = 0); //throws config::error
 
-std::string write(config const &cfg);
+void write(std::ostream &out, config const &cfg);
 
 #endif
Index: wesnoth/src/serialization/preprocessor.cpp
diff -u wesnoth/src/serialization/preprocessor.cpp:1.5 
wesnoth/src/serialization/preprocessor.cpp:1.6
--- wesnoth/src/serialization/preprocessor.cpp:1.5      Fri Mar 25 20:38:06 2005
+++ wesnoth/src/serialization/preprocessor.cpp  Sat Mar 26 14:07:18 2005
@@ -1,4 +1,4 @@
-/* $Id: preprocessor.cpp,v 1.5 2005/03/25 20:38:06 silene Exp $ */
+/* $Id: preprocessor.cpp,v 1.6 2005/03/26 14:07:18 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -379,7 +379,7 @@
                lines_src->push_back(line_source(line,fname,1));
        }
 
-       scoped_istream stream = stream_file(fname);
+       scoped_istream stream = istream_file(fname);
        internal_preprocess_data(*stream, defines_map, depth, out, lines_src, 
line, fname, 1);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]