You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

129 lines
5.3 KiB

  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 <limits>
  15. #include <string>
  16. #include <vector>
  17. /*}}}*/
  18. namespace APT {
  19. namespace Configuration { /*{{{*/
  20. /** \brief Returns a vector of usable Compression Types
  21. *
  22. * Files can be compressed in various ways to decrease the size of the
  23. * download. Therefore the Acquiremethods support a few compression types
  24. * and some archives provide also a few different types. This option
  25. * group exists to give the user the choice to prefer one type over the
  26. * other (some compression types are very resource intensive - great if you
  27. * have a limited download, bad if you have a really lowpowered hardware.)
  28. *
  29. * This method ensures that the defaults are set and checks at runtime
  30. * if the type can be used. E.g. the current default is to prefer bzip2
  31. * over lzma and gz - if the bzip2 binary is not available it has not much
  32. * sense in downloading the bz2 file, therefore we will not return bz2 as
  33. * a usable compression type. The availability is checked with the settings
  34. * in the Dir::Bin group.
  35. *
  36. * \param Cached saves the result so we need to calculated it only once
  37. * this parameter should only be used for testing purposes.
  38. *
  39. * \return a vector of the compression types in the preferred usage order
  40. */
  41. std::vector<std::string> const getCompressionTypes(bool const &Cached = true);
  42. /** \brief Returns a vector of Language Codes
  43. *
  44. * Languages can be defined with their two or five chars long code.
  45. * This methods handles the various ways to set the preferred codes,
  46. * honors the environment and ensures that the codes are not listed twice.
  47. *
  48. * The special word "environment" will be replaced with the long and the short
  49. * code of the local settings and it will be insured that this will not add
  50. * duplicates. So in an german local the setting "environment, de_DE, en, de"
  51. * will result in "de_DE, de, en".
  52. *
  53. * Another special word is "none" which separates the preferred from all codes
  54. * in this setting. So setting and method can be used to get codes the user want
  55. * to see or to get all language codes APT (should) have Translations available.
  56. *
  57. * \param All return all codes or only codes for languages we want to use
  58. * \param Cached saves the result so we need to calculated it only once
  59. * this parameter should only be used for testing purposes.
  60. * \param Locale don't get the locale from the system but use this one instead
  61. * this parameter should only be used for testing purposes.
  62. *
  63. * \return a vector of (all) Language Codes in the preferred usage order
  64. */
  65. std::vector<std::string> const getLanguages(bool const &All = false,
  66. bool const &Cached = true, char const ** const Locale = 0);
  67. /** \brief Are we interested in the given Language?
  68. *
  69. * \param Lang is the language we want to check
  70. * \param All defines if we check against all codes or only against used codes
  71. * \return true if we are interested, false otherwise
  72. */
  73. bool checkLanguage(std::string Lang, bool const All = false);
  74. /** \brief Returns a vector of Architectures we support
  75. *
  76. * \param Cached saves the result so we need to calculated it only once
  77. * this parameter should only be used for testing purposes.
  78. *
  79. * \return a vector of Architectures in preferred order
  80. */
  81. std::vector<std::string> const getArchitectures(bool const &Cached = true);
  82. /** \brief Are we interested in the given Architecture?
  83. *
  84. * \param Arch we want to check
  85. * \return true if we are interested, false otherwise
  86. */
  87. bool checkArchitecture(std::string const &Arch);
  88. /** \brief Representation of supported compressors */
  89. struct Compressor {
  90. std::string Name;
  91. std::string Extension;
  92. std::string Binary;
  93. std::vector<std::string> CompressArgs;
  94. std::vector<std::string> UncompressArgs;
  95. unsigned short Cost;
  96. Compressor(char const *name, char const *extension, char const *binary,
  97. char const *compressArg, char const *uncompressArg,
  98. unsigned short const cost);
  99. Compressor() : Cost(std::numeric_limits<unsigned short>::max()) {};
  100. };
  101. /** \brief Return a vector of Compressors supported for data.tar's
  102. *
  103. * \param Cached saves the result so we need to calculated it only once
  104. * this parameter should only be used for testing purposes.
  105. *
  106. * \return a vector of Compressors
  107. */
  108. std::vector<Compressor> const getCompressors(bool const Cached = true);
  109. /** \brief Return a vector of extensions supported for data.tar's */
  110. std::vector<std::string> const getCompressorExtensions();
  111. /** \return Return a vector of enabled build profile specifications */
  112. std::vector<std::string> const getBuildProfiles();
  113. /** \return Return a comma-separated list of enabled build profile specifications */
  114. std::string const getBuildProfilesString();
  115. /*}}}*/
  116. }
  117. /*}}}*/
  118. }
  119. #endif