• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ msgpack::object类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中msgpack::object的典型用法代码示例。如果您正苦于以下问题:C++ object类的具体用法?C++ object怎么用?C++ object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了object类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dispatch_student_record

    void dispatch_student_record(msgpack::object const& obj)
    {
        student_record sr;
        obj.convert(&sr);

        evaluation eval = make_evaluation(sr);

        msgpack::sbuffer ebuf;
        msgpack::pack(ebuf, eval);

        char *obuf_cusor = outgoing_buf_;
        int32_t omsg_id = EVALUATION;
        int32_t omsglen = sizeof(omsg_id) + ebuf.size();
        size_t olen = sizeof(omsglen) + omsglen;
        ensure_outgoing_buf_capa(olen);

        memcpy(obuf_cusor, &omsglen, sizeof(omsglen));
        obuf_cusor += sizeof(omsglen);
        memcpy(obuf_cusor, &omsg_id, sizeof(omsg_id));
        obuf_cusor += sizeof(omsg_id);
        memcpy(obuf_cusor, ebuf.data(), ebuf.size());

        boost::asio::async_write(socket_,
                boost::asio::buffer(outgoing_buf_, olen),
                boost::bind(&tcp_connection::handle_write,
                    shared_from_this(),
                    boost::asio::placeholders::error,
                    boost::asio::placeholders::bytes_transferred)
                );
    }
开发者ID:jayden717,项目名称:boost_asio_msgpack_ex,代码行数:30,代码来源:msgpack_test_server.cpp


示例2: unmarshal

void wamp_hello_details::unmarshal(const msgpack::object& object)
{
    std::unordered_map<std::string, msgpack::object> details;
    object.convert(&details);

    auto details_itr = details.find("roles");
    if (details_itr == details.end()) {
        return;
    }

    std::unordered_map<std::string, msgpack::object> roles;
    details_itr->second.convert(roles);

    for (const auto& roles_itr : roles) {
        std::unordered_map<std::string, msgpack::object> properties;
        roles_itr.second.convert(properties);

        wamp_role_features features;
        auto properties_itr = properties.find("features");
        if (properties_itr != properties.end()) {
            std::unordered_map<std::string, bool> attributes;
            properties_itr->second.convert(attributes);
            features.set_attributes(std::move(attributes));
        }

        wamp_role_type role_type = role_type_from_string(roles_itr.first);
        wamp_role role(role_type);

        role.set_features(std::move(features));
        add_role(std::move(role));
    }
}
开发者ID:VinnyOG,项目名称:bonefish,代码行数:32,代码来源:wamp_hello_details.cpp


示例3: unpack_message

auto unpack_message(Ret(*fptr)(Args...), const msgpack::object &obj) {
  (void)fptr;
  msgpack::type::tuple<
    typename std::decay<Args>::type...> msg;
  obj.convert(msg);
  return msg;
}
开发者ID:stanionascu,项目名称:smoc,代码行数:7,代码来源:rpc-pack.hpp


示例4: msgpack_unpack

void Settings::msgpack_unpack(msgpack::object o)
{
	std::string data;
	o.convert(&data);
	std::istringstream os(data, std::ios_base::binary);
	os >> m_json;
	fromJson(m_json);
}
开发者ID:Falcon-peregrinus,项目名称:freeminer,代码行数:8,代码来源:settings.cpp


示例5: unpack

void simple_storage::unpack(msgpack::object o) {
  std::vector<msgpack::object> mems;
  o.convert(&mems);
  if (mems.size() != 2) {
    throw msgpack::type_error();
  }
  mems[0].convert(static_cast<storage*>(this));
  mems[1].convert(&mine_);
}
开发者ID:gwtnb,项目名称:jubatus_core,代码行数:9,代码来源:simple_storage.cpp


示例6: if

inline std::vector<msgpack::object> wamp_publish_message::marshal() const
{
    std::vector<msgpack::object> fields;

    if (!m_arguments_kw.is_nil()) {
        if (!m_arguments.is_nil()) {
            fields = { m_type, m_request_id, m_options, m_topic, m_arguments, m_arguments_kw };
        } else {
            fields = { m_type, m_request_id, m_options, m_topic, msgpack_empty_map(), m_arguments_kw };
        }
    } else if (!m_arguments.is_nil()) {
        fields = { m_type, m_request_id, m_options, m_topic, m_arguments };
    } else {
        fields = { m_type, m_request_id, m_options, m_topic };
    }

    return fields;
}
开发者ID:VinnyOG,项目名称:bonefish,代码行数:18,代码来源:wamp_publish_message.hpp


示例7: dispatch_evaluation

void dispatch_evaluation(msgpack::object const& obj)
{
    evaluation eval;
    obj.convert(&eval);

    std::cout << eval.get_remark() <<
        ", result = " <<
        (eval.get_passed() ? "Passed!" : "Failure!") <<
        std::endl;
}
开发者ID:jayden717,项目名称:boost_asio_msgpack_ex,代码行数:10,代码来源:msgpack_test_client.cpp


示例8: if

inline std::vector<msgpack::object> wamp_event_message::marshal() const
{
    std::vector<msgpack::object> fields;

    if (!m_arguments_kw.is_nil()) {
        if (!m_arguments.is_nil()) {
            fields = { m_type, m_subscription_id, m_publication_id, m_details,
                    m_arguments, m_arguments_kw };
        } else {
            fields = { m_type, m_subscription_id, m_publication_id, m_details,
                    msgpack_empty_map(), m_arguments_kw };
        }
    } else if (!m_arguments.is_nil()) {
        fields = { m_type, m_subscription_id, m_publication_id, m_details, m_arguments };
    } else {
        fields = { m_type, m_subscription_id, m_publication_id, m_details };
    }

    return fields;
}
开发者ID:gaolj,项目名称:bonefish,代码行数:20,代码来源:wamp_event_message.hpp


示例9: msgpack_unpack

  void msgpack_unpack(msgpack::object o)
  {
    msgpack::type::tuple<bool, msgpack::object> tuple;
    o.convert(&tuple);

    is_double = tuple.get<0>();
    if (is_double)
      tuple.get<1>().convert(&value.f);
    else
      tuple.get<1>().convert(&value.i);
  }
开发者ID:AnggaSuherman,项目名称:griddb_nosql,代码行数:11,代码来源:msgpack_container.cpp


示例10: unpack

void compressive_storage::unpack(msgpack::object o) {
  std::vector<msgpack::object> mems;
  o.convert(&mems);
  if (mems.size() != 4) {
    throw msgpack::type_error();
  }
  mems[0].convert(static_cast<storage*>(this));
  mems[1].convert(&mine_);
  mems[2].convert(&status_);
  mems[3].convert(compressor_.get());
}
开发者ID:gwtnb,项目名称:jubatus_core,代码行数:11,代码来源:compressive_storage.cpp


示例11: endpoint_drop

void DBServer::endpoint_drop(const msgpack::object& request,
                             Packer* reply_header,
                             Packer* reply_data) {
    reply_header->pack_map(header_sizes::DROP);
    std::map<std::string, std::string> msg;
    try {
        request.convert(msg);
    } catch (msgpack::type_error& e) {
        // TODO: log error, message cannot be deserialized
        set_status(status_codes::DESERIALIZATION_ERROR,
                   "Deserialization failed.",
                   e.what(),
                   reply_header);
        return;
    }
    std::string name;
    std::string path;
    try {
        name = msg["database"];
        path = msg["path"];
    } catch (std::out_of_range& e) {
        set_status(status_codes::INVALID_REQUEST,
                   "Missing database name or path.",
                   "",
                   reply_header);
        return;
    }
    if (!databases_.count(name)) {
        set_status(status_codes::INVALID_REQUEST,
                   "Database name not found.",
                   name,
                   reply_header);
        return;
    }
    std::shared_ptr<Database> db = databases_.at(name);
    if (db->path() != path) {
        set_status(status_codes::INVALID_REQUEST,
                   "Database paths do not match.",
                   path + " != " + db->path(),
                   reply_header);
        return;
    }
    databases_.erase(name);
    db->close();
    std::remove(path.c_str());
    set_status(status_codes::OK, response_messages::OK, "", reply_header);
}
开发者ID:Outernet-Project,项目名称:sqlizator,代码行数:47,代码来源:server.cpp


示例12: msgpack_unpack

void CNodeDefManager::msgpack_unpack(msgpack::object o)
{
	clear();

	std::map<int, ContentFeatures> unpacked_features;
	o.convert(&unpacked_features);

	for (std::map<int, ContentFeatures>::iterator it = unpacked_features.begin();
			it != unpacked_features.end(); ++it) {
		unsigned int i = it->first;
		ContentFeatures f = it->second;

		if(i == CONTENT_IGNORE || i == CONTENT_AIR
				|| i == CONTENT_UNKNOWN){
			infostream<<"NodeDefManager::deSerialize(): WARNING: "
				<<"not changing builtin node "<<i
				<<std::endl;
			continue;
		}
		if(f.name == ""){
			infostream<<"NodeDefManager::deSerialize(): WARNING: "
				<<"received empty name"<<std::endl;
			continue;
		}
		u16 existing_id;
		bool found = m_name_id_mapping.getId(f.name, existing_id);  // ignore aliases
		if(found && i != existing_id){
			infostream<<"NodeDefManager::deSerialize(): WARNING: "
				<<"already defined with different ID: "
				<<f.name<<std::endl;
			continue;
		}

		// All is ok, add node definition with the requested ID
		if(i >= m_content_features.size())
			m_content_features.resize((u32)(i) + 1);
		m_content_features[i] = f;
		addNameIdMapping(i, f.name);
		verbosestream<<"deserialized "<<f.name<<std::endl;
	}
}
开发者ID:cyisfor,项目名称:freeminer,代码行数:41,代码来源:nodedef.cpp


示例13: endpoint_query

void DBServer::endpoint_query(const msgpack::object& request,
                              Packer* reply_header,
                              Packer* reply_data) {
    reply_header->pack_map(header_sizes::QUERY);
    MsgType msg;
    try {
        request.convert(msg);
    } catch (msgpack::type_error& e) {
        // TODO: log error, message cannot be deserialized
        set_status(status_codes::DESERIALIZATION_ERROR,
                   "Deserialization failed.",
                   e.what(),
                   reply_header);
        write_query_header_defaults(reply_header);
        return;
    }
    if (!databases_.count(msg.database)) {
        set_status(status_codes::DATABASE_NOT_FOUND,
                   "Database not found.",
                   msg.database,
                   reply_header);
        return;
    }
    Database& db = *databases_.at(msg.database);
    try {
        db.query(msg.operation,
                 msg.query,
                 msg.parameters,
                 reply_header,
                 reply_data);
    } catch (sqlite_error& e) {
        // TODO: log error, invalid query
        set_status(status_codes::INVALID_QUERY,
                   e.what(),
                   e.extended(),
                   reply_header);
        write_query_header_defaults(reply_header);
        return;
    }
    set_status(status_codes::OK, response_messages::OK, "", reply_header);
}
开发者ID:Outernet-Project,项目名称:sqlizator,代码行数:41,代码来源:server.cpp


示例14: unpack

void bit_index_storage::unpack(msgpack::object o) {
  o.convert(this);
}
开发者ID:gintenlabo,项目名称:jubatus_core,代码行数:3,代码来源:bit_index_storage.cpp


示例15: unpack

void recommender_mock_storage::unpack(msgpack::object o) {
  o.convert(this);
}
开发者ID:AutonomicSecurity,项目名称:jubatus,代码行数:3,代码来源:recommender_mock_storage.cpp


示例16:

void ucb1::unpack(msgpack::object o) {
  o.convert(&s_);
}
开发者ID:nagyistoce,项目名称:jubatus-core,代码行数:3,代码来源:ucb1.cpp


示例17: unpack

void aggregator::unpack(msgpack::object o) {
  JUBATUS_ASSERT(p_);
  o.convert(p_.get());
}
开发者ID:gintenlabo,项目名称:jubatus_core,代码行数:4,代码来源:aggregator.cpp


示例18: unpack

 void unpack(msgpack::object o) {
   util::concurrent::scoped_lock lk(mutex_);
   o.convert(this);
 }
开发者ID:TkrUdagawa,项目名称:jubatus_core,代码行数:4,代码来源:weight_manager.hpp


示例19: operator

 std::optional<T> operator()(msgpack::object const& o) const {
     if(o.is_nil()) return std::nullopt;
     return o.as<T>();
 }
开发者ID:BrainlessLabs,项目名称:bun,代码行数:4,代码来源:optional.hpp


示例20: unpack

void local_storage::unpack(msgpack::object o) {
  o.convert(this);
}
开发者ID:AutonomicSecurity,项目名称:jubatus,代码行数:3,代码来源:local_storage.cpp



注:本文中的msgpack::object类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ msgpack::packer类代码示例发布时间:2022-05-31
下一篇:
C++ msgdata::View类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap