This example demonstrates how to handle dependency specs.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <list>
#include <map>
#include <sstream>
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", "EXAMPLE_DEP_SPEC_OPTIONS", "EXAMPLE_DEP_SPEC_CMDLINE");
CommandLine::get_instance()->a_environment.argument()));
for (CommandLine::ParametersConstIterator q(CommandLine::get_instance()->begin_parameters()),
q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
{
cout << "Information about '" << spec << "':" << endl;
cout <<
" " << left << setw(24) <<
"Package:" <<
" " << *spec.
package_ptr() << endl;
{
cout << " " << left << setw(24) << "Version requirements:" << " ";
bool need_join(false);
{
if (need_join)
{
{
cout << " and ";
break;
case vr_or:
cout << " or ";
break;
}
}
cout << r->version_operator() << r->version_spec();
need_join = true;
}
cout << endl;
}
cout << " " << left << setw(24) << "In repository:" << " " <<
cout << " " << left << setw(24) << "From repository:" << " " <<
cout << " " << left << setw(24) << "Installed at path:" << " " <<
cout << " " << left << setw(24) << "Installable to path:" << " " <<
cout << " " << left << setw(24) << "Installable to repository:" << " " <<
{
cout << " " << left << setw(24) << "Additional requirements:" << " ";
bool need_join(false);
{
if (need_join)
cout << " and ";
cout << (*u)->as_raw_string() + " (meaning: " + (*u)->as_human_string(make_null_shared_ptr()) + ")";
need_join = true;
}
cout << endl;
}
cout << " " << left << setw(24) << "Matches:" << " ";
bool need_indent(false);
i != i_end ; ++i)
{
if (need_indent)
cout << " " << left << setw(24) << "" << " ";
cout << **i << endl;
need_indent = true;
}
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;
}