本文整理汇总了C++中host::Ptr::GetVars方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::GetVars方法的具体用法?C++ Ptr::GetVars怎么用?C++ Ptr::GetVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host::Ptr
的用法示例。
在下文中一共展示了Ptr::GetVars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCheckableCommandArgs
/* service */
String CompatUtility::GetCheckableCommandArgs(const Checkable::Ptr& checkable)
{
CheckCommand::Ptr command = checkable->GetCheckCommand();
Dictionary::Ptr args = new Dictionary();
if (command) {
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
String command_line = GetCommandLine(command);
Dictionary::Ptr command_vars = command->GetVars();
if (command_vars) {
ObjectLock olock(command_vars);
for (const Dictionary::Pair& kv : command_vars) {
String macro = "$" + kv.first + "$"; // this is too simple
if (command_line.Contains(macro))
args->Set(kv.first, kv.second);
}
}
Dictionary::Ptr host_vars = host->GetVars();
if (host_vars) {
ObjectLock olock(host_vars);
for (const Dictionary::Pair& kv : host_vars) {
String macro = "$" + kv.first + "$"; // this is too simple
if (command_line.Contains(macro))
args->Set(kv.first, kv.second);
macro = "$host.vars." + kv.first + "$";
if (command_line.Contains(macro))
args->Set(kv.first, kv.second);
}
}
if (service) {
Dictionary::Ptr service_vars = service->GetVars();
if (service_vars) {
ObjectLock olock(service_vars);
for (const Dictionary::Pair& kv : service_vars) {
String macro = "$" + kv.first + "$"; // this is too simple
if (command_line.Contains(macro))
args->Set(kv.first, kv.second);
macro = "$service.vars." + kv.first + "$";
if (command_line.Contains(macro))
args->Set(kv.first, kv.second);
}
}
}
String arg_string;
ObjectLock olock(args);
for (const Dictionary::Pair& kv : args) {
arg_string += Convert::ToString(kv.first) + "=" + Convert::ToString(kv.second) + "!";
}
return arg_string;
}
return Empty;
}