This example demonstrates how to use DepSpecFlattener. It extracts various metadata items from a package.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <map>
using namespace paludis;
using namespace examples;
using std::cout;
using std::endl;
using std::setw;
using std::left;
int main(int argc, char * argv[])
{
try
{
CommandLine::get_instance()->run(argc, argv,
"example_dep_spec_flattener", "EXAMPLE_DEP_SPEC_FLATTENER_OPTIONS", "EXAMPLE_DEP_SPEC_FLATTENER_CMDLINE");
CommandLine::get_instance()->a_environment.argument()));
i != i_end ; ++i)
{
cout << "Information about '" << **i << "':" << endl;
if ((*i)->homepage_key())
{
(*i)->homepage_key()->parse_value()->top()->accept(homepages);
cout << " " << left << setw(24) << "Homepages:" << " "
<< endl;
}
if ((*i)->end_metadata() != (*i)->find_metadata("RESTRICT") &&
{
**(*i)->find_metadata(
"RESTRICT"))->parse_value()->top()->
accept(restricts);
cout << " " << left << setw(24) << "Restricts:" << " "
<< endl;
}
cout << endl;
}
}
{
cout << endl;
cout << "Unhandled exception:" << endl
return EXIT_FAILURE;
}
catch (const std::exception & e)
{
cout << endl;
cout << "Unhandled exception:" << endl
<< " * " << e.what() << endl;
return EXIT_FAILURE;
}
catch (...)
{
cout << endl;
cout << "Unhandled exception:" << endl
<< " * Unknown exception type. Ouch..." << endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}