serialization/binary_or_text.hpp

Go to the documentation of this file.
00001 /* $Id: binary_or_text.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 by David White <dave@whitevine.net>
00004    Copyright (C) 2005 - 2012 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 as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY.
00013 
00014    See the COPYING file for more details.
00015 */
00016 
00017 /** @file */
00018 
00019 #ifndef SERIALIZATION_BINARY_OR_TEXT_HPP_INCLUDED
00020 #define SERIALIZATION_BINARY_OR_TEXT_HPP_INCLUDED
00021 
00022 #include "preprocessor.hpp"
00023 
00024 #include <boost/iostreams/filtering_stream.hpp>
00025 
00026 class config;
00027 
00028 /** Class for writing a config out to a file in pieces. */
00029 class config_writer
00030 {
00031 public:
00032     config_writer(std::ostream &out, bool compress, int level = -1);
00033     /** Default implementation, but defined out-of-line for efficiency reasons. */
00034     ~config_writer();
00035 
00036     void write(const config &cfg);
00037 
00038     void write_child(const std::string &key, const config &cfg);
00039     void write_key_val(const std::string &key, const std::string &value);
00040     void open_child(const std::string &key);
00041     void close_child(const std::string &key);
00042     bool good() const;
00043 
00044 private:
00045     boost::iostreams::filtering_stream<boost::iostreams::output> filter_;
00046     std::ostream *out_ptr_;
00047     std::ostream &out_;
00048     bool compress_;
00049     unsigned int level_;
00050     std::string textdomain_;
00051 };
00052 
00053 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Wed May 23 2012 01:02:55 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs