1 #ifndef BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP
2 #define BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
6 # pragma once
7 #endif
8 
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // common_oarchive.hpp
11 
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16 
17 //  See http://www.boost.org for updates, documentation, and revision history.
18 
19 #include <boost/config.hpp>
20 
21 #include <boost/archive/detail/basic_oarchive.hpp>
22 #include <boost/archive/detail/interface_oarchive.hpp>
23 
24 #ifdef BOOST_MSVC
25 #  pragma warning(push)
26 #  pragma warning(disable : 4511 4512)
27 #endif
28 
29 namespace boost {
30 namespace archive {
31 namespace detail {
32 
33 // note: referred to as Curiously Recurring Template Patter (CRTP)
34 template<class Archive>
35 class common_oarchive :
36     public basic_oarchive,
37     public interface_oarchive<Archive>
38 {
39     friend class interface_oarchive<Archive>;
40 private:
vsave(const version_type t)41     virtual void vsave(const version_type t){
42         * this->This() << t;
43     }
vsave(const object_id_type t)44     virtual void vsave(const object_id_type t){
45         * this->This() << t;
46     }
vsave(const object_reference_type t)47     virtual void vsave(const object_reference_type t){
48         * this->This() << t;
49     }
vsave(const class_id_type t)50     virtual void vsave(const class_id_type t){
51         * this->This() << t;
52     }
vsave(const class_id_reference_type t)53     virtual void vsave(const class_id_reference_type t){
54         * this->This() << t;
55     }
vsave(const class_id_optional_type t)56     virtual void vsave(const class_id_optional_type t){
57         * this->This() << t;
58     }
vsave(const class_name_type & t)59     virtual void vsave(const class_name_type & t){
60         * this->This() << t;
61     }
vsave(const tracking_type t)62     virtual void vsave(const tracking_type t){
63         * this->This() << t;
64     }
65 protected:
66     // default processing - invoke serialization library
67     template<class T>
save_override(T & t,BOOST_PFTO int)68     void save_override(T & t, BOOST_PFTO int){
69         archive::save(* this->This(), t);
70     }
save_start(const char *)71     void save_start(const char * /*name*/){}
save_end(const char *)72     void save_end(const char * /*name*/){}
common_oarchive(unsigned int flags=0)73     common_oarchive(unsigned int flags = 0) :
74         basic_oarchive(flags),
75         interface_oarchive<Archive>()
76     {}
77 };
78 
79 } // namespace detail
80 } // namespace archive
81 } // namespace boost
82 
83 #ifdef BOOST_MSVC
84 #pragma warning(pop)
85 #endif
86 
87 #endif // BOOST_ARCHIVE_DETAIL_COMMON_OARCHIVE_HPP
88