Made the requirement of gzip and boost_iostream only mandatory...

...if the game is compiled. It doesn't work properly yet since the
boost detection hasn't been added yet, once done it will work
properly.
This commit is contained in:
Mark de Wever 2007-12-05 19:20:14 +00:00
parent 22ad729bcc
commit 085a6a1ef6
5 changed files with 39 additions and 1 deletions

View file

@ -878,7 +878,21 @@ fi
# FIXME do a check
LIBS="$LIBS -lboost_iostreams"
# test for gzip
gzip_found="yes"
# When gzip and boost are found they are used everywhere. They are
# mandatory for the game, so bail out if not found.
if test "x$gzip_found" = "xyes"
then
CPPFLAGS="$CPPFLAGS -DUSE_GZIP"
LIBS="$LIBS -lboost_iostreams"
else
if test "x$game" = "xyes"
then
AC_MSG_ERROR([*** Missing gzip or boost_iostreams support.])
fi
fi
#######################################################################
# Tune gettext stuff for our needs #

View file

@ -24,10 +24,13 @@
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
#include <cassert> // used when USE_GZIP is false
#include <sstream>
#ifdef USE_GZIP
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#endif
bool detect_format_and_read(config &cfg, std::istream &in, std::string* error_log)
{
@ -51,15 +54,25 @@ void write_possibly_compressed(std::ostream &out, config &cfg, bool compress)
config_writer::config_writer(
std::ostream &out, bool compress, const std::string &textdomain) :
#ifdef USE_GZIP
filter_(),
out_(compress ? filter_ : out),
#else
out_(out),
#endif
compress_(compress),
level_(0),
textdomain_(textdomain)
{
if(compress_) {
#ifdef USE_GZIP
filter_.push(boost::iostreams::gzip_compressor());
filter_.push(out);
#else
// it can't hurt to use the compress option here but
// it does nothing.
assert(false);
#endif
}
}

View file

@ -22,7 +22,9 @@
#include <iosfwd>
#include <string>
#ifdef USE_GZIP
#include <boost/iostreams/filtering_stream.hpp>
#endif
class config;
@ -49,7 +51,9 @@ public:
bool good() const;
private:
#ifdef USE_GZIP
boost::iostreams::filtering_stream<boost::iostreams::output> filter_;
#endif
std::ostream &out_;
bool compress_;

View file

@ -36,9 +36,11 @@
#include <sstream>
#include <stack>
#ifdef USE_GZIP
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#endif
#define ERR_CF LOG_STREAM(err, config)
#define WRN_CF LOG_STREAM(warn, config)
@ -351,6 +353,7 @@ void read(config &cfg, std::string &in, std::string* error_log)
parser(cfg, in)(error_log);
}
#ifdef USE_GZIP
void read_gz(config &cfg, std::istream &file, std::string* error_log)
{
@ -360,6 +363,7 @@ void read_gz(config &cfg, std::istream &file, std::string* error_log)
parser(cfg, filter)(error_log);
}
#endif
static char const *AttributeEquals = "=";

View file

@ -30,7 +30,10 @@ class t_string;
// Read data in, clobbering existing data.
void read(config &cfg, std::istream &in, std::string* error_log = NULL); // Throws config::error
void read(config &cfg, std::string &in, std::string* error_log = NULL); // Throws config::error
#ifdef USE_GZIP
void read_gz(config &cfg, std::istream &in, std::string* error_log=NULL);
#endif
void write(std::ostream &out, config const &cfg, unsigned int level=0);
void write_key_val(std::ostream &out, const std::string &key, const t_string &value, unsigned int level, std::string &textdomain);