]>
git.saurik.com Git - apt.git/blob - apt-pkg/indexfile.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: indexfile.cc,v 1.2.2.1 2003/12/24 23:09:17 mdz Exp $
4 /* ######################################################################
6 Index File - Abstraction for an index of archive/souce file.
8 ##################################################################### */
10 // Include Files /*{{{*/
13 #include <apt-pkg/indexfile.h>
14 #include <apt-pkg/error.h>
15 #include <apt-pkg/aptconfiguration.h>
21 // Global list of Item supported
22 static pkgIndexFile::Type
*ItmList
[10];
23 pkgIndexFile::Type
**pkgIndexFile::Type::GlobalList
= ItmList
;
24 unsigned long pkgIndexFile::Type::GlobalListLen
= 0;
26 // Type::Type - Constructor /*{{{*/
27 // ---------------------------------------------------------------------
29 pkgIndexFile::Type::Type()
31 ItmList
[GlobalListLen
] = this;
36 // Type::GetType - Locate the type by name /*{{{*/
37 // ---------------------------------------------------------------------
39 pkgIndexFile::Type
*pkgIndexFile::Type::GetType(const char *Type
)
41 for (unsigned I
= 0; I
!= GlobalListLen
; I
++)
42 if (strcmp(GlobalList
[I
]->Label
,Type
) == 0)
47 // IndexFile::ArchiveInfo - Stub /*{{{*/
48 // ---------------------------------------------------------------------
50 std::string
pkgIndexFile::ArchiveInfo(pkgCache::VerIterator
/*Ver*/) const
55 // IndexFile::FindInCache - Stub /*{{{*/
56 // ---------------------------------------------------------------------
58 pkgCache::PkgFileIterator
pkgIndexFile::FindInCache(pkgCache
&Cache
) const
60 return pkgCache::PkgFileIterator(Cache
);
63 // IndexFile::SourceIndex - Stub /*{{{*/
64 // ---------------------------------------------------------------------
66 std::string
pkgIndexFile::SourceInfo(pkgSrcRecords::Parser
const &/*Record*/,
67 pkgSrcRecords::File
const &/*File*/) const
72 // IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
73 // ---------------------------------------------------------------------
75 bool pkgIndexFile::TranslationsAvailable() {
76 return (APT::Configuration::getLanguages().empty() != true);
79 // IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
80 // ---------------------------------------------------------------------
81 /* No intern need for this method anymore as the check for correctness
82 is already done in getLanguages(). Note also that this check is
83 rather bad (doesn't take three character like ast into account).
84 TODO: Remove method with next API break */
85 __attribute__ ((deprecated
)) bool pkgIndexFile::CheckLanguageCode(const char *Lang
)
87 if (strlen(Lang
) == 2 || (strlen(Lang
) == 5 && Lang
[2] == '_'))
90 if (strcmp(Lang
,"C") != 0)
91 _error
->Warning("Wrong language code %s", Lang
);
96 // IndexFile::LanguageCode - Return the Language Code /*{{{*/
97 // ---------------------------------------------------------------------
98 /* As we have now possibly more than one LanguageCode this method is
99 supersided by a) private classmembers or b) getLanguages().
100 TODO: Remove method with next API break */
101 __attribute__ ((deprecated
)) std::string
pkgIndexFile::LanguageCode() {
102 if (TranslationsAvailable() == false)
104 return APT::Configuration::getLanguages()[0];