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