epoc32/include/stdapis/boost/archive/archive_exception.hpp
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 #ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
       
     2 #define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_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 // archive/archive_exception.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 <exception>
       
    20 #include <cassert>
       
    21 
       
    22 namespace boost {
       
    23 namespace archive {
       
    24 
       
    25 //////////////////////////////////////////////////////////////////////
       
    26 // exceptions thrown by archives
       
    27 //
       
    28 class archive_exception : 
       
    29     public virtual std::exception
       
    30 {
       
    31 public:
       
    32     typedef enum {
       
    33         no_exception,       // initialized without code
       
    34         other_exception,    // any excepton not listed below
       
    35         unregistered_class, // attempt to serialize a pointer of an
       
    36                             // an unregistered class
       
    37         invalid_signature,  // first line of archive does not contain
       
    38                             // expected string
       
    39         unsupported_version,// archive created with library version
       
    40                             // subsequent to this one
       
    41         pointer_conflict,   // an attempt has been made to directly
       
    42                             // serialization::detail an object
       
    43                             // after having already serialzed the same
       
    44                             // object through a pointer.  Were this permited,
       
    45                             // it the archive load would result in the
       
    46                             // creation of an extra copy of the obect.
       
    47         incompatible_native_format, // attempt to read native binary format
       
    48                             // on incompatible platform
       
    49         array_size_too_short,// array being loaded doesn't fit in array allocated
       
    50         stream_error,       // i/o error on stream
       
    51         invalid_class_name, // class name greater than the maximum permitted.
       
    52                             // most likely a corrupted archive or an attempt
       
    53                             // to insert virus via buffer overrun method.
       
    54         unregistered_cast   // base - derived relationship not registered with 
       
    55                             // void_cast_register
       
    56     } exception_code;
       
    57     exception_code code;
       
    58     archive_exception(exception_code c) : 
       
    59         code(c)
       
    60     {}
       
    61     virtual const char *what( ) const throw( )
       
    62     {
       
    63         const char *msg = "programming error";
       
    64         switch(code){
       
    65         case no_exception:
       
    66             msg = "uninitialized exception";
       
    67             break;
       
    68         case unregistered_class:
       
    69             msg = "unregistered class";
       
    70             break;
       
    71         case invalid_signature:
       
    72             msg = "invalid signature";
       
    73             break;
       
    74         case unsupported_version:
       
    75             msg = "unsupported version";
       
    76             break;
       
    77         case pointer_conflict:
       
    78             msg = "pointer conflict";
       
    79             break;
       
    80         case incompatible_native_format:
       
    81             msg = "incompatible native format";
       
    82             break;
       
    83         case array_size_too_short:
       
    84             msg = "array size too short";
       
    85             break;
       
    86         case stream_error:
       
    87             msg = "stream error";
       
    88             break;
       
    89         case invalid_class_name:
       
    90             msg = "class name too long";
       
    91             break;
       
    92         case unregistered_cast:
       
    93             msg = "unregistered void cast";
       
    94             break;
       
    95         case other_exception:
       
    96             // if get here - it indicates a derived exception 
       
    97             // was sliced by passing by value in catch
       
    98             msg = "unknown derived exception";
       
    99             break;
       
   100         default:
       
   101             assert(false);
       
   102             break;
       
   103         }
       
   104         return msg;
       
   105     }
       
   106 protected:
       
   107     archive_exception() : 
       
   108          code(no_exception)
       
   109     {}
       
   110 };
       
   111 
       
   112 }// namespace archive
       
   113 }// namespace boost
       
   114 
       
   115 #endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP