mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-04-25 09:25:58 +02:00
Modified type classes' interfaces parameters 'object' from passed by value to passed by reference.
This commit is contained in:
parent
415b14335f
commit
616be1aa60
@ -24,7 +24,7 @@
|
||||
namespace msgpack {
|
||||
|
||||
|
||||
inline bool& operator>> (object o, bool& v)
|
||||
inline bool& operator>> (object const& o, bool& v)
|
||||
{
|
||||
if(o.type != type::BOOLEAN) { throw type_error(); }
|
||||
v = o.via.boolean;
|
||||
|
@ -25,7 +25,7 @@ namespace msgpack {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::deque<T>& operator>> (object o, std::deque<T>& v)
|
||||
inline std::deque<T>& operator>> (object const& o, std::deque<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
|
@ -54,29 +54,29 @@ typedef fix_int<int64_t> fix_int64;
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline type::fix_int8& operator>> (object o, type::fix_int8& v)
|
||||
inline type::fix_int8& operator>> (object const& o, type::fix_int8& v)
|
||||
{ v = type::detail::convert_integer<int8_t>(o); return v; }
|
||||
|
||||
inline type::fix_int16& operator>> (object o, type::fix_int16& v)
|
||||
inline type::fix_int16& operator>> (object const& o, type::fix_int16& v)
|
||||
{ v = type::detail::convert_integer<int16_t>(o); return v; }
|
||||
|
||||
inline type::fix_int32& operator>> (object o, type::fix_int32& v)
|
||||
inline type::fix_int32& operator>> (object const& o, type::fix_int32& v)
|
||||
{ v = type::detail::convert_integer<int32_t>(o); return v; }
|
||||
|
||||
inline type::fix_int64& operator>> (object o, type::fix_int64& v)
|
||||
inline type::fix_int64& operator>> (object const& o, type::fix_int64& v)
|
||||
{ v = type::detail::convert_integer<int64_t>(o); return v; }
|
||||
|
||||
|
||||
inline type::fix_uint8& operator>> (object o, type::fix_uint8& v)
|
||||
inline type::fix_uint8& operator>> (object const& o, type::fix_uint8& v)
|
||||
{ v = type::detail::convert_integer<uint8_t>(o); return v; }
|
||||
|
||||
inline type::fix_uint16& operator>> (object o, type::fix_uint16& v)
|
||||
inline type::fix_uint16& operator>> (object const& o, type::fix_uint16& v)
|
||||
{ v = type::detail::convert_integer<uint16_t>(o); return v; }
|
||||
|
||||
inline type::fix_uint32& operator>> (object o, type::fix_uint32& v)
|
||||
inline type::fix_uint32& operator>> (object const& o, type::fix_uint32& v)
|
||||
{ v = type::detail::convert_integer<uint32_t>(o); return v; }
|
||||
|
||||
inline type::fix_uint64& operator>> (object o, type::fix_uint64& v)
|
||||
inline type::fix_uint64& operator>> (object const& o, type::fix_uint64& v)
|
||||
{ v = type::detail::convert_integer<uint64_t>(o); return v; }
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace msgpack {
|
||||
// FIXME check overflow, underflow
|
||||
|
||||
|
||||
inline float& operator>> (object o, float& v)
|
||||
inline float& operator>> (object const& o, float& v)
|
||||
{
|
||||
if(o.type == type::DOUBLE) {
|
||||
v = (float)o.via.dec;
|
||||
@ -52,7 +52,7 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const float& v)
|
||||
}
|
||||
|
||||
|
||||
inline double& operator>> (object o, double& v)
|
||||
inline double& operator>> (object const& o, double& v)
|
||||
{
|
||||
if(o.type == type::DOUBLE) {
|
||||
v = o.via.dec;
|
||||
|
@ -31,7 +31,7 @@ namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct convert_integer_sign<T, true> {
|
||||
static inline T convert(object o) {
|
||||
static inline T convert(object const& o) {
|
||||
if(o.type == type::POSITIVE_INTEGER) {
|
||||
if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max())
|
||||
{ throw type_error(); }
|
||||
@ -47,7 +47,7 @@ namespace detail {
|
||||
|
||||
template <typename T>
|
||||
struct convert_integer_sign<T, false> {
|
||||
static inline T convert(object o) {
|
||||
static inline T convert(object const& o) {
|
||||
if(o.type == type::POSITIVE_INTEGER) {
|
||||
if(o.via.u64 > (uint64_t)std::numeric_limits<T>::max())
|
||||
{ throw type_error(); }
|
||||
@ -121,35 +121,35 @@ inline char& operator>> (object const& o, char& v)
|
||||
{ v = type::detail::convert_integer<char>(o); return v; }
|
||||
|
||||
|
||||
inline signed char& operator>> (object o, signed char& v)
|
||||
inline signed char& operator>> (object const& o, signed char& v)
|
||||
{ v = type::detail::convert_integer<signed char>(o); return v; }
|
||||
|
||||
inline signed short& operator>> (object o, signed short& v)
|
||||
inline signed short& operator>> (object const& o, signed short& v)
|
||||
{ v = type::detail::convert_integer<signed short>(o); return v; }
|
||||
|
||||
inline signed int& operator>> (object o, signed int& v)
|
||||
inline signed int& operator>> (object const& o, signed int& v)
|
||||
{ v = type::detail::convert_integer<signed int>(o); return v; }
|
||||
|
||||
inline signed long& operator>> (object o, signed long& v)
|
||||
inline signed long& operator>> (object const& o, signed long& v)
|
||||
{ v = type::detail::convert_integer<signed long>(o); return v; }
|
||||
|
||||
inline signed long long& operator>> (object o, signed long long& v)
|
||||
inline signed long long& operator>> (object const& o, signed long long& v)
|
||||
{ v = type::detail::convert_integer<signed long long>(o); return v; }
|
||||
|
||||
|
||||
inline unsigned char& operator>> (object o, unsigned char& v)
|
||||
inline unsigned char& operator>> (object const& o, unsigned char& v)
|
||||
{ v = type::detail::convert_integer<unsigned char>(o); return v; }
|
||||
|
||||
inline unsigned short& operator>> (object o, unsigned short& v)
|
||||
inline unsigned short& operator>> (object const& o, unsigned short& v)
|
||||
{ v = type::detail::convert_integer<unsigned short>(o); return v; }
|
||||
|
||||
inline unsigned int& operator>> (object o, unsigned int& v)
|
||||
inline unsigned int& operator>> (object const& o, unsigned int& v)
|
||||
{ v = type::detail::convert_integer<unsigned int>(o); return v; }
|
||||
|
||||
inline unsigned long& operator>> (object o, unsigned long& v)
|
||||
inline unsigned long& operator>> (object const& o, unsigned long& v)
|
||||
{ v = type::detail::convert_integer<unsigned long>(o); return v; }
|
||||
|
||||
inline unsigned long long& operator>> (object o, unsigned long long& v)
|
||||
inline unsigned long long& operator>> (object const& o, unsigned long long& v)
|
||||
{ v = type::detail::convert_integer<unsigned long long>(o); return v; }
|
||||
|
||||
template <typename Stream>
|
||||
|
@ -25,7 +25,7 @@ namespace msgpack {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::list<T>& operator>> (object o, std::list<T>& v)
|
||||
inline std::list<T>& operator>> (object const& o, std::list<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
|
@ -43,7 +43,7 @@ namespace detail {
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline type::assoc_vector<K,V>& operator>> (object o, type::assoc_vector<K,V>& v)
|
||||
inline type::assoc_vector<K,V>& operator>> (object const& o, type::assoc_vector<K,V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
v.resize(o.via.map.size);
|
||||
@ -94,7 +94,7 @@ inline void operator<< (object::with_zone& o, const type::assoc_vector<K,V>& v)
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline std::map<K, V> operator>> (object o, std::map<K, V>& v)
|
||||
inline std::map<K, V> operator>> (object const& o, std::map<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
@ -150,7 +150,7 @@ inline void operator<< (object::with_zone& o, const std::map<K,V>& v)
|
||||
|
||||
|
||||
template <typename K, typename V>
|
||||
inline std::multimap<K, V> operator>> (object o, std::multimap<K, V>& v)
|
||||
inline std::multimap<K, V> operator>> (object const& o, std::multimap<K, V>& v)
|
||||
{
|
||||
if(o.type != type::MAP) { throw type_error(); }
|
||||
object_kv* p(o.via.map.ptr);
|
||||
|
@ -29,7 +29,7 @@ struct nil { };
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline type::nil& operator>> (object o, type::nil& v)
|
||||
inline type::nil& operator>> (object const& o, type::nil& v)
|
||||
{
|
||||
if(o.type != type::NIL) { throw type_error(); }
|
||||
return v;
|
||||
|
@ -25,7 +25,7 @@ namespace msgpack {
|
||||
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline std::pair<T1, T2>& operator>> (object o, std::pair<T1, T2>& v)
|
||||
inline std::pair<T1, T2>& operator>> (object const& o, std::pair<T1, T2>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
if(o.via.array.size != 2) { throw type_error(); }
|
||||
|
@ -61,7 +61,7 @@ struct raw_ref {
|
||||
} // namespace type
|
||||
|
||||
|
||||
inline type::raw_ref& operator>> (object o, type::raw_ref& v)
|
||||
inline type::raw_ref& operator>> (object const& o, type::raw_ref& v)
|
||||
{
|
||||
if(o.type != type::RAW) { throw type_error(); }
|
||||
v.ptr = o.via.raw.ptr;
|
||||
|
@ -25,7 +25,7 @@ namespace msgpack {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::set<T>& operator>> (object o, std::set<T>& v)
|
||||
inline std::set<T>& operator>> (object const& o, std::set<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
@ -71,7 +71,7 @@ inline void operator<< (object::with_zone& o, const std::set<T>& v)
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::multiset<T>& operator>> (object o, std::multiset<T>& v)
|
||||
inline std::multiset<T>& operator>> (object const& o, std::multiset<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace msgpack {
|
||||
|
||||
|
||||
inline std::string& operator>> (object o, std::string& v)
|
||||
inline std::string& operator>> (object const& o, std::string& v)
|
||||
{
|
||||
if(o.type != type::RAW) { throw type_error(); }
|
||||
v.assign(o.via.raw.ptr, o.via.raw.size);
|
||||
|
@ -25,7 +25,7 @@ namespace msgpack {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::vector<T>& operator>> (object o, std::vector<T>& v)
|
||||
inline std::vector<T>& operator>> (object const& o, std::vector<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user