本文整理汇总了C++中FileStorage::Save方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStorage::Save方法的具体用法?C++ FileStorage::Save怎么用?C++ FileStorage::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStorage
的用法示例。
在下文中一共展示了FileStorage::Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
try
{
po::options_description desc("v0.1,\nSupported options");
desc.add_options()( //
"help,h", "produce help message")( //
"version,v", "version information")( //
"input,i", po::value<string>(), "specify input file")( //
"output,o", po::value<string>(), "specify output file");
po::positional_options_description p;
p.add("input", -1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv) //
.options(desc).positional(p).run(),
vm);
po::notify(vm);
if (vm.count("help"))
{
cout << desc << "\n";
return 1;
}
if (vm.count("version"))
{
cout << desc << "\n";
return 1;
}
bool error = false;
if (vm.count("input"))
{
cout << "Input file was set to " << vm["input"].as<string>() << "." << endl;
}
else
{
error = true;
cout << "Input file was not set, but this is required." << endl;
}
if (vm.count("output"))
{
cout << "Output file was set to " << vm["output"].as<string>() << "." << endl;
}
else
{
cout << "Output file was not set." << endl;
}
if (error)
{
cout << "Abort program. Use --help to get a list of the available options." << endl;
return 1;
}
FileStorage storage;
storage.SetFilter(boost::shared_ptr<FilterIsActive>(new FilterIsActive()));
storage.Load(vm["input"].as<string>());
storage.Save(vm["output"].as<string>());
cout << "Saved the active articles from " << vm["input"].as<string>();
cout << " into " << vm["output"].as<string>() << ".\n";
}
catch (exception& e)
{
cerr << "error: " << e.what() << endl;
return 1;
}
catch (std::string const& e)
{
cerr << "error: " << e << endl;
cout << "Current directory: " << fs::initial_path() << endl;
return 1;
}
catch (...)
{
cerr << "Exception of unknown type!" << endl;
}
return 0;
}