C++ Boost

Serialization

A Simple Logging Archive Class


The purpose of this example help clarify the usage of the Archive Concept so that one can implement his own archive classes. simple_log_archive.hpp implements a simple but useful archive class. This class can be used to send any serializable types on an output text stream in a readable format. Usage of this facility is trivially easy:

#include "simple_log_archive.hpp"
...
// display the complete schedule
simple_log_archive log(std::cout);
log << schedule;
and it produces the following output

schedule 
 count 6
 item 
  first 
   driver bob
   hour 6
   minute 24
  second -> 
   stops 
    count 3
    item -> 
     latitude 
      degrees 34
      minutes 135
      seconds 52.56
     longitude 
      degrees 134
      minutes 22
      seconds 78.3
...
The complete example is demo_simple_log.cpp. Look at Trivial Archive to get a better understanding of how this works. Also, note the following:

© Copyright Robert Ramey 2002-2010. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)