]> git.saurik.com Git - apt.git/blame - apt-pkg/aptconfiguration.h
add default and override handling for Cnf::FindVector
[apt.git] / apt-pkg / aptconfiguration.h
CommitLineData
e878aedb
DK
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/** \class APT::Configuration
4 * \brief Provide access methods to various configuration settings
5 *
6 * This class and their methods providing a layer around the usual access
7 * methods with _config to ensure that settings are correct and to be able
8 * to set defaults without the need to recheck it in every method again.
9 */
10 /*}}}*/
11#ifndef APT_CONFIGURATION_H
12#define APT_CONFIGURATION_H
13// Include Files /*{{{*/
14#include <string>
15#include <vector>
dd688285 16#include <limits>
e878aedb
DK
17 /*}}}*/
18namespace APT {
19class Configuration { /*{{{*/
20public: /*{{{*/
21 /** \brief Returns a vector of usable Compression Types
22 *
23 * Files can be compressed in various ways to decrease the size of the
24 * download. Therefore the Acquiremethods support a few compression types
25 * and some archives provide also a few different types. This option
26 * group exists to give the user the choice to prefer one type over the
27 * other (some compression types are very resource intensive - great if you
28 * have a limited download, bad if you have a really lowpowered hardware.)
29 *
30 * This method ensures that the defaults are set and checks at runtime
31 * if the type can be used. E.g. the current default is to prefer bzip2
32 * over lzma and gz - if the bzip2 binary is not available it has not much
33 * sense in downloading the bz2 file, therefore we will not return bz2 as
34 * a usable compression type. The availability is checked with the settings
35 * in the Dir::Bin group.
36 *
37 * \param Cached saves the result so we need to calculated it only once
38 * this parameter should ony be used for testing purposes.
39 *
1e3f4083 40 * \return a vector of the compression types in the preferred usage order
e878aedb
DK
41 */
42 std::vector<std::string> static const getCompressionTypes(bool const &Cached = true);
45df0ad2
DK
43
44 /** \brief Returns a vector of Language Codes
45 *
46 * Languages can be defined with their two or five chars long code.
1e3f4083 47 * This methods handles the various ways to set the preferred codes,
45df0ad2
DK
48 * honors the environment and ensures that the codes are not listed twice.
49 *
50 * The special word "environment" will be replaced with the long and the short
51 * code of the local settings and it will be insured that this will not add
52 * duplicates. So in an german local the setting "environment, de_DE, en, de"
53 * will result in "de_DE, de, en".
54 *
1e3f4083 55 * Another special word is "none" which separates the preferred from all codes
45df0ad2
DK
56 * in this setting. So setting and method can be used to get codes the user want
57 * to see or to get all language codes APT (should) have Translations available.
58 *
59 * \param All return all codes or only codes for languages we want to use
60 * \param Cached saves the result so we need to calculated it only once
61 * this parameter should ony be used for testing purposes.
62 * \param Locale don't get the locale from the system but use this one instead
63 * this parameter should ony be used for testing purposes.
64 *
1e3f4083 65 * \return a vector of (all) Language Codes in the preferred usage order
45df0ad2
DK
66 */
67 std::vector<std::string> static const getLanguages(bool const &All = false,
83742b3c 68 bool const &Cached = true, char const ** const Locale = 0);
45df0ad2 69
c45233ea
DK
70 /** \brief Are we interested in the given Language?
71 *
72 * \param Lang is the language we want to check
73 * \param All defines if we check against all codes or only against used codes
74 * \return true if we are interested, false otherwise
75 */
601c2c8e 76 bool static const checkLanguage(std::string Lang, bool const All = false);
c45233ea 77
5dd4c8b8
DK
78 /** \brief Returns a vector of Architectures we support
79 *
80 * \param Cached saves the result so we need to calculated it only once
81 * this parameter should ony be used for testing purposes.
82 *
1e3f4083 83 * \return a vector of Architectures in preferred order
5dd4c8b8
DK
84 */
85 std::vector<std::string> static const getArchitectures(bool const &Cached = true);
86
87 /** \brief Are we interested in the given Architecture?
88 *
89 * \param Arch we want to check
90 * \return true if we are interested, false otherwise
91 */
92 bool static const checkArchitecture(std::string const &Arch);
93
03bef784
DK
94 /** \brief Representation of supported compressors */
95 struct Compressor {
96 std::string Name;
97 std::string Extension;
98 std::string Binary;
99 std::vector<std::string> CompressArgs;
100 std::vector<std::string> UncompressArgs;
101 unsigned short Cost;
102
103 Compressor(char const *name, char const *extension, char const *binary,
104 char const *compressArg, char const *uncompressArg,
105 unsigned short const cost);
dd688285 106 Compressor() : Cost(std::numeric_limits<unsigned short>::max()) {};
03bef784
DK
107 };
108
109 /** \brief Return a vector of Compressors supported for data.tar's
110 *
111 * \param Cached saves the result so we need to calculated it only once
112 * this parameter should ony be used for testing purposes.
113 *
114 * \return a vector of Compressors
115 */
116 std::vector<Compressor> static const getCompressors(bool const Cached = true);
b0e1a43f
DK
117
118 /** \brief Return a vector of extensions supported for data.tar's */
119 std::vector<std::string> static const getCompressorExtensions();
03bef784
DK
120 /*}}}*/
121 private: /*{{{*/
122 void static setDefaultConfigurationForCompressors();
e878aedb
DK
123 /*}}}*/
124};
125 /*}}}*/
126}
127#endif