epoc32/include/stdapis/boost/archive/basic_text_oarchive.hpp
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
#ifndef BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
williamr@2
     2
#define BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP
williamr@2
     3
williamr@2
     4
// MS compatible compilers support #pragma once
williamr@2
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
williamr@2
     6
# pragma once
williamr@2
     7
#endif
williamr@2
     8
williamr@2
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
williamr@2
    10
// basic_text_oarchive.hpp
williamr@2
    11
williamr@2
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
williamr@2
    13
// Use, modification and distribution is subject to the Boost Software
williamr@2
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
williamr@2
    15
// http://www.boost.org/LICENSE_1_0.txt)
williamr@2
    16
williamr@2
    17
//  See http://www.boost.org for updates, documentation, and revision history.
williamr@2
    18
williamr@2
    19
// archives stored as text - note these ar templated on the basic
williamr@2
    20
// stream templates to accommodate wide (and other?) kind of characters
williamr@2
    21
//
williamr@2
    22
// note the fact that on libraries without wide characters, ostream is
williamr@2
    23
// is not a specialization of basic_ostream which in fact is not defined
williamr@2
    24
// in such cases.   So we can't use basic_ostream<OStream::char_type> but rather
williamr@2
    25
// use two template parameters
williamr@2
    26
williamr@2
    27
#include <cassert>
williamr@2
    28
#include <boost/config.hpp>
williamr@2
    29
#include <boost/pfto.hpp>
williamr@2
    30
#include <boost/detail/workaround.hpp>
williamr@2
    31
williamr@2
    32
#include <boost/archive/detail/common_oarchive.hpp>
williamr@2
    33
#include <boost/serialization/string.hpp>
williamr@2
    34
williamr@2
    35
#include <boost/archive/detail/abi_prefix.hpp> // must be the last header
williamr@2
    36
williamr@2
    37
namespace boost {
williamr@2
    38
namespace archive {
williamr@2
    39
williamr@2
    40
/////////////////////////////////////////////////////////////////////////
williamr@2
    41
// class basic_text_iarchive - read serialized objects from a input text stream
williamr@2
    42
template<class Archive>
williamr@2
    43
class basic_text_oarchive : 
williamr@2
    44
    public detail::common_oarchive<Archive>
williamr@2
    45
{
williamr@2
    46
protected:
williamr@2
    47
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
williamr@2
    48
|| BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x560))
williamr@2
    49
public:
williamr@2
    50
#elif defined(BOOST_MSVC)
williamr@2
    51
    // for some inexplicable reason insertion of "class" generates compile erro
williamr@2
    52
    // on msvc 7.1
williamr@2
    53
    friend detail::interface_oarchive<Archive>;
williamr@2
    54
#else
williamr@2
    55
    friend class detail::interface_oarchive<Archive>;
williamr@2
    56
#endif
williamr@2
    57
    enum {
williamr@2
    58
        none,
williamr@2
    59
        eol,
williamr@2
    60
        space
williamr@2
    61
    } delimiter;
williamr@2
    62
williamr@2
    63
    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
williamr@2
    64
    newtoken();
williamr@2
    65
williamr@2
    66
    void newline(){
williamr@2
    67
        delimiter = eol;
williamr@2
    68
    }
williamr@2
    69
williamr@2
    70
    // default processing - kick back to base class.  Note the
williamr@2
    71
    // extra stuff to get it passed borland compilers
williamr@2
    72
    typedef detail::common_oarchive<Archive> detail_common_oarchive;
williamr@2
    73
    template<class T>
williamr@2
    74
    void save_override(T & t, BOOST_PFTO int){
williamr@2
    75
        this->detail_common_oarchive::save_override(t, 0);
williamr@2
    76
    }
williamr@2
    77
williamr@2
    78
    // start new objects on a new line
williamr@2
    79
    void save_override(const object_id_type & t, int){
williamr@2
    80
        this->This()->newline();
williamr@2
    81
        // and and invoke prmitive to underlying value
williamr@2
    82
        this->This()->save(t.t);
williamr@2
    83
    }
williamr@2
    84
williamr@2
    85
    void save_override(const object_reference_type & t, int){
williamr@2
    86
        this->This()->newline();
williamr@2
    87
        // and and invoke prmitive to underlying value
williamr@2
    88
        this->This()->save(t.t);
williamr@2
    89
    }
williamr@2
    90
williamr@2
    91
    // text file don't include the optional information 
williamr@2
    92
    void save_override(const class_id_optional_type & /* t */, int){}
williamr@2
    93
williamr@2
    94
    // note the following four overrides are necessary for some borland
williamr@2
    95
    // compilers which don't handle BOOST_STRONG_TYPE properly.
williamr@2
    96
    void save_override(const version_type & t, int){
williamr@2
    97
        // note:t.t resolves borland ambguity
williamr@2
    98
        unsigned int x = t.t;
williamr@2
    99
        * this->This() << x;
williamr@2
   100
    }
williamr@2
   101
    void save_override(const class_id_type & t, int){
williamr@2
   102
        // note:t.t resolves borland ambguity
williamr@2
   103
        int x = t.t;
williamr@2
   104
        * this->This() << x;
williamr@2
   105
    }
williamr@2
   106
    void save_override(const class_id_reference_type & t, int){
williamr@2
   107
        // note:t.t resolves borland ambguity
williamr@2
   108
        int x = t.t;
williamr@2
   109
        * this->This() << x;
williamr@2
   110
    }
williamr@2
   111
    void save_override(const class_name_type & t, int){
williamr@2
   112
        const std::string s(t);
williamr@2
   113
        * this->This() << s;
williamr@2
   114
    }
williamr@2
   115
williamr@2
   116
    BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
williamr@2
   117
    init();
williamr@2
   118
williamr@2
   119
    basic_text_oarchive(unsigned int flags) :
williamr@2
   120
        detail::common_oarchive<Archive>(flags),
williamr@2
   121
        delimiter(none)
williamr@2
   122
    {}
williamr@2
   123
    ~basic_text_oarchive(){}
williamr@2
   124
};
williamr@2
   125
williamr@2
   126
} // namespace archive
williamr@2
   127
} // namespace boost
williamr@2
   128
williamr@2
   129
#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
williamr@2
   130
williamr@2
   131
#endif // BOOST_ARCHIVE_BASIC_TEXT_OARCHIVE_HPP