binary_wml.cpp File Reference

Data compression, designed for network traffic. More...

#include "global.hpp"
#include "config.hpp"
#include "loadscreen.hpp"
#include "log.hpp"
#include "serialization/binary_wml.hpp"
#include <algorithm>
#include <iostream>
#include <sstream>

Include dependency graph for binary_wml.cpp:

Go to the source code of this file.

Defines

#define ERR_CF   LOG_STREAM(err, config)

Functions

static void compress_output_literal_word (std::ostream &out, std::string const &word)
static
compression_schema::word_char_map::const_iterator 
add_word_to_schema (std::string const &word, compression_schema &schema)
static
compression_schema::word_char_map::const_iterator 
get_word_in_schema (std::string const &word, compression_schema &schema, std::ostream &out)
static void compress_emit_word (std::ostream &out, std::string const &word, compression_schema &schema)
static std::string compress_read_literal_word (std::istream &in)
static void write_compressed_internal (std::ostream &out, config const &cfg, compression_schema &schema, int level)
void write_compressed (std::ostream &out, config const &cfg, compression_schema &schema)
 Write compressed data.
static void read_compressed_internal (config &cfg, std::istream &in, compression_schema &schema, int level)
void read_compressed (config &cfg, std::istream &in, compression_schema &schema)
 Read compressed data.
void write_compressed (std::ostream &out, config const &cfg)
void read_compressed (config &cfg, std::istream &in)

Variables

static const unsigned int compress_open_element = 0
static const unsigned int compress_close_element = 1
static const unsigned int compress_schema_item = 2
static const unsigned int compress_literal_word = 3
static const unsigned int compress_first_word = 4
static const unsigned int compress_end_words = 256
static const size_t compress_max_words = compress_end_words - compress_first_word
static const size_t max_schema_item_length = 20
static const int max_recursion_levels = 1000


Detailed Description

Data compression, designed for network traffic.

Definition in file binary_wml.cpp.


Define Documentation

#define ERR_CF   LOG_STREAM(err, config)

Definition at line 30 of file binary_wml.cpp.


Function Documentation

static compression_schema::word_char_map::const_iterator add_word_to_schema ( std::string const &  word,
compression_schema schema 
) [static]

static void compress_emit_word ( std::ostream &  out,
std::string const &  word,
compression_schema schema 
) [static]

static void compress_output_literal_word ( std::ostream &  out,
std::string const &  word 
) [static]

static std::string compress_read_literal_word ( std::istream &  in  )  [static]

Definition at line 120 of file binary_wml.cpp.

Referenced by read_compressed_internal().

static compression_schema::word_char_map::const_iterator get_word_in_schema ( std::string const &  word,
compression_schema schema,
std::ostream &  out 
) [static]

void read_compressed ( config cfg,
std::istream &  in 
)

Definition at line 226 of file binary_wml.cpp.

References read_compressed().

void read_compressed ( config cfg,
std::istream &  in,
compression_schema schema 
)

Read compressed data.

Definition at line 215 of file binary_wml.cpp.

References config::clear(), and read_compressed_internal().

Referenced by check_python_scripts(), detect_format_and_read(), process_queue(), and read_compressed().

static void read_compressed_internal ( config cfg,
std::istream &  in,
compression_schema schema,
int  level 
) [static]

void write_compressed ( std::ostream &  out,
config const &  cfg 
)

Definition at line 221 of file binary_wml.cpp.

References write_compressed().

void write_compressed ( std::ostream &  out,
config const &  cfg,
compression_schema schema 
)

Write compressed data.

The schema will be created and written with the data. However if you are making successive writes (e.g. a network connection), you can re-use the same schema on the sending end, and the receiver can store the schema, meaning that the entire schema won't have to be transmitted each time.

Definition at line 156 of file binary_wml.cpp.

References write_compressed_internal().

Referenced by output_to_buffer(), write_compressed(), write_possibly_compressed(), and write_save_index().

static void write_compressed_internal ( std::ostream &  out,
config const &  cfg,
compression_schema schema,
int  level 
) [static]


Variable Documentation

const unsigned int compress_close_element = 1 [static]

Definition at line 57 of file binary_wml.cpp.

Referenced by read_compressed_internal(), and write_compressed_internal().

const unsigned int compress_end_words = 256 [static]

Definition at line 59 of file binary_wml.cpp.

const unsigned int compress_first_word = 4 [static]

Definition at line 59 of file binary_wml.cpp.

Referenced by add_word_to_schema().

const unsigned int compress_literal_word = 3 [static]

Definition at line 58 of file binary_wml.cpp.

Referenced by compress_emit_word(), and read_compressed_internal().

Definition at line 60 of file binary_wml.cpp.

Referenced by get_word_in_schema().

const unsigned int compress_open_element = 0 [static]

Definition at line 57 of file binary_wml.cpp.

Referenced by read_compressed_internal(), and write_compressed_internal().

const unsigned int compress_schema_item = 2 [static]

Definition at line 58 of file binary_wml.cpp.

Referenced by get_word_in_schema(), and read_compressed_internal().

const int max_recursion_levels = 1000 [static]

const size_t max_schema_item_length = 20 [static]

Definition at line 61 of file binary_wml.cpp.

Referenced by add_word_to_schema(), and get_word_in_schema().


Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs