本文整理汇总了C++中plugin::SettingsRequestMessage::mutable_header方法的典型用法代码示例。如果您正苦于以下问题:C++ SettingsRequestMessage::mutable_header方法的具体用法?C++ SettingsRequestMessage::mutable_header怎么用?C++ SettingsRequestMessage::mutable_header使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin::SettingsRequestMessage
的用法示例。
在下文中一共展示了SettingsRequestMessage::mutable_header方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}