本文整理汇总了C++中ObjectFactory::build_object方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectFactory::build_object方法的具体用法?C++ ObjectFactory::build_object怎么用?C++ ObjectFactory::build_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectFactory
的用法示例。
在下文中一共展示了ObjectFactory::build_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
std::string resp_str = "";
rapidjson::Document d;
protoObj3::Obj3List new_proto;
// Convert the OMQ message into a string to be passed on the event
char * req_ptr = zmqi->crecv();
if (!req_ptr) continue;
main_logging->debug("Conversion to C String performed with result: ");
main_logging->debug(req_ptr);
// Trim the string recieved
std::string recvd_msg(req_ptr);
std::string clean_string;
std::string new_error_message = "";
// Parsing logic - JSON
if (config->get_formattype() == JSON_FORMAT) {
response_message = ofactory.build_json_object_list();
int final_closing_char = recvd_msg.find_last_of("}");
int first_opening_char = recvd_msg.find_first_of("{");
clean_string = \
recvd_msg.substr(first_opening_char, final_closing_char+1);
main_logging->debug("Input String Cleaned");
main_logging->debug(clean_string);
try {
d.Parse<rapidjson::kParseStopWhenDoneFlag>(clean_string.c_str());
if (d.HasParseError()) {
main_logging->error("Parsing Error: ");
main_logging->error(GetParseError_En(d.GetParseError()));
response_message->set_error_code(TRANSLATION_ERROR);
new_error_message.assign(GetParseError_En(d.GetParseError()));
} else {inbound_message = ofactory.build_object_list(d);}
}
// Catch a possible error and write to logs
catch (std::exception& e) {
main_logging->error("Exception occurred while parsing document:");
main_logging->error(e.what());
}
// Parsing logic - Protocol Buffers
} else if (config->get_formattype() == PROTO_FORMAT) {
response_message = ofactory.build_proto_object_list();
clean_string = trim(recvd_msg);
main_logging->debug("Input String Cleaned");
main_logging->debug(clean_string);
try {
new_proto.ParseFromString(clean_string);
inbound_message = ofactory.build_object_list(new_proto);
} catch (std::exception& e) {
main_logging->error("Exception occurred while parsing bytes:");
main_logging->error(e.what());
response_message->set_error_code(TRANSLATION_ERROR);
new_error_message.assign(e.what());
}
}
// Determine the Transaction ID
UuidContainer id_container;
id_container.id = "";
if (config->get_transactionidsactive() && inbound_message) {
// Get an existing transaction ID
std::string existing_trans_id = \
inbound_message->get_transaction_id();
// If no transaction ID is sent in, generate a new one