This example demonstrates how to handle dependency specs.
#include <paludis/paludis.hh>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <list>
#include <map>
#include <sstream>
using namespace examples;
using std::cout;
using std::endl;
using std::setw;
using std::left;
int main(int argc, char * argv[])
{
try
{
"example_dep_spec", "EXAMPLE_DEP_SPEC_OPTIONS", "EXAMPLE_DEP_SPEC_CMDLINE");
{
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 << requirement.version_operator() << requirement.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 << requirement->as_raw_string() + " (meaning: " + requirement->as_human_string(nullptr) + ")";
need_join = true;
}
cout << endl;
}
cout << " " << left << setw(24) << "Matches:" << " ";
bool need_indent(false);
for (const auto & id : *ids)
{
if (need_indent)
cout << " " << left << setw(24) << "" << " ";
cout << *id << 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;
}
Definition exception.hh:77
std::string backtrace(const std::string &delim) const
const char * what() const noexcept override
const std::string & message() const noexcept
Definition exception.hh:134
Definition dep_spec.hh:348
std::shared_ptr< const AdditionalPackageDepSpecRequirements > additional_requirements_ptr() const
std::shared_ptr< const FSPath > installed_at_path_ptr() const
std::shared_ptr< const SlotRequirement > slot_requirement_ptr() const
std::shared_ptr< const InstallableToRepository > installable_to_repository_ptr() const
std::shared_ptr< const InstallableToPath > installable_to_path_ptr() const
std::shared_ptr< const VersionRequirements > version_requirements_ptr() const
std::shared_ptr< const QualifiedPackageName > package_ptr() const
VersionRequirementsMode version_requirements_mode() const
std::shared_ptr< const CategoryNamePart > category_name_part_ptr() const
std::shared_ptr< const PackageNamePart > package_name_part_ptr() const
std::shared_ptr< const RepositoryName > in_repository_ptr() const
std::shared_ptr< const RepositoryName > from_repository_ptr() const
static CommandLine * get_instance() PALUDIS_ATTRIBUTE((warn_unused_result))
Definition generator.hh:160
Definition selection.hh:172
PackageDepSpec parse_user_package_dep_spec(const std::string &, const Environment *const, const UserPackageDepSpecOptions &, const Filter &=filter::All()) PALUDIS_VISIBLE
@ vr_and
< Must match one
Definition version_requirements-fwd.hh:57
@ last_vr
< Must match all
Definition version_requirements-fwd.hh:58
#define PALUDIS_HERE
Definition exception.hh:217
Definition about_metadata-fwd.hh:24