indexfile.cc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: indexfile.cc,v 1.2.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Index File - Abstraction for an index of archive/souce file.
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include Files /*{{{*/
  9. #include<config.h>
  10. #include <apt-pkg/indexfile.h>
  11. #include <apt-pkg/error.h>
  12. #include <apt-pkg/aptconfiguration.h>
  13. #include <clocale>
  14. #include <cstring>
  15. /*}}}*/
  16. // Global list of Item supported
  17. static pkgIndexFile::Type *ItmList[10];
  18. pkgIndexFile::Type **pkgIndexFile::Type::GlobalList = ItmList;
  19. unsigned long pkgIndexFile::Type::GlobalListLen = 0;
  20. // Type::Type - Constructor /*{{{*/
  21. // ---------------------------------------------------------------------
  22. /* */
  23. pkgIndexFile::Type::Type()
  24. {
  25. ItmList[GlobalListLen] = this;
  26. GlobalListLen++;
  27. Label = NULL;
  28. }
  29. /*}}}*/
  30. // Type::GetType - Locate the type by name /*{{{*/
  31. // ---------------------------------------------------------------------
  32. /* */
  33. pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
  34. {
  35. for (unsigned I = 0; I != GlobalListLen; I++)
  36. if (strcmp(GlobalList[I]->Label,Type) == 0)
  37. return GlobalList[I];
  38. return 0;
  39. }
  40. /*}}}*/
  41. // IndexFile::ArchiveInfo - Stub /*{{{*/
  42. // ---------------------------------------------------------------------
  43. /* */
  44. std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
  45. {
  46. return std::string();
  47. }
  48. /*}}}*/
  49. // IndexFile::FindInCache - Stub /*{{{*/
  50. // ---------------------------------------------------------------------
  51. /* */
  52. pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
  53. {
  54. return pkgCache::PkgFileIterator(Cache);
  55. }
  56. /*}}}*/
  57. // IndexFile::SourceIndex - Stub /*{{{*/
  58. // ---------------------------------------------------------------------
  59. /* */
  60. std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
  61. pkgSrcRecords::File const &File) const
  62. {
  63. return std::string();
  64. }
  65. /*}}}*/
  66. // IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
  67. // ---------------------------------------------------------------------
  68. /* */
  69. bool pkgIndexFile::TranslationsAvailable() {
  70. return (APT::Configuration::getLanguages().empty() != true);
  71. }
  72. /*}}}*/
  73. // IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
  74. // ---------------------------------------------------------------------
  75. /* No intern need for this method anymore as the check for correctness
  76. is already done in getLanguages(). Note also that this check is
  77. rather bad (doesn't take three character like ast into account).
  78. TODO: Remove method with next API break */
  79. __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *Lang)
  80. {
  81. if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
  82. return true;
  83. if (strcmp(Lang,"C") != 0)
  84. _error->Warning("Wrong language code %s", Lang);
  85. return false;
  86. }
  87. /*}}}*/
  88. // IndexFile::LanguageCode - Return the Language Code /*{{{*/
  89. // ---------------------------------------------------------------------
  90. /* As we have now possibly more than one LanguageCode this method is
  91. supersided by a) private classmembers or b) getLanguages().
  92. TODO: Remove method with next API break */
  93. __attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() {
  94. if (TranslationsAvailable() == false)
  95. return "";
  96. return APT::Configuration::getLanguages()[0];
  97. }
  98. /*}}}*/