mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 21:18:23 +01:00
cpp: const
This commit is contained in:
parent
b0062a7f6f
commit
6a0729ea91
@ -80,13 +80,13 @@ struct object {
|
|||||||
type::object_type type;
|
type::object_type type;
|
||||||
union_type via;
|
union_type via;
|
||||||
|
|
||||||
bool is_nil() { return type == type::NIL; }
|
bool is_nil() const { return type == type::NIL; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T as();
|
T as() const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void convert(T* v);
|
void convert(T* v) const;
|
||||||
|
|
||||||
object();
|
object();
|
||||||
object(msgpack_object obj);
|
object(msgpack_object obj);
|
||||||
@ -96,7 +96,7 @@ private:
|
|||||||
struct implicit_type;
|
struct implicit_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
implicit_type convert();
|
implicit_type convert() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct object_kv {
|
struct object_kv {
|
||||||
@ -201,25 +201,25 @@ inline object::operator msgpack_object()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline object::implicit_type object::convert()
|
inline object::implicit_type object::convert() const
|
||||||
{
|
{
|
||||||
return implicit_type(*this);
|
return implicit_type(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T object::as()
|
inline void object::convert(T* v) const
|
||||||
|
{
|
||||||
|
*this >> *v;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline T object::as() const
|
||||||
{
|
{
|
||||||
T v;
|
T v;
|
||||||
convert(&v);
|
convert(&v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline void object::convert(T* v)
|
|
||||||
{
|
|
||||||
*this >> *v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// obsolete
|
// obsolete
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user