| 357 | } |
| 358 | |
| 359 | HRESULT ConfigFile::PrintConfig(const ConfigItem& config, DWORD dwIndent) |
| 360 | { |
| 361 | const auto MAX_INDENT = 20; |
| 362 | |
| 363 | WCHAR szIndent[MAX_INDENT]; |
| 364 | if (dwIndent >= MAX_INDENT) |
| 365 | return E_INVALIDARG; |
| 366 | wmemset(szIndent, L'\t', MAX_INDENT); |
| 367 | szIndent[dwIndent] = L'\0'; |
| 368 | |
| 369 | switch (config.Type) |
| 370 | { |
| 371 | case ConfigItem::NODE: |
| 372 | Log::Info( |
| 373 | L"{}NODE: \"{}\" {} {}", |
| 374 | szIndent, |
| 375 | config.strName, |
| 376 | (config.Flags & ConfigItem::MANDATORY) ? L"Mandatory" : L"Optional", |
| 377 | config ? L"Present" : L"Absent"); |
| 378 | if (!config.empty()) |
| 379 | Log::Info(L"{}\tDATA: \"{}\" ", szIndent, config.c_str()); |
| 380 | |
| 381 | std::for_each(begin(config.SubItems), end(config.SubItems), [dwIndent](const ConfigItem& item) { |
| 382 | PrintConfig(item, dwIndent + 1); |
| 383 | }); |
| 384 | break; |
| 385 | |
| 386 | case ConfigItem::ATTRIBUTE: |
| 387 | Log::Info( |
| 388 | L"{}ATTRIBUTE: \"{}={}\" {} {}", |
| 389 | szIndent, |
| 390 | config.strName, |
| 391 | config.c_str(), |
| 392 | (config.Flags & ConfigItem::MANDATORY) ? L"Mandatory" : L"Optional", |
| 393 | config ? L"Present" : L"Absent"); |
| 394 | break; |
| 395 | case ConfigItem::NODELIST: { |
| 396 | Log::Info( |
| 397 | L"{}NODES: \"{}\" {} {}", |
| 398 | szIndent, |
| 399 | config.strName, |
| 400 | (config.Flags & ConfigItem::MANDATORY) ? L"Mandatory" : L"Optional", |
| 401 | config ? L"Present" : L"Absent"); |
| 402 | |
| 403 | std::for_each(begin(config.NodeList), end(config.NodeList), [dwIndent](const ConfigItem& item) { |
| 404 | PrintConfig(item, dwIndent + 1); |
| 405 | }); |
| 406 | } |
| 407 | break; |
| 408 | } |
| 409 | |
| 410 | return S_OK; |
| 411 | } |
| 412 | |
| 413 | HRESULT ConfigFile::SetOutputSpec(ConfigItem& item, const OutputSpec& outputSpec) |
| 414 | { |
no test coverage detected