]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/example/demo_trivial_archive.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / example / demo_trivial_archive.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 //
3 // demo_trivial_archive.cpp
4 //
5 // (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
6 // Use, modification and distribution is subject to the Boost Software
7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 #include <cstddef> // std::size_t
11 #include <boost/mpl/bool.hpp>
12
13 /////////////////////////////////////////////////////////////////////////
14 // class trivial_oarchive
15 class trivial_oarchive {
16
17 public:
18 //////////////////////////////////////////////////////////
19 // public interface used by programs that use the
20 // serialization library
21 typedef boost::mpl::bool_<true> is_saving;
22 typedef boost::mpl::bool_<false> is_loading;
23 template<class T> void register_type(){}
24 template<class T> trivial_oarchive & operator<<(const T & t){
25 return *this;
26 }
27 template<class T> trivial_oarchive & operator&(const T & t){
28 return *this << t;
29 }
30 void save_binary(void *address, std::size_t count){};
31 };
32
33 #include "demo_gps.hpp"
34
35 int main(int argc, char *argv[])
36 {
37 // make the schedule
38 bus_schedule schedule;
39
40 // fill in the data
41 // make a few stops
42 bus_stop *bs0 = new bus_stop_corner(
43 gps_position(34, 135, 52.560f),
44 gps_position(134, 22, 78.30f),
45 "24th Street", "10th Avenue"
46 );
47 bus_stop *bs1 = new bus_stop_corner(
48 gps_position(35, 137, 23.456f),
49 gps_position(133, 35, 54.12f),
50 "State street", "Cathedral Vista Lane"
51 );
52 bus_stop *bs2 = new bus_stop_destination(
53 gps_position(35, 136, 15.456f),
54 gps_position(133, 32, 15.300f),
55 "White House"
56 );
57 bus_stop *bs3 = new bus_stop_destination(
58 gps_position(35, 134, 48.789f),
59 gps_position(133, 32, 16.230f),
60 "Lincoln Memorial"
61 );
62
63 // make a routes
64 bus_route route0;
65 route0.append(bs0);
66 route0.append(bs1);
67 route0.append(bs2);
68
69 // add trips to schedule
70 schedule.append("bob", 6, 24, &route0);
71 schedule.append("bob", 9, 57, &route0);
72 schedule.append("alice", 11, 02, &route0);
73
74 // make aother routes
75 bus_route route1;
76 route1.append(bs3);
77 route1.append(bs2);
78 route1.append(bs1);
79
80 // add trips to schedule
81 schedule.append("ted", 7, 17, &route1);
82 schedule.append("ted", 9, 38, &route1);
83 schedule.append("alice", 11, 47, &route1);
84
85 // display the complete schedule
86 trivial_oarchive ta;
87 ta << schedule;
88
89 delete bs0;
90 delete bs1;
91 delete bs2;
92 delete bs3;
93 return 0;
94 }