indexfile.cc 3.5 KB

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