当前位置: 首页>>代码示例>>C++>>正文


C++ SettingsResponseMessage::ParseFromString方法代码示例

本文整理汇总了C++中plugin::SettingsResponseMessage::ParseFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ SettingsResponseMessage::ParseFromString方法的具体用法?C++ SettingsResponseMessage::ParseFromString怎么用?C++ SettingsResponseMessage::ParseFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plugin::SettingsResponseMessage的用法示例。


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

示例1:

nscapi::settings_proxy::string_list nscapi::settings_proxy::get_keys(std::string path) {
	nscapi::settings_proxy::string_list ret;
	Plugin::SettingsRequestMessage request;
	nscapi::protobuf::functions::create_simple_header(request.mutable_header());
	Plugin::SettingsRequestMessage::Request *payload = request.add_payload();
	payload->set_plugin_id(plugin_id_);
	Plugin::SettingsRequestMessage::Request::Query *item = payload->mutable_query();
	item->mutable_node()->set_path(path);
	item->set_type(Plugin::Common_DataType_LIST);
	item->set_recursive(false);

	std::string response_string;
	core_->settings_query(request.SerializeAsString(), response_string);
	Plugin::SettingsResponseMessage response;
	response.ParseFromString(response_string);


	if (response.payload_size() != 1 || !response.payload(0).has_query()) {
		return ret;
	}

	const ::Plugin::Common_AnyDataType value = response.payload(0).query().value();

	for (int i=0;i<value.list_data_size();++i) {
		ret.push_back(value.list_data(i));
	}
	return ret;
}
开发者ID:Vilse1202,项目名称:nscp,代码行数:28,代码来源:nscapi_settings_proxy.cpp

示例2: request

NSCAPI::errorReturn NSCAPIProtobuf2Json(const char* object, const char* request_buffer, unsigned int request_buffer_len, char ** response_buffer, unsigned int *response_buffer_len) {
	std::string request(request_buffer, request_buffer_len), response, obj(object);
	try {
		json_spirit::Object root;
		if (obj == "SettingsResponseMessage") {
			Plugin::SettingsResponseMessage message;
			message.ParseFromString(request);
			root = json_pb::Plugin::SettingsResponseMessage::to_json(message);
		} else if (obj == "RegistryResponseMessage") {
			Plugin::RegistryResponseMessage message;
			message.ParseFromString(request);
			root = json_pb::Plugin::RegistryResponseMessage::to_json(message);
		} else if (obj == "QueryResponseMessage") {
			Plugin::QueryResponseMessage message;
			message.ParseFromString(request);
			root = json_pb::Plugin::QueryResponseMessage::to_json(message);
		} else {
			LOG_ERROR_STD("Invalid type: " + obj);
			return NSCAPI::hasFailed;
		}
		std::string response = json_spirit::write(root);
		*response_buffer_len = static_cast<unsigned int>(response.size());
		if (response.empty())
			*response_buffer = NULL;
		else {
			*response_buffer = new char[*response_buffer_len + 10];
			memcpy(*response_buffer, response.c_str(), *response_buffer_len);
		}
	} catch (const json_spirit::ParseError &e) {
		LOG_ERROR_STD("Failed to parse JSON: " + e.reason_);
		return NSCAPI::hasFailed;
	}
	return NSCAPI::isSuccess;
}
开发者ID:TaylorMonacelli,项目名称:nscp,代码行数:34,代码来源:core_api.cpp

示例3:

void nscapi::settings_proxy::set_string(std::string path, std::string key, std::string value) {
	Plugin::SettingsRequestMessage request;
	nscapi::protobuf::functions::create_simple_header(request.mutable_header());
	Plugin::SettingsRequestMessage::Request *payload = request.add_payload();
	payload->set_plugin_id(plugin_id_);
	Plugin::SettingsRequestMessage::Request::Update *item = payload->mutable_update();
	item->mutable_node()->set_key(key);
	item->mutable_node()->set_path(path);
	item->mutable_value()->set_string_data(value);

	std::string response_string;
	core_->settings_query(request.SerializeAsString(), response_string);
	Plugin::SettingsResponseMessage response;
	response.ParseFromString(response_string);
	report_errors(response, core_, "update " + path + "." + key);
}
开发者ID:TaylorMonacelli,项目名称:nscp,代码行数:16,代码来源:nscapi_settings_proxy.cpp


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