/*! \mainpage XStream C++ flexible stream library
*
* \section intro_sec Introduction
*
* This library is supposed to help the developer's work by making easy doing the following things using C++'s standard iostream/streambuf architecture:
*
* \arg Compressing and decompressing data using \c zlib and \c bzlib
* \arg Encode and decode \c base64 data
* \arg Serialize and deserialize structures to \c XDR
* \arg Calculate \c digests of data
* \arg Fork data written to a stream to several others
* \arg Use file descriptors using a iostream interface (where available)
*
* All this by just creating some new \c streambufs (and \c iostream like classes for the \c xdr operations) that can be coupled to any C++ standard \c iostream, like \c cin, \c ifstream, \c ofstream, \c stringstream, or any others defined by this library or the user.
*
* \section prereq Pre-requisites
*
* \arg \c zlib for gzip deflate/inflate compression (gzip compression currently not supported, only decompression), \c adler32 and \c crc32 digests
* \arg \c bz2lib for bzip2 compression and decompressing
* \arg modern c++ compiler and a compliant io library (g++ >= 3.3 should be enough)
* \arg \c POSIX system for file descriptor classes
*
* \section Usage
*
* \note unless written otherwise, all this section is supposed to be using the \c std namespace.
*
* If you're in a hurry you should check the examples directory.
* There you will find simple examples of almost all the library's functionalities.
* The test directory also contains some more examples on how to use the library.
*
*
* \subsection philosophy Philosophy
*
* \c C++ standard io facilites are \c istreams, \c ostreams and \c iostreams.
* \c cin is an \c istream (used for input) \c cout is an \c ostream (use for output) and an \c fstream openned for both reading and writting is an \c iostream (allows for both input and output)
*
* \c iostreams by themselfs don't read or write any data to any files, or input/output "channels" (standard input/output/error), instead they delegate all these tasks to \c streambufs.
* These are responsible for buffering data that iostreams ask them to read/write and actually manage the "physical" reading/writting as well as seeking, flushing, closing and whatever low-level work necessary.
*
* Every \c ios object has a \c streambuf member used for reading/writting, this can be reached via the rdbuf() method, so:
*
* \code
* streambuf* buf = cin.rdbuf();
* \endcode
*
* retireves the \c streambuf that \c cin uses to read data. It's also possible to change the \c streambuf of an \c ios object by using the same method with the new \c streambuf* as an argument. So,
*
* \code
* //buf is a streambuf* initialized before
* cin.rdbuf(buf);
* \endcode
*
* now makes \c cin use \c buf for reading data, so you can do a kind of standard input redirection from within C++. From now onward, when you write \code cin>>var; \endcode you read \c var from data suplied by \c buf and not standard input.
*
*
* Understanding this is crucial to using this library and grasping it's goal.
*
* \subsection what What does XStream do?
*
* \c XStream gives you some new \c streambuf objects (they inherit from \c streambuf) that perform some kind of filtering operation or redirect data to another \c streambuf. In essence this allows to stack several filters and use \c iostreams to acess data after several transforms. For example, suppose you want to read data from a file whose content is several lines of numbers \c base64 encoded, you could simply proceed like this:
*
* \code
#include
//to open the file for reading
#include
//xstream base64 classes
#include
using namespace std;
using namespace xstream;
int main(int argc, char* argv[]){
ifstream file("base64_encoded_file");
//this creates a xstream base64 input streambuf b64sb
//this reads data from the streambuf of file
base64::istreambuf b64sb(file.rdbuf());
//now create a usual istream that reads data from the base64 streambuf
istream decoded(&b64sb);
//read decoded data
while(decoded.good()){
int i;
decoded>>i;
cout<