]> git.saurik.com Git - apt.git/blame - apt-pkg/indexfile.cc
merged from lp:~mvo/apt/mvo
[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;
dd688285
DK
30 GlobalListLen++;
31 Label = NULL;
b2e465d6
AL
32}
33 /*}}}*/
34// Type::GetType - Locate the type by name /*{{{*/
35// ---------------------------------------------------------------------
36/* */
37pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
38{
39 for (unsigned I = 0; I != GlobalListLen; I++)
40 if (strcmp(GlobalList[I]->Label,Type) == 0)
41 return GlobalList[I];
42 return 0;
43}
44 /*}}}*/
b2e465d6
AL
45// IndexFile::ArchiveInfo - Stub /*{{{*/
46// ---------------------------------------------------------------------
47/* */
48string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
49{
50 return string();
51}
52 /*}}}*/
53// IndexFile::FindInCache - Stub /*{{{*/
54// ---------------------------------------------------------------------
55/* */
56pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
57{
58 return pkgCache::PkgFileIterator(Cache);
59}
60 /*}}}*/
61// IndexFile::SourceIndex - Stub /*{{{*/
62// ---------------------------------------------------------------------
63/* */
64string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
65 pkgSrcRecords::File const &File) const
66{
67 return string();
68}
69 /*}}}*/
45df0ad2 70// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
a52f938b
OS
71// ---------------------------------------------------------------------
72/* */
45df0ad2
DK
73bool pkgIndexFile::TranslationsAvailable() {
74 return (APT::Configuration::getLanguages().empty() != true);
a52f938b
OS
75}
76 /*}}}*/
45df0ad2 77// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
a52f938b 78// ---------------------------------------------------------------------
45df0ad2
DK
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)
a52f938b
OS
84{
85 if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
86 return true;
87
88 if (strcmp(Lang,"C") != 0)
89 _error->Warning("Wrong language code %s", Lang);
90
91 return false;
92}
93 /*}}}*/
45df0ad2 94// IndexFile::LanguageCode - Return the Language Code /*{{{*/
a52f938b 95// ---------------------------------------------------------------------
45df0ad2
DK
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)
101 return "";
102 return APT::Configuration::getLanguages()[0];
a52f938b
OS
103}
104 /*}}}*/