merge with debian-sid (some version screw going on here)
[ntk/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 /*{{{*/
ea542140
DK
11#include<config.h>
12
b2e465d6
AL
13#include <apt-pkg/indexfile.h>
14#include <apt-pkg/error.h>
45df0ad2 15#include <apt-pkg/aptconfiguration.h>
a52f938b
OS
16
17#include <clocale>
4f333a8b 18#include <cstring>
b2e465d6
AL
19 /*}}}*/
20
21// Global list of Item supported
22static pkgIndexFile::Type *ItmList[10];
23pkgIndexFile::Type **pkgIndexFile::Type::GlobalList = ItmList;
24unsigned long pkgIndexFile::Type::GlobalListLen = 0;
25
26// Type::Type - Constructor /*{{{*/
27// ---------------------------------------------------------------------
28/* */
29pkgIndexFile::Type::Type()
30{
31 ItmList[GlobalListLen] = this;
dd688285
DK
32 GlobalListLen++;
33 Label = NULL;
b2e465d6
AL
34}
35 /*}}}*/
36// Type::GetType - Locate the type by name /*{{{*/
37// ---------------------------------------------------------------------
38/* */
39pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
40{
41 for (unsigned I = 0; I != GlobalListLen; I++)
42 if (strcmp(GlobalList[I]->Label,Type) == 0)
43 return GlobalList[I];
44 return 0;
45}
46 /*}}}*/
b2e465d6
AL
47// IndexFile::ArchiveInfo - Stub /*{{{*/
48// ---------------------------------------------------------------------
49/* */
8f3ba4e8 50std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const
b2e465d6 51{
8f3ba4e8 52 return std::string();
b2e465d6
AL
53}
54 /*}}}*/
55// IndexFile::FindInCache - Stub /*{{{*/
56// ---------------------------------------------------------------------
57/* */
58pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const
59{
60 return pkgCache::PkgFileIterator(Cache);
61}
62 /*}}}*/
63// IndexFile::SourceIndex - Stub /*{{{*/
64// ---------------------------------------------------------------------
65/* */
8f3ba4e8 66std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record,
b2e465d6
AL
67 pkgSrcRecords::File const &File) const
68{
8f3ba4e8 69 return std::string();
b2e465d6
AL
70}
71 /*}}}*/
45df0ad2 72// IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/
a52f938b
OS
73// ---------------------------------------------------------------------
74/* */
45df0ad2
DK
75bool pkgIndexFile::TranslationsAvailable() {
76 return (APT::Configuration::getLanguages().empty() != true);
a52f938b
OS
77}
78 /*}}}*/
45df0ad2 79// IndexFile::CheckLanguageCode - Check the Language Code /*{{{*/
a52f938b 80// ---------------------------------------------------------------------
45df0ad2
DK
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)
a52f938b
OS
86{
87 if (strlen(Lang) == 2 || (strlen(Lang) == 5 && Lang[2] == '_'))
88 return true;
89
90 if (strcmp(Lang,"C") != 0)
91 _error->Warning("Wrong language code %s", Lang);
92
93 return false;
94}
95 /*}}}*/
45df0ad2 96// IndexFile::LanguageCode - Return the Language Code /*{{{*/
a52f938b 97// ---------------------------------------------------------------------
45df0ad2
DK
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 */
8f3ba4e8 101__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() {
45df0ad2
DK
102 if (TranslationsAvailable() == false)
103 return "";
104 return APT::Configuration::getLanguages()[0];
a52f938b
OS
105}
106 /*}}}*/