mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-13 14:45:38 +02:00
lang/c/msgpack: added C++ binding
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@50 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
48
cpp/unpack.hpp
Normal file
48
cpp/unpack.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef MSGPACK_UNPACK_HPP__
|
||||
#define MSGPACK_UNPACK_HPP__
|
||||
|
||||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/zone.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
|
||||
struct unpack_error : public std::runtime_error {
|
||||
unpack_error(const std::string& msg) :
|
||||
std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
|
||||
class unpacker {
|
||||
public:
|
||||
unpacker(zone& z);
|
||||
~unpacker();
|
||||
public:
|
||||
size_t execute(const void* data, size_t len, size_t off);
|
||||
bool is_finished() { return m_finished; }
|
||||
object data();
|
||||
void reset();
|
||||
private:
|
||||
struct context;
|
||||
context* m_ctx;
|
||||
zone& m_zone;
|
||||
bool m_finished;
|
||||
private:
|
||||
unpacker();
|
||||
unpacker(const unpacker&);
|
||||
public:
|
||||
static object unpack(const void* data, size_t len, zone& z);
|
||||
};
|
||||
|
||||
|
||||
inline object unpack(const void* data, size_t len, zone& z)
|
||||
{
|
||||
return unpacker::unpack(data, len, z);
|
||||
}
|
||||
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif /* msgpack/unpack.hpp */
|
||||
|
Reference in New Issue
Block a user