示例#1
0
 msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const char(&v)[N]) const {
     char const* p = v;
     uint32_t size = checked_get_container_size(std::strlen(p));
     o.pack_str(size);
     o.pack_str_body(p, size);
     return o;
 }
示例#2
0
inline void operator<< (msgpack::object& o, const std::string& v)
{
    uint32_t size = checked_get_container_size(v.size());
    o.type = msgpack::type::STR;
    o.via.str.ptr = v.data();
    o.via.str.size = size;
}
示例#3
0
 msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const unsigned char(&v)[N]) const {
     unsigned char const* p = v;
     uint32_t size = checked_get_container_size(N);
     o.pack_bin(size);
     o.pack_bin_body(reinterpret_cast<char const*>(p), size);
     return o;
 }
示例#4
0
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v)
{
    uint32_t size = checked_get_container_size(v.size());
    o.pack_str(size);
    o.pack_str_body(v.data(), size);
    return o;
}
示例#5
0
    void operator()(msgpack::object::with_zone& o, const std::vector<T>& v) const {
        o.type = msgpack::type::ARRAY;
        if(v.empty()) {
            o.via.array.ptr = nullptr;
            o.via.array.size = 0;
        } else {
            uint32_t size = checked_get_container_size(v.size());
            msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
            msgpack::object* const pend = p + size;
            o.via.array.ptr = p;
            o.via.array.size = size;
            typename std::vector<T>::const_iterator it(v.begin());
            do {
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // defined(__GNUC__) && !defined(__clang__)
                *p = msgpack::object(*it, o.zone);
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // defined(__GNUC__) && !defined(__clang__)
                ++p;
                ++it;
            } while(p < pend);
        }
    }
示例#6
0
    clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const std::array<unsigned char, N>& v) const {
        uint32_t size = checked_get_container_size(v.size());
        o.pack_bin(size);
        o.pack_bin_body(reinterpret_cast<char const*>(v.data()), size);

        return o;
    }
示例#7
0
    msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::array<char, N>& v) const {
        uint32_t size = checked_get_container_size(v.size());
        o.pack_bin(size);
        o.pack_bin_body(v.data(), size);

        return o;
    }
示例#8
0
    msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<char, Alloc>& v) const {
        uint32_t size = checked_get_container_size(v.size());
        o.pack_bin(size);
        o.pack_bin_body(&v.front(), size);

        return o;
    }
示例#9
0
 msgpack::packer<Stream>& operator()(
     msgpack::packer<Stream>& o,
     const std::tuple<Args...>& v) const {
     uint32_t size = checked_get_container_size(sizeof...(Args));
     o.pack_array(size);
     StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
     return o;
 }
示例#10
0
 void operator()(msgpack::object::with_zone& o, const unsigned char(&v)[N]) const {
     uint32_t size = checked_get_container_size(N);
     o.type = msgpack::type::BIN;
     char* ptr = static_cast<char*>(o.zone.allocate_align(size));
     o.via.bin.ptr = ptr;
     o.via.bin.size = size;
     std::memcpy(ptr, v, size);
 }
示例#11
0
文件: string.hpp 项目: rpclib/rpclib
 void operator()(clmdep_msgpack::object::with_zone& o, const std::string& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = clmdep_msgpack::type::STR;
     char* ptr = static_cast<char*>(o.zone.allocate_align(size));
     o.via.str.ptr = ptr;
     o.via.str.size = size;
     std::memcpy(ptr, v.data(), v.size());
 }
示例#12
0
 void operator()(clmdep_msgpack::object::with_zone& o, const std::array<unsigned char, N>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = clmdep_msgpack::type::BIN;
     char* ptr = static_cast<char*>(o.zone.allocate_align(size));
     o.via.bin.ptr = ptr;
     o.via.bin.size = size;
     std::memcpy(ptr, v.data(), size);
 }
示例#13
0
 void operator()(msgpack::object& o, const std::vector<char, Alloc>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = msgpack::type::BIN;
     if (size != 0) {
         o.via.bin.ptr = &v.front();
     }
     o.via.bin.size = size;
 }
示例#14
0
 void operator()(msgpack::object::with_zone& o, const std::vector<char, Alloc>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = msgpack::type::BIN;
     char* ptr = static_cast<char*>(o.zone.allocate_align(size));
     o.via.bin.ptr = ptr;
     o.via.bin.size = size;
     std::memcpy(ptr, &v.front(), size);
 }
示例#15
0
文件: set.hpp 项目: rpclib/rpclib
 clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const std::set<T, Compare, Alloc>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.pack_array(size);
     for (typename std::set<T, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
         it != it_end; ++it) {
         o.pack(*it);
     }
     return o;
 }
示例#16
0
 void operator()(
     msgpack::object::with_zone& o,
     std::tuple<Args...> const& v) const {
     uint32_t size = checked_get_container_size(sizeof...(Args));
     o.type = msgpack::type::ARRAY;
     o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
     o.via.array.size = size;
     StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
 }
示例#17
0
     msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.pack_array(size);
     for(typename std::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
         it != it_end; ++it) {
         o.pack(*it);
     }
     return o;
 }
示例#18
0
     msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_map<K, V, Hash, Compare, Alloc>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.pack_map(size);
     for(typename std::unordered_map<K, V, Hash, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
         it != it_end; ++it) {
         o.pack(it->first);
         o.pack(it->second);
     }
     return o;
 }
示例#19
0
 clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.pack_map(size);
     for(typename MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>::const_iterator it(v.begin()), it_end(v.end());
         it != it_end; ++it) {
         o.pack(it->first);
         o.pack(it->second);
     }
     return o;
 }
示例#20
0
 void operator()(clmdep_msgpack::object::with_zone& o, const std::forward_list<T, Alloc>& v) const {
     o.type = clmdep_msgpack::type::ARRAY;
     if(v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
         o.via.array.size = size;
         clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(
             o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
         o.via.array.ptr = p;
         for(auto const& e : v) *p++ = clmdep_msgpack::object(e, o.zone);
     }
 }
示例#21
0
文件: set.hpp 项目: rpclib/rpclib
 void operator()(clmdep_msgpack::object::with_zone& o, const std::multiset<T, Compare, Alloc>& v) const {
     o.type = clmdep_msgpack::type::ARRAY;
     if (v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
         clmdep_msgpack::object* const pend = p + size;
         o.via.array.ptr = p;
         o.via.array.size = size;
         typename std::multiset<T, Compare, Alloc>::const_iterator it(v.begin());
         do {
             *p = clmdep_msgpack::object(*it, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
示例#22
0
 void operator()(msgpack::object::with_zone& o, const std::unordered_map<K, V, Hash, Compare, Alloc>& v) const {
     o.type = msgpack::type::MAP;
     if(v.empty()) {
         o.via.map.ptr  = nullptr;
         o.via.map.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
         msgpack::object_kv* const pend = p + size;
         o.via.map.ptr  = p;
         o.via.map.size = size;
         typename std::unordered_map<K, V, Hash, Compare, Alloc>::const_iterator it(v.begin());
         do {
             p->key = msgpack::object(it->first, o.zone);
             p->val = msgpack::object(it->second, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
示例#23
0
文件: set.hpp 项目: BrainlessLabs/bun
 void operator()(msgpack::object::with_zone& o, const std::set<T, Compare, Alloc>& v) const {
     o.type = msgpack::type::ARRAY;
     if (v.empty()) {
         o.via.array.ptr = MSGPACK_NULLPTR;
         o.via.array.size = 0;
     }
     else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
         msgpack::object* const pend = p + size;
         o.via.array.ptr = p;
         o.via.array.size = size;
         typename std::set<T, Compare, Alloc>::const_iterator it(v.begin());
         do {
             *p = msgpack::object(*it, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
示例#24
0
 void operator()(msgpack::object& o, const std::array<char, N>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = msgpack::type::BIN;
     o.via.bin.ptr = v.data();
     o.via.bin.size = size;
 }
示例#25
0
 void operator()(clmdep_msgpack::object& o, const std::array<unsigned char, N>& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = clmdep_msgpack::type::BIN;
     o.via.bin.ptr = reinterpret_cast<char const*>(v.data());
     o.via.bin.size = size;
 }
示例#26
0
 void operator()(clmdep_msgpack::object& o, const boost::string_ref& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.type = clmdep_msgpack::type::STR;
     o.via.str.ptr = v.data();
     o.via.str.size = size;
 }
示例#27
0
 clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const boost::string_ref& v) const {
     uint32_t size = checked_get_container_size(v.size());
     o.pack_str(size);
     o.pack_str_body(v.data(), size);
     return o;
 }
示例#28
0
 clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const std::forward_list<T, Alloc>& v) const {
     uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
     o.pack_array(size);
     for(auto const& e : v) o.pack(e);
     return o;
 }
示例#29
0
 void operator()(msgpack::object& o, const char(&v)[N]) const {
     uint32_t size = checked_get_container_size(std::strlen(v));
     o.type = msgpack::type::STR;
     o.via.str.ptr = v;
     o.via.str.size = size;
 }