unpack_exception.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // MessagePack for C++ deserializing routine
  3. //
  4. // Copyright (C) 2008-2016 FURUHASHI Sadayuki and KONDO Takatoshi
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef MSGPACK_V1_UNPACK_EXCEPTION_HPP
  11. #define MSGPACK_V1_UNPACK_EXCEPTION_HPP
  12. #include "msgpack/versioning.hpp"
  13. #include <string>
  14. #include <stdexcept>
  15. namespace msgpack {
  16. /// @cond
  17. MSGPACK_API_VERSION_NAMESPACE(v1) {
  18. /// @endcond
  19. struct unpack_error : public std::runtime_error {
  20. explicit unpack_error(const std::string& msg)
  21. :std::runtime_error(msg) {}
  22. #if !defined(MSGPACK_USE_CPP03)
  23. explicit unpack_error(const char* msg):
  24. std::runtime_error(msg) {}
  25. #endif // !defined(MSGPACK_USE_CPP03)
  26. };
  27. struct parse_error : public unpack_error {
  28. explicit parse_error(const std::string& msg)
  29. :unpack_error(msg) {}
  30. #if !defined(MSGPACK_USE_CPP03)
  31. explicit parse_error(const char* msg)
  32. :unpack_error(msg) {}
  33. #endif // !defined(MSGPACK_USE_CPP03)
  34. };
  35. struct insufficient_bytes : public unpack_error {
  36. explicit insufficient_bytes(const std::string& msg)
  37. :unpack_error(msg) {}
  38. #if !defined(MSGPACK_USE_CPP03)
  39. explicit insufficient_bytes(const char* msg)
  40. :unpack_error(msg) {}
  41. #endif // !defined(MSGPACK_USE_CPP03)
  42. };
  43. struct size_overflow : public unpack_error {
  44. explicit size_overflow(const std::string& msg)
  45. :unpack_error(msg) {}
  46. #if !defined(MSGPACK_USE_CPP03)
  47. explicit size_overflow(const char* msg)
  48. :unpack_error(msg) {}
  49. #endif
  50. };
  51. struct array_size_overflow : public size_overflow {
  52. array_size_overflow(const std::string& msg)
  53. :size_overflow(msg) {}
  54. #if !defined(MSGPACK_USE_CPP03)
  55. array_size_overflow(const char* msg)
  56. :size_overflow(msg) {}
  57. #endif
  58. };
  59. struct map_size_overflow : public size_overflow {
  60. map_size_overflow(const std::string& msg)
  61. :size_overflow(msg) {}
  62. #if !defined(MSGPACK_USE_CPP03)
  63. map_size_overflow(const char* msg)
  64. :size_overflow(msg) {}
  65. #endif
  66. };
  67. struct str_size_overflow : public size_overflow {
  68. str_size_overflow(const std::string& msg)
  69. :size_overflow(msg) {}
  70. #if !defined(MSGPACK_USE_CPP03)
  71. str_size_overflow(const char* msg)
  72. :size_overflow(msg) {}
  73. #endif
  74. };
  75. struct bin_size_overflow : public size_overflow {
  76. bin_size_overflow(const std::string& msg)
  77. :size_overflow(msg) {}
  78. #if !defined(MSGPACK_USE_CPP03)
  79. bin_size_overflow(const char* msg)
  80. :size_overflow(msg) {}
  81. #endif
  82. };
  83. struct ext_size_overflow : public size_overflow {
  84. ext_size_overflow(const std::string& msg)
  85. :size_overflow(msg) {}
  86. #if !defined(MSGPACK_USE_CPP03)
  87. ext_size_overflow(const char* msg)
  88. :size_overflow(msg) {}
  89. #endif
  90. };
  91. struct depth_size_overflow : public size_overflow {
  92. depth_size_overflow(const std::string& msg)
  93. :size_overflow(msg) {}
  94. #if !defined(MSGPACK_USE_CPP03)
  95. depth_size_overflow(const char* msg)
  96. :size_overflow(msg) {}
  97. #endif
  98. };
  99. /// @cond
  100. } // MSGPACK_API_VERSION_NAMESPACE(v1)
  101. /// @endcond
  102. } // namespace msgpack
  103. #endif // MSGPACK_V1_UNPACK_EXCEPTION_HPP