]>
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 /*{{{*/
11 #include <apt-pkg/indexfile.h>
12 #include <apt-pkg/error.h>
13 #include <apt-pkg/aptconfiguration.h>
19 // Global list of Item supported
20 static pkgIndexFile::Type
*ItmList
[10];
21 pkgIndexFile::Type
**pkgIndexFile::Type::GlobalList
= ItmList
;
22 unsigned long pkgIndexFile::Type::GlobalListLen
= 0;
24 // Type::Type - Constructor /*{{{*/
25 // ---------------------------------------------------------------------
27 pkgIndexFile::Type::Type()
29 ItmList
[GlobalListLen
] = this;
34 // Type::GetType - Locate the type by name /*{{{*/
35 // ---------------------------------------------------------------------
37 pkgIndexFile::Type
*pkgIndexFile::Type::GetType(const char *Type
)
39 for (unsigned I
= 0; I
!= GlobalListLen
; I
++)
40 if (strcmp(GlobalList
[I
]->Label
,Type
) == 0)
45 // IndexFile::ArchiveInfo - Stub /*{{{*/
46 // ---------------------------------------------------------------------
48 string
pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver
) const
53 // IndexFile::FindInCache - Stub /*{{{*/
54 // ---------------------------------------------------------------------
56 pkgCache::PkgFileIterator
pkgIndexFile::FindInCache(pkgCache
&Cache
) const
58 return pkgCache::PkgFileIterator(Cache
);
61 // IndexFile::SourceIndex - Stub /*{{{*/
62 // ---------------------------------------------------------------------
64 string
pkgIndexFile::SourceInfo(pkgSrcRecords::Parser
const &Record
,
65 pkgSrcRecords::File
const &File
) const
70 // IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
71 // ---------------------------------------------------------------------
73 bool pkgIndexFile::TranslationsAvailable() {
74 return (APT::Configuration::getLanguages().empty() != true);
77 // IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
78 // ---------------------------------------------------------------------
79 /* No intern need for this method anymore as the check for correctness
80 is already done in getLanguages(). Note also that this check is
81 rather bad (doesn't take three character like ast into account).
82 TODO: Remove method with next API break */
83 __attribute__ ((deprecated
)) bool pkgIndexFile::CheckLanguageCode(const char *Lang
)
85 if (strlen(Lang
) == 2 || (strlen(Lang
) == 5 && Lang
[2] == '_'))
88 if (strcmp(Lang
,"C") != 0)
89 _error
->Warning("Wrong language code %s", Lang
);
94 // IndexFile::LanguageCode - Return the Language Code /*{{{*/
95 // ---------------------------------------------------------------------
96 /* As we have now possibly more than one LanguageCode this method is
97 supersided by a) private classmembers or b) getLanguages().
98 TODO: Remove method with next API break */
99 __attribute__ ((deprecated
)) string
pkgIndexFile::LanguageCode() {
100 if (TranslationsAvailable() == false)
102 return APT::Configuration::getLanguages()[0];