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