This example demonstrates how to use VersionSpec.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <set>
using namespace paludis;
using namespace examples;
using std::cout;
using std::endl;
using std::setw;
using std::left;
using std::boolalpha;
using std::hex;
int main(int argc, char * argv[])
{
try
{
CommandLine::get_instance()->run(argc, argv,
"example_version_spec", "EXAMPLE_VERSION_SPEC_OPTIONS", "EXAMPLE_VERSION_SPEC_CMDLINE");
std::set<VersionSpec> versions;
for (std::set<VersionSpec>::const_iterator v(versions.begin()), v_end(versions.end()) ;
v != v_end ; ++v)
{
cout << *v << ":" << endl;
cout << " " << left << setw(24) << "Hash value:" << " " << "0x" << hex << v->hash() << endl;
cout << " " << left << setw(24) << "Remove revision:" << " " << v->remove_revision() << endl;
cout << " " << left << setw(24) << "Revision only:" << " " << v->revision_only() << endl;
cout << " " << left << setw(24) << "Bump:" << " " << v->bump() << endl;
cout << " " << left << setw(24) << "Is scm?" << " " << boolalpha << v->is_scm() << endl;
cout << " " << left << setw(24) << "Has -try?" << " " << boolalpha << v->has_try_part() << endl;
cout << " " << left << setw(24) << "Has -scm?" << " " << boolalpha << v->has_scm_part() << 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;
}