This example demonstrates how to use EnvironmentFactory and the resultant Environment.
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace paludis;
using namespace examples;
using std::cout;
using std::endl;
using std::left;
using std::setw;
int main(int argc, char * argv[])
{
int exit_status(0);
try
{
CommandLine::get_instance()->run(argc, argv,
"example_environment", "EXAMPLE_ENVIRONMENT_OPTIONS", "EXAMPLE_ENVIRONMENT_CMDLINE");
CommandLine::get_instance()->a_environment.argument()));
std::shared_ptr<const SetSpecTree> world(env->set(
SetName(
"world")));
if (world)
{
cout << "World set exists" << endl;
}
else
cout << "No world set defined" << 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_status;
}