| 445 | } |
| 446 | |
| 447 | int ConfigCommand::Dump(const std::string& inputPath, const std::string& className) |
| 448 | { |
| 449 | ParamFile cfg; |
| 450 | if (!cfg.ParseBin(inputPath.c_str())) |
| 451 | { |
| 452 | std::cerr << "Error: failed to parse binary config: " << inputPath << std::endl; |
| 453 | return 1; |
| 454 | } |
| 455 | |
| 456 | const ParamEntry* entry = cfg.FindEntry(className.c_str()); |
| 457 | if (!entry) |
| 458 | { |
| 459 | std::cerr << "Error: class '" << className << "' not found in " << inputPath << std::endl; |
| 460 | std::cerr << "Available top-level entries (" << cfg.GetEntryCount() << "):" << std::endl; |
| 461 | for (int i = 0; i < cfg.GetEntryCount() && i < 50; i++) |
| 462 | { |
| 463 | std::cerr << " " << cfg.GetEntry(i).GetName() << std::endl; |
| 464 | } |
| 465 | return 1; |
| 466 | } |
| 467 | |
| 468 | QOStream buf; |
| 469 | entry->Save(buf, 0); |
| 470 | std::cout.write(buf.str(), buf.tellp()); |
| 471 | std::cout << std::endl; |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | int ConfigCommand::ToJson(const std::string& inputPath, const std::string& outputPath) |
| 476 | { |