os/ossrv/ossrv_pub/boost_apis/boost/archive/archive_exception.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
#ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
sl@0
     2
#define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
sl@0
     3
sl@0
     4
// MS compatible compilers support #pragma once
sl@0
     5
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
sl@0
     6
# pragma once
sl@0
     7
#endif
sl@0
     8
sl@0
     9
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
sl@0
    10
// archive/archive_exception.hpp:
sl@0
    11
sl@0
    12
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 
sl@0
    13
// Use, modification and distribution is subject to the Boost Software
sl@0
    14
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
    15
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
    16
sl@0
    17
//  See http://www.boost.org for updates, documentation, and revision history.
sl@0
    18
sl@0
    19
#include <exception>
sl@0
    20
#include <cassert>
sl@0
    21
sl@0
    22
namespace boost {
sl@0
    23
namespace archive {
sl@0
    24
sl@0
    25
//////////////////////////////////////////////////////////////////////
sl@0
    26
// exceptions thrown by archives
sl@0
    27
//
sl@0
    28
class archive_exception : 
sl@0
    29
    public virtual std::exception
sl@0
    30
{
sl@0
    31
public:
sl@0
    32
    typedef enum {
sl@0
    33
        no_exception,       // initialized without code
sl@0
    34
        other_exception,    // any excepton not listed below
sl@0
    35
        unregistered_class, // attempt to serialize a pointer of an
sl@0
    36
                            // an unregistered class
sl@0
    37
        invalid_signature,  // first line of archive does not contain
sl@0
    38
                            // expected string
sl@0
    39
        unsupported_version,// archive created with library version
sl@0
    40
                            // subsequent to this one
sl@0
    41
        pointer_conflict,   // an attempt has been made to directly
sl@0
    42
                            // serialization::detail an object
sl@0
    43
                            // after having already serialzed the same
sl@0
    44
                            // object through a pointer.  Were this permited,
sl@0
    45
                            // it the archive load would result in the
sl@0
    46
                            // creation of an extra copy of the obect.
sl@0
    47
        incompatible_native_format, // attempt to read native binary format
sl@0
    48
                            // on incompatible platform
sl@0
    49
        array_size_too_short,// array being loaded doesn't fit in array allocated
sl@0
    50
        stream_error,       // i/o error on stream
sl@0
    51
        invalid_class_name, // class name greater than the maximum permitted.
sl@0
    52
                            // most likely a corrupted archive or an attempt
sl@0
    53
                            // to insert virus via buffer overrun method.
sl@0
    54
        unregistered_cast   // base - derived relationship not registered with 
sl@0
    55
                            // void_cast_register
sl@0
    56
    } exception_code;
sl@0
    57
    exception_code code;
sl@0
    58
    archive_exception(exception_code c) : 
sl@0
    59
        code(c)
sl@0
    60
    {}
sl@0
    61
    virtual const char *what( ) const throw( )
sl@0
    62
    {
sl@0
    63
        const char *msg = "programming error";
sl@0
    64
        switch(code){
sl@0
    65
        case no_exception:
sl@0
    66
            msg = "uninitialized exception";
sl@0
    67
            break;
sl@0
    68
        case unregistered_class:
sl@0
    69
            msg = "unregistered class";
sl@0
    70
            break;
sl@0
    71
        case invalid_signature:
sl@0
    72
            msg = "invalid signature";
sl@0
    73
            break;
sl@0
    74
        case unsupported_version:
sl@0
    75
            msg = "unsupported version";
sl@0
    76
            break;
sl@0
    77
        case pointer_conflict:
sl@0
    78
            msg = "pointer conflict";
sl@0
    79
            break;
sl@0
    80
        case incompatible_native_format:
sl@0
    81
            msg = "incompatible native format";
sl@0
    82
            break;
sl@0
    83
        case array_size_too_short:
sl@0
    84
            msg = "array size too short";
sl@0
    85
            break;
sl@0
    86
        case stream_error:
sl@0
    87
            msg = "stream error";
sl@0
    88
            break;
sl@0
    89
        case invalid_class_name:
sl@0
    90
            msg = "class name too long";
sl@0
    91
            break;
sl@0
    92
        case unregistered_cast:
sl@0
    93
            msg = "unregistered void cast";
sl@0
    94
            break;
sl@0
    95
        case other_exception:
sl@0
    96
            // if get here - it indicates a derived exception 
sl@0
    97
            // was sliced by passing by value in catch
sl@0
    98
            msg = "unknown derived exception";
sl@0
    99
            break;
sl@0
   100
        default:
sl@0
   101
            assert(false);
sl@0
   102
            break;
sl@0
   103
        }
sl@0
   104
        return msg;
sl@0
   105
    }
sl@0
   106
protected:
sl@0
   107
    archive_exception() : 
sl@0
   108
         code(no_exception)
sl@0
   109
    {}
sl@0
   110
};
sl@0
   111
sl@0
   112
}// namespace archive
sl@0
   113
}// namespace boost
sl@0
   114
sl@0
   115
#endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP