36 Commits

Author SHA1 Message Date
Takatoshi Kondo
469040be6b Fixed exceptions' interface. On the C++11, both const char* and const std::string& are supported.
Updated all exceptions relate to unpack take a message parameter. It is better to explain the exceptional situation in detail. So far, just passing the exceptions name.
2014-12-15 10:12:55 +09:00
Takatoshi Kondo
309e96087a - Added unpack limit.
- Added new exceptions to explain limit over errors.

- Fixed ext maximum size problem.
Problem:
The type of m_trail was uint32_t but when parsing ext, it could be 0xffffffff + 1. +1 means type. See https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family

Solution:
Modified the type of m_trail as std::size_t. If sizeof(std::size_t) == 4, 0xffffffff size of ext is an error. If sizeof(std::size_t) == 8, 0xffffffff size of ext is not an error. m_trail is 0xffffffff + 1.

Design cohice:
I chose std::size_t as the m_trail's type instead of uint64_t intentionally. On 64 addressing bit environment, there is no problem. On 32 bit environment, there is no problem except ext with maximum size. There is only one exception in the all msgpack format. Using uint64_t to support that, it's very expensive. On 32 addressing bit environment, allocating 0xffffffff + 1 bytes of memory couldn't succeed, so I believe that throwing an exception is a reasonable design choice in the case.
2014-12-14 19:10:46 +09:00
Mircea Baja
6e560e345a Added check for already defined NOMINMAX 2014-12-08 21:36:26 +00:00
Takatoshi Kondo
dab725624e Made copy constructors and copy assignment operators private for classes that should be noncopyable. 2014-11-23 20:42:38 +09:00
Takatoshi Kondo
d6cc5494a9 Fixed memory size caluclation problem.
See https://github.com/msgpack/msgpack-c/issues/149
2014-11-01 19:41:47 +09:00
Takatoshi Kondo
3bfd142660 Fixed https://github.com/msgpack/msgpack-c/issues/153 2014-10-31 15:50:57 +09:00
Takatoshi Kondo
a6aac482dd Merge branch 'api_versioning' of https://github.com/redboltz/msgpack-c into redboltz-api_versioning
Conflicts:
	include/msgpack/unpack.hpp
2014-10-26 09:43:36 +09:00
Takatoshi Kondo
e21e3245db Merge pull request #138 from redboltz/move_byteswap
Moved include byteswap.h to sysdep.h.
2014-10-19 19:42:38 +09:00
Takatoshi Kondo
4a292193f2 Moved include byteswap.h to sysdep.h.
When compiling on Mac, byteswap.h is not included.
2014-10-12 01:22:10 +09:00
Takatoshi Kondo
479d50bd93 Replaced uint64_t with apropriate types. 2014-10-11 23:45:21 +09:00
Takatoshi Kondo
3ddeb08e6e Added API versioning. 2014-10-12 23:21:25 +09:00
Takatoshi Kondo
4fcb4777f3 Added additional unpack() APIs to support C++11 style programming. 2014-09-15 22:33:23 +09:00
Takatoshi Kondo
7737f1cb77 Removed unused member variable. 2014-09-08 17:14:56 +09:00
Jason Newton
93d0f0bd00 inline default_reference_func to avoid multiple definition errors 2014-09-03 10:26:09 +09:00
Takatoshi Kondo
5896ff3746 Fixed -Wextra warnings on gcc. 2014-09-02 18:15:58 +09:00
Takatoshi Kondo
4d6e9d6c05 Removed referenced member from msgpack::unpacked.
Added a referenced parameter to msgpack::unpack() and msgpack::unpacker::next().

msgpack::unpacked is a kind of handler that holds msgpack::object and msgpack::zone, so the size of msgpack::unpacked should be small. There is no reason to have referenced in msgpack::unpacked. msgpack user can get the same information using msgpack::unpack() and msgpack::unpacker::next().
2014-08-11 15:50:51 +09:00
Takatoshi Kondo
0a99b9f933 Fixed the problem that reference function doesn't pass correctly.
Fixed referenced flag writing timing on next(). It should place before flush.
Added msgpack_tuple test for CMakeLists.txt
Untabified CMakeLists.txt
Added reference function test.
2014-08-07 23:26:09 +09:00
Takatoshi Kondo
17e696fc0d Removed redundant memory allocation from zone.
Removed zone::create and zone::destroy.
We can use zone as follows:
   zone z; // on stack
   zone* z = new zone; // on heap

Fixed a resource leak when zone::push_finalizer(msgpack::unique_ptr<T>) is called.
2014-08-07 15:23:34 +09:00
Takatoshi Kondo
b5b459cfca Reordered unpack selector sequence. 2014-08-07 10:40:21 +09:00
Takatoshi Kondo
7822bc787d Replaced switch-case and bit calculation with a table. 2014-08-07 10:28:18 +09:00
Takatoshi Kondo
1f5d6b9cac Added EXT support.
Removed obsolete unpack functions.
Updated examples that no longer use obsolete functions.
Added reference checking function to unpacked. ( unpacked::referenced() )
Added std:: namespace.
Added reference or copy choice function and default behavior:
  When you use unpacker, default behavior is:
    STR, BIN, EXT types are always held by reference.
  When you don't use unpacker, default behavior is:
    STR, BIN, EXT types are always held by copy.
    The memory is allocated from zone.
  You can customize the behavior passing your custom judging function to unpack() or unpacker's constructor.
2014-08-06 16:18:37 +09:00
Takatoshi Kondo
ce21ab0ebf Fixed zone allocating functions always throw std::bad_alloc() if allocation is failed. 2014-08-06 12:16:28 +09:00
Takatoshi Kondo
fd566afeb4 Added reference version of unpacker::next(). 2014-08-04 00:52:04 +09:00
Takatoshi Kondo
e4d32b176e Use const char* version of msgpack::unpack_error to avoid std::string memory allocation when usr C++11 compiler.
See http://www.cplusplus.com/reference/stdexcept/runtime_error/?kw=runtime_error
2014-08-03 17:04:46 +09:00
Takatoshi Kondo
b27c87c9ed Replaced C-Style cast with static_cast. 2014-08-03 16:38:58 +09:00
Takatoshi Kondo
3729f334a1 Replaced size_t with std::size_t. 2014-08-03 16:34:47 +09:00
Takatoshi Kondo
78e8cbdfb5 Cleaned up pointer and reference versions of unpack(). 2014-08-03 07:09:03 +09:00
Takatoshi Kondo
09325ed846 Re-implemented msgpack::unpacker's move operations.
I refered to the following article and comments.
http://scottmeyers.blogspot.jp/2014/06/the-drawbacks-of-implementing-move.html

msgpack::detail::context back to copiable.
msgpack::detail::context doen't have any resource ownership, so there is
no strong reason to avoid copy.
2014-07-24 10:38:24 +09:00
Takatoshi Kondo
ecdeec9948 Fixed the move assign operator implementation. 2014-07-24 07:41:23 +09:00
Takatoshi Kondo
f11a811114 Added a move constructor and a move assign operator for unpacker and context.
https://github.com/msgpack/msgpack-c/issues/96
2014-07-23 21:32:45 +09:00
Takatoshi Kondo
0e48f65a4b Fixed https://github.com/msgpack/msgpack-c/issues/94
Added a private copy assign operator to unpacker.
2014-07-12 00:41:33 +09:00
Takatoshi Kondo
b0df21295c Untabified.
Adjust line break positions.
2014-07-12 00:17:31 +09:00
Takatoshi Kondo
0889e6117e Renamed member variables name. 2014-07-11 23:37:43 +09:00
Takatoshi Kondo
6a349d0b28 Fixed zero size string in the array problem. 2014-07-07 16:31:29 +09:00
Takatoshi Kondo
dac5c60608 Replaced bit shift with memcpy on load. 2014-07-07 16:31:29 +09:00
Takatoshi Kondo
bc33317b7e Reorganized tree. 2014-07-07 16:31:29 +09:00