[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src Makefile.am game.cpp gamestatus.cpp...
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src Makefile.am game.cpp gamestatus.cpp... |
Date: |
Fri, 25 Mar 2005 14:48:49 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/03/25 19:48:48
Modified files:
src : Makefile.am game.cpp gamestatus.cpp
src/serialization: binary_or_text.cpp parser.hpp
Added files:
src/serialization: binary_or_text.hpp
Log message:
Add a writer for (un)compressed files. Now that detect_format_and_read
is no more the only function able to deal with both binary and text formats,
create a header file.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/Makefile.am.diff?tr1=1.86&tr2=1.87&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.217&tr2=1.218&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.64&tr2=1.65&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.hpp?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/parser.hpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: wesnoth/src/Makefile.am
diff -u wesnoth/src/Makefile.am:1.86 wesnoth/src/Makefile.am:1.87
--- wesnoth/src/Makefile.am:1.86 Tue Mar 22 22:09:27 2005
+++ wesnoth/src/Makefile.am Fri Mar 25 19:48:48 2005
@@ -195,6 +195,7 @@
variable.hpp \
video.hpp \
wassert.hpp \
+ serialization/binary_or_text.hpp \
serialization/binary_wml.hpp \
serialization/parser.hpp \
serialization/preprocessor.hpp \
@@ -362,6 +363,7 @@
unit_display.hpp \
unit_types.hpp \
video.hpp \
+ serialization/binary_or_text.hpp \
serialization/binary_wml.hpp \
serialization/parser.hpp \
serialization/preprocessor.hpp \
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.217 wesnoth/src/game.cpp:1.218
--- wesnoth/src/game.cpp:1.217 Fri Mar 25 19:35:27 2005
+++ wesnoth/src/game.cpp Fri Mar 25 19:48:48 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.217 2005/03/25 19:35:27 silene Exp $ */
+/* $Id: game.cpp,v 1.218 2005/03/25 19:48:48 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -54,6 +54,7 @@
#include "video.hpp"
#include "wassert.hpp"
#include "wml_separators.hpp"
+#include "serialization/binary_or_text.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
@@ -1545,14 +1546,7 @@
return 0;
}
- std::string res;
- if (compress) {
- std::ostringstream savefile;
- write_compressed(savefile, cfg);
- res = savefile.str();
- } else res = write(cfg);
- write_file(output, res);
-
+ write_possibly_compressed(output, 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.64 wesnoth/src/gamestatus.cpp:1.65
--- wesnoth/src/gamestatus.cpp:1.64 Fri Mar 25 19:35:27 2005
+++ wesnoth/src/gamestatus.cpp Fri Mar 25 19:48:48 2005
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.64 2005/03/25 19:35:27 silene Exp $ */
+/* $Id: gamestatus.cpp,v 1.65 2005/03/25 19:48:48 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -22,6 +22,7 @@
#include "preferences.hpp"
#include "statistics.hpp"
#include "util.hpp"
+#include "serialization/binary_or_text.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
#include "serialization/string_utils.hpp"
@@ -454,14 +455,7 @@
write_game(state,cfg);
const std::string fname = get_saves_dir() + "/" + name;
-
- std::string savefile;
- if (preferences::compress_saves()) {
- std::ostringstream stream;
- write_compressed(stream, cfg);
- savefile = stream.str();
- } else savefile = write(cfg);
- write_file(fname, savefile);
+ write_possibly_compressed(fname, cfg,
preferences::compress_saves());
config& summary = save_summary(state.label);
extract_summary_data_from_save(state,summary);
Index: wesnoth/src/serialization/binary_or_text.cpp
diff -u wesnoth/src/serialization/binary_or_text.cpp:1.3
wesnoth/src/serialization/binary_or_text.cpp:1.4
--- wesnoth/src/serialization/binary_or_text.cpp:1.3 Fri Mar 25 18:19:20 2005
+++ wesnoth/src/serialization/binary_or_text.cpp Fri Mar 25 19:48:48 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.cpp,v 1.3 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: binary_or_text.cpp,v 1.4 2005/03/25 19:48:48 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -13,9 +13,12 @@
*/
#include "config.hpp"
+#include "filesystem.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
+#include <sstream>
+
bool detect_format_and_read(config &cfg, std::istream &in)
{
try {
@@ -27,3 +30,15 @@
read(cfg, in);
return false;
}
+
+void write_possibly_compressed(std::string const &filename, 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);
+}
Index: wesnoth/src/serialization/parser.hpp
diff -u wesnoth/src/serialization/parser.hpp:1.3
wesnoth/src/serialization/parser.hpp:1.4
--- wesnoth/src/serialization/parser.hpp:1.3 Fri Mar 25 18:19:20 2005
+++ wesnoth/src/serialization/parser.hpp Fri Mar 25 19:48:48 2005
@@ -1,4 +1,4 @@
-/* $Id: parser.hpp,v 1.3 2005/03/25 18:19:20 silene Exp $ */
+/* $Id: parser.hpp,v 1.4 2005/03/25 19:48:48 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -27,9 +27,4 @@
std::string write(config const &cfg);
-//function which reads a file, and automatically detects whether it's
compressed or not before
-//reading it. If it's not a valid file at all, it will throw an error as if it
was trying to
-//read it as text WML. Returns true iff the format is compressed
-bool detect_format_and_read(config &cfg, std::istream &in); //throws
config::error
-
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src Makefile.am game.cpp gamestatus.cpp...,
Guillaume Melquiond <=