本文整理汇总了C++中msgpack::object类的典型用法代码示例。如果您正苦于以下问题:C++ object类的具体用法?C++ object怎么用?C++ object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
);
}
示例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));
}
}
示例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;
}
示例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);
}
示例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_);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
}
示例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);
}
示例14: unpack
void bit_index_storage::unpack(msgpack::object o) {
o.convert(this);
}
示例15: unpack
void recommender_mock_storage::unpack(msgpack::object o) {
o.convert(this);
}