diff options
author | 2011-03-26 18:58:38 +0000 | |
---|---|---|
committer | 2011-03-26 19:00:38 +0000 | |
commit | 5c2a332b70243cb583a29bb74f712bfca2c1fb76 (patch) | |
tree | 0a01f8e624caa2c6639181df45fa80bc20adba84 /doc | |
parent | 79d9f02fb355d81c472f3d94b8b85d5a7639210c (diff) | |
download | paludis-5c2a332b70243cb583a29bb74f712bfca2c1fb76.tar.gz paludis-5c2a332b70243cb583a29bb74f712bfca2c1fb76.tar.xz |
Use Environment rather than PackageDatabase
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/cplusplus/examples/Makefile.am | 7 | ||||
-rw-r--r-- | doc/api/cplusplus/examples/example_metadata_key.cc | 3 | ||||
-rw-r--r-- | doc/api/cplusplus/examples/example_package_database.cc | 100 | ||||
-rw-r--r-- | doc/api/cplusplus/examples/example_repository.cc | 3 | ||||
-rw-r--r-- | doc/api/cplusplus/groups.doxygen | 12 | ||||
-rw-r--r-- | doc/api/cplusplus/main_page.doxygen | 1 | ||||
-rw-r--r-- | doc/api/index.html.part | 7 | ||||
-rw-r--r-- | doc/api/ruby/Makefile.am | 1 | ||||
-rw-r--r-- | doc/api/ruby/example_package_database.rb | 39 | ||||
-rw-r--r-- | doc/api/ruby/example_repository.rb | 4 |
10 files changed, 4 insertions, 173 deletions
diff --git a/doc/api/cplusplus/examples/Makefile.am b/doc/api/cplusplus/examples/Makefile.am index 05bd89cf0..fae161c5f 100644 --- a/doc/api/cplusplus/examples/Makefile.am +++ b/doc/api/cplusplus/examples/Makefile.am @@ -22,7 +22,6 @@ noinst_PROGRAMS = \ example_mask \ example_repository \ example_match_package \ - example_package_database \ example_selection \ example_version_operator \ example_version_spec \ @@ -115,12 +114,6 @@ example_selection_LDADD = \ $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ $(top_builddir)/paludis/args/libpaludisargs_@PALUDIS_PC_SLOT@.la -example_package_database_SOURCES = example_package_database.cc -example_package_database_LDADD = \ - libpaludisexamples.a \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/args/libpaludisargs_@PALUDIS_PC_SLOT@.la - example_version_operator_SOURCES = example_version_operator.cc example_version_operator_LDADD = \ libpaludisexamples.a \ diff --git a/doc/api/cplusplus/examples/example_metadata_key.cc b/doc/api/cplusplus/examples/example_metadata_key.cc index 1d95145c1..17821ba7f 100644 --- a/doc/api/cplusplus/examples/example_metadata_key.cc +++ b/doc/api/cplusplus/examples/example_metadata_key.cc @@ -275,8 +275,7 @@ int main(int argc, char * argv[]) } /* And for each repository: */ - for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()), - r_end(env->package_database()->end_repositories()) ; + for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ; r != r_end ; ++r) { cout << (*r)->name() << ":" << endl; diff --git a/doc/api/cplusplus/examples/example_package_database.cc b/doc/api/cplusplus/examples/example_package_database.cc deleted file mode 100644 index ddbc38ec3..000000000 --- a/doc/api/cplusplus/examples/example_package_database.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/** \file - * - * Example \ref example_package_database.cc "example_package_database.cc" . - * - * \ingroup g_package_database - */ - -/** \example example_package_database.cc - * - * This example demonstrates how to use PackageDatabase. - */ - -#include <paludis/paludis.hh> -#include "example_command_line.hh" -#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_package_database", "EXAMPLE_PACKAGE_DATABASE_OPTIONS", "EXAMPLE_PACKAGE_DATABASE_CMDLINE"); - - /* We start with an Environment, respecting the user's '--environment' choice. */ - std::shared_ptr<Environment> env(EnvironmentFactory::get_instance()->create( - CommandLine::get_instance()->a_environment.argument())); - - /* Mostly PackageDatabase is used by Environment. But some methods are useful: */ - if (env->package_database()->has_repository_named(RepositoryName("gentoo"))) - { - std::shared_ptr<const Repository> repo(env->package_database()->fetch_repository(RepositoryName("gentoo"))); - cout << "Repository 'gentoo' exists, and has format '" << - (repo->format_key() ? repo->format_key()->value() : "") << "'" << endl; - } - - /* Users often expect to be able to refer to a package by its name part - * only (e.g. 'foo' rather than 'app-misc/foo'). This has to be - * disambiguated as follows: */ - try - { - QualifiedPackageName name(env->package_database()->fetch_unique_qualified_package_name( - PackageNamePart("git"))); - cout << "The only package named 'git' is '" << name << "'" << endl; - } - catch (const NoSuchPackageError & e) - { - cout << "There is no package named 'git'" << endl; - } - catch (const AmbiguousPackageNameError & e) - { - cout << "There are several packages named 'git':" << endl; - for (AmbiguousPackageNameError::OptionsConstIterator o(e.begin_options()), o_end(e.end_options()) ; - o != o_end ; ++o) - cout << " " << *o << endl; - } - } - catch (const Exception & e) - { - /* Paludis exceptions can provide a handy human-readable backtrace and - * an explanation message. Where possible, these should be displayed. */ - cout << endl; - cout << "Unhandled exception:" << endl - << " * " << e.backtrace("\n * ") - << e.message() << " (" << e.what() << ")" << 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; -} - - diff --git a/doc/api/cplusplus/examples/example_repository.cc b/doc/api/cplusplus/examples/example_repository.cc index 8ae820f1f..78db20540 100644 --- a/doc/api/cplusplus/examples/example_repository.cc +++ b/doc/api/cplusplus/examples/example_repository.cc @@ -39,8 +39,7 @@ int main(int argc, char * argv[]) CommandLine::get_instance()->a_environment.argument())); /* For each repository... */ - for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()), - r_end(env->package_database()->end_repositories()) ; + for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ; r != r_end ; ++r) { /* A repository is identified by its name. */ diff --git a/doc/api/cplusplus/groups.doxygen b/doc/api/cplusplus/groups.doxygen index 8cc58c6a5..99262c90f 100644 --- a/doc/api/cplusplus/groups.doxygen +++ b/doc/api/cplusplus/groups.doxygen @@ -177,18 +177,6 @@ using namespace paludis; * - \ref example_repository.cc "example_repository.cc" */ -/** \defgroup g_package_database Package Database - * - * \ingroup g_paludis - * - * A PackageDatabase, which is owned by an Environment, contains a number of - * Repository instances. - * - * \section Examples - * - * - \ref example_package_database.cc "example_package_database.cc" - */ - /** \defgroup g_names Names and Versions * * \ingroup g_paludis diff --git a/doc/api/cplusplus/main_page.doxygen b/doc/api/cplusplus/main_page.doxygen index 3e79a6ef2..e1461ceac 100644 --- a/doc/api/cplusplus/main_page.doxygen +++ b/doc/api/cplusplus/main_page.doxygen @@ -14,7 +14,6 @@ Some classes you may find useful: - paludis::Environment, which is usually created using paludis::EnvironmentFactory - paludis::PackageID, which you can get from your paludis::Environment by using a paludis::Selection -- paludis::PackageDatabase - paludis::Repository and the associated interface classes */ diff --git a/doc/api/index.html.part b/doc/api/index.html.part index 8a8eaf6bb..07dd5dc01 100644 --- a/doc/api/index.html.part +++ b/doc/api/index.html.part @@ -135,13 +135,6 @@ how concepts map on to different language bindings.</p> <td>How to use name classes</td> </tr> <tr> - <td>example_package_database</td> - <td><a href="cplusplus/examples.html">C++</a></td> - <td><a href="ruby/example_package_database.html">Ruby</a></td> - <td></td> - <td>How to use PackageDatabase</td> - </tr> - <tr> <td>example_package_id</td> <td><a href="cplusplus/examples.html">C++</a></td> <td><a href="ruby/example_package_id.html">Ruby</a></td> diff --git a/doc/api/ruby/Makefile.am b/doc/api/ruby/Makefile.am index 178ec522f..b536ed677 100644 --- a/doc/api/ruby/Makefile.am +++ b/doc/api/ruby/Makefile.am @@ -24,7 +24,6 @@ examples = \ example_contents.rb \ example_dep_tree.rb \ example_environment.rb \ - example_package_database.rb \ example_package_id.rb \ example_mask.rb \ example_match_package.rb \ diff --git a/doc/api/ruby/example_package_database.rb b/doc/api/ruby/example_package_database.rb deleted file mode 100644 index 6c7a17ec0..000000000 --- a/doc/api/ruby/example_package_database.rb +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env ruby -# vim: set sw=4 sts=4 et tw=100 : - -=begin description -This example demonstrates how to use Mask. It displays all the -mask keys for a particular PackageID. -=end - -require 'Paludis' -require 'example_command_line' - -include Paludis - -exit_status = 0 - -# We start with an Environment, respecting the user's '--environment' choice. -env = EnvironmentFactory.instance.create(ExampleCommandLine.instance.environment) - -# Mostly PackageDatabase is used by Environment. But other methods are useful: -if env.package_database.has_repository_named?('gentoo') - repo = env.package_database.fetch_repository('gentoo') - puts "Repository 'gentoo' exists, and has format '" + - (repo.format_key ? repo.format_key.value : '') + "'" -end - -begin - name = env.package_database.fetch_unique_qualified_package_name('git') - puts "The only package named 'git' is '#{name}'" -rescue NoSuchPackageError - puts "There is no package named 'git'" -rescue AmbiguousPackageNameError - puts "There are several packages named 'git':" - $!.options.each do |o| - puts " #{o}" - end -end - -exit exit_status - diff --git a/doc/api/ruby/example_repository.rb b/doc/api/ruby/example_repository.rb index 5d9fba4e7..8d09b3f4e 100644 --- a/doc/api/ruby/example_repository.rb +++ b/doc/api/ruby/example_repository.rb @@ -16,7 +16,7 @@ exit_status = 0 env = EnvironmentFactory.instance.create(ExampleCommandLine.instance.environment) # For each repository -env.package_database.repositories do |repo| +env.repositories do |repo| # A repository is identified by its name. puts repo.name + ':' @@ -33,7 +33,7 @@ env.package_database.repositories do |repo| # Repositories support various methods for querying categories, # packages, IDs and so on. These methods are used by - # PackageDatabase::query, but are also sometimes of direct use to + # Environment::[], but are also sometimes of direct use to # clients. puts " Number of categories: ".ljust(31) + repo.category_names.length.to_s puts " IDs for sys-apps/paludis: ".ljust(31) + repo.package_ids('sys-apps/paludis').join(' ') |