mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-08 02:40:09 +00:00
cpp: object::object(const T& v, zone* z)
This commit is contained in:
parent
120e8bffd7
commit
4e85ebbf98
10 changed files with 152 additions and 1 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "msgpack/object.h"
|
||||
#include "msgpack/pack.hpp"
|
||||
#include "msgpack/zone.hpp"
|
||||
#include <string.h>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
|
|
@ -92,6 +93,9 @@ struct object {
|
|||
template <typename T>
|
||||
object(const T& v);
|
||||
|
||||
template <typename T>
|
||||
object(const T& v, zone* z);
|
||||
|
||||
template <typename T>
|
||||
object& operator=(const T& v);
|
||||
|
||||
|
|
@ -100,6 +104,10 @@ struct object {
|
|||
private:
|
||||
struct implicit_type;
|
||||
|
||||
public:
|
||||
// FIXME private?
|
||||
struct object_zone;
|
||||
|
||||
public:
|
||||
implicit_type convert() const;
|
||||
};
|
||||
|
|
@ -109,6 +117,14 @@ struct object_kv {
|
|||
object val;
|
||||
};
|
||||
|
||||
struct object::object_zone : object {
|
||||
object_zone(msgpack::zone* zone) : zone(zone) { }
|
||||
msgpack::zone* zone;
|
||||
private:
|
||||
object_zone();
|
||||
};
|
||||
|
||||
|
||||
bool operator==(const object x, const object y);
|
||||
bool operator!=(const object x, const object y);
|
||||
|
||||
|
|
@ -230,6 +246,15 @@ inline object& object::operator=(const T& v)
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
object::object(const T& v, zone* z)
|
||||
{
|
||||
object_zone oz(z);
|
||||
oz << v;
|
||||
type = oz.type;
|
||||
via = oz.via;
|
||||
}
|
||||
|
||||
|
||||
inline object::operator msgpack_object()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue