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

C++ settingsrequestmessage::Request类代码示例

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

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



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

示例1: settings_inventory

	void settings_inventory(Mongoose::Request &request, Mongoose::StreamResponse &response) {
		if (!is_loggedin(request, response, password))
			return;
		Plugin::SettingsRequestMessage rm;
		nscapi::protobuf::functions::create_simple_header(rm.mutable_header());
		Plugin::SettingsRequestMessage::Request *payload = rm.add_payload();
		if (request.get("paths", "false") == "true")
			payload->mutable_inventory()->set_fetch_paths(true);
		if (request.get("keys", "false") == "true")
			payload->mutable_inventory()->set_fetch_keys(true);
		if (request.get("recursive", "false") == "true")
			payload->mutable_inventory()->set_recursive_fetch(true);
		if (request.get("samples", "false") == "true")
			payload->mutable_inventory()->set_fetch_samples(true);
		if (request.get("desc", "false") == "true")
			payload->mutable_inventory()->set_descriptions(true);
		std::string path = request.get("path", "");
		if (!path.empty())
			payload->mutable_inventory()->mutable_node()->set_path(path);
		std::string key = request.get("key", "");
		if (!key.empty())
			payload->mutable_inventory()->mutable_node()->set_key(key);
		std::string module = request.get("module", "");
		if (!module.empty())
			payload->mutable_inventory()->set_plugin(module);
		payload->set_plugin_id(plugin_id);

		std::string pb_response, json_response;
		core->settings_query(rm.SerializeAsString(), pb_response);
		core->protobuf_to_json("SettingsResponseMessage", pb_response, json_response);
		response << json_response;
	}
开发者ID:zyberpunker,项目名称:nscp,代码行数:32,代码来源:WEBServer.cpp


示例2:

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


示例3: settings_status

	void settings_status(Mongoose::Request &request, Mongoose::StreamResponse &response) {
		if (!is_loggedin(request, response, password))
			return;
		Plugin::SettingsRequestMessage rm;
		nscapi::protobuf::functions::create_simple_header(rm.mutable_header());
		Plugin::SettingsRequestMessage::Request *payload = rm.add_payload();
		payload->mutable_status();
		payload->set_plugin_id(plugin_id);

		std::string pb_response, json_response;
		core->settings_query(rm.SerializeAsString(), pb_response);
		core->protobuf_to_json("SettingsResponseMessage", pb_response, json_response);
		response << json_response;
	}
开发者ID:zyberpunker,项目名称:nscp,代码行数:14,代码来源:WEBServer.cpp


示例4:

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


示例5: get_key

void settings_controller::get_key(Mongoose::Request &request, boost::smatch &what, Mongoose::StreamResponse &response) {
	if (!session->is_loggedin("settings", request, response))
		return;

	if (!validate_arguments(2, what, response)) {
		return;
	}
	std::string path = what.str(1);
	std::string key = what.str(2);

	if (!session->can("settings.get", request, response))
		return;

	Plugin::SettingsRequestMessage rm;
	Plugin::SettingsRequestMessage::Request *payload = rm.add_payload();
	payload->mutable_query()->mutable_node()->set_path(path);
	payload->mutable_query()->mutable_node()->set_key(key);
	payload->mutable_query()->set_recursive(false);
	payload->set_plugin_id(plugin_id);

	std::string str_response;
	core->settings_query(rm.SerializeAsString(), str_response);
	Plugin::SettingsResponseMessage pb_response;
	pb_response.ParseFromString(str_response);
	json_spirit::Object node;

	BOOST_FOREACH(const Plugin::SettingsResponseMessage::Response r, pb_response.payload()) {
		if (!r.has_query()) {
			response.setCode(HTTP_NOT_FOUND);
			response.append("Key not found: " + path + "/" + key);
			return;
		}
		const Plugin::SettingsResponseMessage::Response::Query &i = r.query();
		node["path"] = i.node().path();
		node["key"] = i.node().key();
		if (i.value().has_string_data()) {
			node["value"] = i.value().string_data();
		} else if (i.value().has_int_data()) {
			node["value"] = i.value().int_data();
		} else if (i.value().has_bool_data()) {
			node["value"] = i.value().bool_data();
		}
	}
	response.append(json_spirit::write(node));
}
开发者ID:mickem,项目名称:nscp,代码行数:45,代码来源:settings_controller.cpp


示例6: get_section

void settings_controller::get_section(Mongoose::Request &request, boost::smatch &what, Mongoose::StreamResponse &response) {
	if (!session->is_loggedin("settings.list", request, response))
		return;

	if (!validate_arguments(1, what, response)) {
		return;
	}

	std::string path = what.str(1);

	Plugin::SettingsRequestMessage rm;
	Plugin::SettingsRequestMessage::Request *payload = rm.add_payload();
	payload->mutable_query()->mutable_node()->set_path(path);
	payload->mutable_query()->set_recursive(false);
	payload->set_plugin_id(plugin_id);
	payload = rm.add_payload();
	payload->mutable_query()->mutable_node()->set_path(path);
	payload->mutable_query()->set_recursive(true);
	payload->set_plugin_id(plugin_id);

	std::string str_response;
	core->settings_query(rm.SerializeAsString(), str_response);
	Plugin::SettingsResponseMessage pb_response;
	pb_response.ParseFromString(str_response);
	json_spirit::Object node;
	node["path"] = path;

	if (pb_response.payload_size() != 2) {
		response.setCode(HTTP_SERVER_ERROR);
		response.append("Failed to fetch keys");
		return;
	}

	const Plugin::SettingsResponseMessage::Response rKeys = pb_response.payload(0);
	if (!rKeys.has_query()) {
		response.setCode(HTTP_NOT_FOUND);
		response.append("Key not found: " + path);
		return;
	}

	json_spirit::Array keys;
	BOOST_FOREACH(const std::string &s, rKeys.query().value().list_data()) {
		keys.push_back(s);
	}
	node["keys"] = keys;

	const Plugin::SettingsResponseMessage::Response rPath = pb_response.payload(1);
	if (!rPath.has_query()) {
		response.setCode(HTTP_NOT_FOUND);
		response.append("Key not found: " + path);
		return;
	}
	json_spirit::Array paths;
	BOOST_FOREACH(const std::string &s, rPath.query().value().list_data()) {
		paths.push_back(s);
	}
	node["paths"] = paths;


	response.append(json_spirit::write(node));
}
开发者ID:mickem,项目名称:nscp,代码行数:61,代码来源:settings_controller.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ plugins::FactoryManager类代码示例发布时间:2022-05-31
下一篇:
C++ queryrequestmessage::Request类代码示例发布时间: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