Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Serialization - Derivation from an Existing Archive

Boost , ,

C++ Boost

Serialization

A Simple Logging Archive Class


The purpose of this example is to 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:
  • Only 160 lines of code.
  • Header only - linking with the serialization library not required.
  • Displays ALL Serializable types.
  • Lacks some features.
    • it will not display the data from the derived type given the pointer to a polymorphic base class. That is, only displays the information of the base class. To add that see the next example.
    • doesn't display information serialized as binary data

© Авторское правоРоберт Рэми2002-2010. Распространяется под лицензией Boost Software License, версия 1.0. (См. сопроводительный файл LICENSE_1_0.txt или копию по адресу http://www.boost.org/LICENSE_1_0.txt)

Статья Serialization - Derivation from an Existing Archive раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-20 22:06:09/0.0054681301116943/0