| 1 | #ifndef PORTABLE_BINARY_ARCHIVE_HPP |
| 2 | #define PORTABLE_BINARY_ARCHIVE_HPP |
| 3 | |
| 4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . |
| 5 | // Use, modification and distribution is subject to the Boost Software |
| 6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | |
| 9 | // MS compatible compilers support #pragma once |
| 10 | #if defined(_MSC_VER) |
| 11 | # pragma once |
| 12 | #endif |
| 13 | |
| 14 | #include <boost/config.hpp> |
| 15 | #include <boost/cstdint.hpp> |
| 16 | #include <boost/static_assert.hpp> |
| 17 | #include <boost/archive/archive_exception.hpp> |
| 18 | |
| 19 | #include <climits> |
| 20 | #if CHAR_BIT != 8 |
| 21 | #error This code assumes an eight-bit byte. |
| 22 | #endif |
| 23 | |
| 24 | #include <boost/archive/basic_archive.hpp> |
| 25 | #include <boost/predef/other/endian.h> |
| 26 | |
| 27 | #include <boost/archive/impl/archive_serializer_map.ipp> |
| 28 | |
| 29 | namespace boost { namespace archive { |
| 30 | |
| 31 | enum portable_binary_archive_flags { |
| 32 | endian_big = 0x4000, |
| 33 | endian_little = 0x8000 |
| 34 | }; |
| 35 | |
| 36 | //#if ( endian_big <= boost::archive::flags_last ) |
| 37 | //#error archive flags conflict |
| 38 | //#endif |
| 39 | |
| 40 | inline void |
| 41 | reverse_bytes(signed char size, char *address){ |
| 42 | if (size <= 0) |
| 43 | throw archive_exception(archive_exception::other_exception); |
| 44 | char * first = address; |
| 45 | char * last = first + size - 1; |
| 46 | for(;first < last;++first, --last){ |
| 47 | #if defined(__GNUC__) && !defined(__clang__) |
| 48 | #pragma GCC diagnostic push |
| 49 | #pragma GCC diagnostic ignored "-Wstringop-overflow=" |
| 50 | #endif |
| 51 | char x = *last; |
| 52 | *last = *first; |
| 53 | *first = x; |
| 54 | #if defined(__GNUC__) && !defined(__clang__) |
| 55 | #pragma GCC diagnostic pop |
| 56 | #endif |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } } |
| 61 | |
| 62 | #endif // PORTABLE_BINARY_ARCHIVE_HPP |