00001 /* $Id: binary_wml.hpp 23842 2008-02-16 08:47:16Z mordante $ */ 00002 /* 00003 Copyright (C) 2003 by David White <dave@whitevine.net> 00004 Copyright (C) 2005 - 2008 by Guillaume Melquiond <guillaume.melquiond@gmail.com> 00005 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License version 2 00009 or at your option any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 00017 #ifndef SERIALIZATION_BINARY_WML_HPP_INCLUDED 00018 #define SERIALIZATION_BINARY_WML_HPP_INCLUDED 00019 00020 #include <iosfwd> 00021 #include <map> 00022 #include <string> 00023 00024 class config; 00025 00026 //! Holds the schema by which config objects can be compressed and decompressed. 00027 struct compression_schema 00028 { 00029 compression_schema() : char_to_word(), word_to_char() { } 00030 00031 typedef std::map< unsigned int, std::string > char_word_map; 00032 char_word_map char_to_word; 00033 00034 typedef std::map< std::string, unsigned int > word_char_map; 00035 word_char_map word_to_char; 00036 }; 00037 00038 // Read and write compressed data. 00039 00040 //! Write compressed data. 00041 //! The schema will be created and written with the data. 00042 //! However if you are making successive writes (e.g. a network connection), 00043 //! you can re-use the same schema on the sending end, and the receiver can store 00044 //! the schema, meaning that the entire schema won't have to be transmitted each time. 00045 void write_compressed(std::ostream &out, config const &cfg, compression_schema &schema); 00046 //! Read compressed data. 00047 void read_compressed(config &cfg, std::istream &in, compression_schema &schema); //throws config::error 00048 00049 void write_compressed(std::ostream &out, config const &cfg); 00050 void read_compressed(config &cfg, std::istream &in); 00051 00052 #endif
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |