portable_binary_archive.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef PORTABLE_BINARY_ARCHIVE_HPP
  2. #define PORTABLE_BINARY_ARCHIVE_HPP
  3. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  4. // Use, modification and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. // MS compatible compilers support #pragma once
  8. #if defined(_MSC_VER)
  9. # pragma once
  10. #endif
  11. #include <boost/config.hpp>
  12. #include <boost/cstdint.hpp>
  13. #include <boost/static_assert.hpp>
  14. #include <climits>
  15. #if CHAR_BIT != 8
  16. #error This code assumes an eight-bit byte.
  17. #endif
  18. #include <boost/archive/basic_archive.hpp>
  19. #include <boost/predef/other/endian.h>
  20. enum portable_binary_archive_flags {
  21. endian_big = 0x4000,
  22. endian_little = 0x8000
  23. };
  24. //#if ( endian_big <= boost::archive::flags_last )
  25. //#error archive flags conflict
  26. //#endif
  27. inline void
  28. reverse_bytes(char size, char *address){
  29. char * first = address;
  30. char * last = first + size - 1;
  31. for(;first < last;++first, --last){
  32. char x = *last;
  33. *last = *first;
  34. *first = x;
  35. }
  36. }
  37. #endif // PORTABLE_BINARY_ARCHIVE_HPP