You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

688 lines
26 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /**\file pkgcache.h
  4. \brief pkgCache - Structure definitions for the cache file
  5. The goal of the cache file is two fold:
  6. Firstly to speed loading and processing of the package file array and
  7. secondly to reduce memory consumption of the package file array.
  8. The implementation is aimed at an environment with many primary package
  9. files, for instance someone that has a Package file for their CD-ROM, a
  10. Package file for the latest version of the distribution on the CD-ROM and a
  11. package file for the development version. Always present is the information
  12. contained in the status file which might be considered a separate package
  13. file.
  14. Please understand, this is designed as a <b>Cache file</b> it is not meant to be
  15. used on any system other than the one it was created for. It is not meant to
  16. be authoritative either, i.e. if a system crash or software failure occurs it
  17. must be perfectly acceptable for the cache file to be in an inconsistent
  18. state. Furthermore at any time the cache file may be erased without losing
  19. any information.
  20. Also the structures and storage layout is optimized for use by the APT
  21. and may not be suitable for all purposes. However it should be possible
  22. to extend it with associate cache files that contain other information.
  23. To keep memory use down the cache file only contains often used fields and
  24. fields that are inexpensive to store, the Package file has a full list of
  25. fields. Also the client may assume that all items are perfectly valid and
  26. need not perform checks against their correctness. Removal of information
  27. from the cache is possible, but blanks will be left in the file, and
  28. unused strings will also be present. The recommended implementation is to
  29. simply rebuild the cache each time any of the data files change. It is
  30. possible to add a new package file to the cache without any negative side
  31. effects.
  32. <b>Note on Pointer access</b>
  33. Clients should always use the CacheIterators classes for access to the
  34. cache and the data in it. They also provide a simple STL-like method for
  35. traversing the links of the datastructure.
  36. Every item in every structure is stored as the index to that structure.
  37. What this means is that once the files is mmaped every data access has to
  38. go through a fix up stage to get a real memory pointer. This is done
  39. by taking the index, multiplying it by the type size and then adding
  40. it to the start address of the memory block. This sounds complex, but
  41. in C it is a single array dereference. Because all items are aligned to
  42. their size and indexes are stored as multiples of the size of the structure
  43. the format is immediately portable to all possible architectures - BUT the
  44. generated files are -NOT-.
  45. This scheme allows code like this to be written:
  46. <example>
  47. void *Map = mmap(...);
  48. Package *PkgList = (Package *)Map;
  49. Header *Head = (Header *)Map;
  50. char *Strings = (char *)Map;
  51. cout << (Strings + PkgList[Head->HashTable[0]]->Name) << endl;
  52. </example>
  53. Notice the lack of casting or multiplication. The net result is to return
  54. the name of the first package in the first hash bucket, without error
  55. checks.
  56. The generator uses allocation pools to group similarly sized structures in
  57. large blocks to eliminate any alignment overhead. The generator also
  58. assures that no structures overlap and all indexes are unique. Although
  59. at first glance it may seem like there is the potential for two structures
  60. to exist at the same point the generator never allows this to happen.
  61. (See the discussion of free space pools)
  62. See \ref pkgcachegen.h for more information about generating cache structures. */
  63. /*}}}*/
  64. #ifndef PKGLIB_PKGCACHE_H
  65. #define PKGLIB_PKGCACHE_H
  66. #include <string>
  67. #include <time.h>
  68. #include <apt-pkg/mmap.h>
  69. using std::string;
  70. class pkgVersioningSystem;
  71. class pkgCache /*{{{*/
  72. {
  73. public:
  74. // Cache element predeclarations
  75. struct Header;
  76. struct Group;
  77. struct Package;
  78. struct PackageFile;
  79. struct Version;
  80. struct Description;
  81. struct Provides;
  82. struct Dependency;
  83. struct StringItem;
  84. struct VerFile;
  85. struct DescFile;
  86. // Iterators
  87. template<typename Str, typename Itr> class Iterator;
  88. class GrpIterator;
  89. class PkgIterator;
  90. class VerIterator;
  91. class DescIterator;
  92. class DepIterator;
  93. class PrvIterator;
  94. class PkgFileIterator;
  95. class VerFileIterator;
  96. class DescFileIterator;
  97. class Namespace;
  98. // These are all the constants used in the cache structures
  99. // WARNING - if you change these lists you must also edit
  100. // the stringification in pkgcache.cc and also consider whether
  101. // the cache file will become incompatible.
  102. struct Dep
  103. {
  104. enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
  105. Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
  106. /** \brief available compare operators
  107. The lower 4 bits are used to indicate what operator is being specified and
  108. the upper 4 bits are flags. OR indicates that the next package is
  109. or'd with the current package. */
  110. enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
  111. Greater=0x4,Equals=0x5,NotEquals=0x6};
  112. };
  113. struct State
  114. {
  115. /** \brief priority of a package version
  116. Zero is used for unparsable or absent Priority fields. */
  117. enum VerPriority {Important=1,Required=2,Standard=3,Optional=4,Extra=5};
  118. enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4};
  119. enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
  120. enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
  121. HalfInstalled=4,ConfigFiles=5,Installed=6,
  122. TriggersAwaited=7,TriggersPending=8};
  123. };
  124. struct Flag
  125. {
  126. enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
  127. enum PkgFFlags {NotSource=(1<<0),NotAutomatic=(1<<1),ButAutomaticUpgrades=(1<<2)};
  128. };
  129. protected:
  130. // Memory mapped cache file
  131. string CacheFile;
  132. MMap &Map;
  133. unsigned long sHash(const string &S) const;
  134. unsigned long sHash(const char *S) const;
  135. public:
  136. // Pointers to the arrays of items
  137. Header *HeaderP;
  138. Group *GrpP;
  139. Package *PkgP;
  140. VerFile *VerFileP;
  141. DescFile *DescFileP;
  142. PackageFile *PkgFileP;
  143. Version *VerP;
  144. Description *DescP;
  145. Provides *ProvideP;
  146. Dependency *DepP;
  147. StringItem *StringItemP;
  148. char *StrP;
  149. virtual bool ReMap(bool const &Errorchecks = true);
  150. inline bool Sync() {return Map.Sync();};
  151. inline MMap &GetMap() {return Map;};
  152. inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();};
  153. // String hashing function (512 range)
  154. inline unsigned long Hash(const string &S) const {return sHash(S);};
  155. inline unsigned long Hash(const char *S) const {return sHash(S);};
  156. // Useful transformation things
  157. const char *Priority(unsigned char Priority);
  158. // Accessors
  159. GrpIterator FindGrp(const string &Name);
  160. PkgIterator FindPkg(const string &Name);
  161. PkgIterator FindPkg(const string &Name, const string &Arch);
  162. Header &Head() {return *HeaderP;};
  163. inline GrpIterator GrpBegin();
  164. inline GrpIterator GrpEnd();
  165. inline PkgIterator PkgBegin();
  166. inline PkgIterator PkgEnd();
  167. inline PkgFileIterator FileBegin();
  168. inline PkgFileIterator FileEnd();
  169. inline bool MultiArchCache() const { return MultiArchEnabled; };
  170. // Make me a function
  171. pkgVersioningSystem *VS;
  172. // Converters
  173. static const char *CompTypeDeb(unsigned char Comp);
  174. static const char *CompType(unsigned char Comp);
  175. static const char *DepType(unsigned char Dep);
  176. pkgCache(MMap *Map,bool DoMap = true);
  177. virtual ~pkgCache() {};
  178. private:
  179. bool MultiArchEnabled;
  180. PkgIterator SingleArchFindPkg(const string &Name);
  181. };
  182. /*}}}*/
  183. // Header structure /*{{{*/
  184. struct pkgCache::Header
  185. {
  186. /** \brief Signature information
  187. This must contain the hex value 0x98FE76DC which is designed to
  188. verify that the system loading the image has the same byte order
  189. and byte size as the system saving the image */
  190. unsigned long Signature;
  191. /** These contain the version of the cache file */
  192. short MajorVersion;
  193. short MinorVersion;
  194. /** \brief indicates if the cache should be erased
  195. Dirty is true if the cache file was opened for reading, the client
  196. expects to have written things to it and have not fully synced it.
  197. The file should be erased and rebuilt if it is true. */
  198. bool Dirty;
  199. /** \brief Size of structure values
  200. All *Sz variables contains the sizeof() that particular structure.
  201. It is used as an extra consistency check on the structure of the file.
  202. If any of the size values do not exactly match what the client expects
  203. then the client should refuse the load the file. */
  204. unsigned short HeaderSz;
  205. unsigned short GroupSz;
  206. unsigned short PackageSz;
  207. unsigned short PackageFileSz;
  208. unsigned short VersionSz;
  209. unsigned short DescriptionSz;
  210. unsigned short DependencySz;
  211. unsigned short ProvidesSz;
  212. unsigned short VerFileSz;
  213. unsigned short DescFileSz;
  214. /** \brief Structure counts
  215. These indicate the number of each structure contained in the cache.
  216. PackageCount is especially useful for generating user state structures.
  217. See Package::Id for more info. */
  218. unsigned long GroupCount;
  219. unsigned long PackageCount;
  220. unsigned long VersionCount;
  221. unsigned long DescriptionCount;
  222. unsigned long DependsCount;
  223. unsigned long PackageFileCount;
  224. unsigned long VerFileCount;
  225. unsigned long DescFileCount;
  226. unsigned long ProvidesCount;
  227. /** \brief index of the first PackageFile structure
  228. The PackageFile structures are singly linked lists that represent
  229. all package files that have been merged into the cache. */
  230. map_ptrloc FileList;
  231. /** \brief index of the first StringItem structure
  232. The cache contains a list of all the unique strings (StringItems).
  233. The parser reads this list into memory so it can match strings
  234. against it.*/
  235. map_ptrloc StringList;
  236. /** \brief String representing the version system used */
  237. map_ptrloc VerSysName;
  238. /** \brief Architecture(s) the cache was built against */
  239. map_ptrloc Architecture;
  240. /** \brief The maximum size of a raw entry from the original Package file */
  241. unsigned long MaxVerFileSize;
  242. /** \brief The maximum size of a raw entry from the original Translation file */
  243. unsigned long MaxDescFileSize;
  244. /** \brief The Pool structures manage the allocation pools that the generator uses
  245. Start indicates the first byte of the pool, Count is the number of objects
  246. remaining in the pool and ItemSize is the structure size (alignment factor)
  247. of the pool. An ItemSize of 0 indicates the pool is empty. There should be
  248. the same number of pools as there are structure types. The generator
  249. stores this information so future additions can make use of any unused pool
  250. blocks. */
  251. DynamicMMap::Pool Pools[9];
  252. /** \brief hash tables providing rapid group/package name lookup
  253. Each group/package name is inserted into the hash table using pkgCache::Hash(const &string)
  254. By iterating over each entry in the hash table it is possible to iterate over
  255. the entire list of packages. Hash Collisions are handled with a singly linked
  256. list of packages based at the hash item. The linked list contains only
  257. packages that match the hashing function.
  258. In the PkgHashTable is it possible that multiple packages have the same name -
  259. these packages are stored as a sequence in the list.
  260. Beware: The Hashmethod assumes that the hash table sizes are equal */
  261. map_ptrloc PkgHashTable[2*1048];
  262. map_ptrloc GrpHashTable[2*1048];
  263. bool CheckSizes(Header &Against) const;
  264. Header();
  265. };
  266. /*}}}*/
  267. // Group structure /*{{{*/
  268. /** \brief groups architecture depending packages together
  269. On or more packages with the same name form a group, so we have
  270. a simple way to access a package built for different architectures
  271. Group exists in a singly linked list of group records starting at
  272. the hash index of the name in the pkgCache::Header::GrpHashTable */
  273. struct pkgCache::Group
  274. {
  275. /** \brief Name of the group */
  276. map_ptrloc Name; // StringItem
  277. // Linked List
  278. /** \brief Link to the first package which belongs to the group */
  279. map_ptrloc FirstPackage; // Package
  280. /** \brief Link to the last package which belongs to the group */
  281. map_ptrloc LastPackage; // Package
  282. /** \brief Link to the next Group */
  283. map_ptrloc Next; // Group
  284. /** \brief unique sequel ID */
  285. unsigned int ID;
  286. };
  287. /*}}}*/
  288. // Package structure /*{{{*/
  289. /** \brief contains information for a single unique package
  290. There can be any number of versions of a given package.
  291. Package exists in a singly linked list of package records starting at
  292. the hash index of the name in the pkgCache::Header::PkgHashTable
  293. A package can be created for every architecture so package names are
  294. not unique, but it is garanteed that packages with the same name
  295. are sequencel ordered in the list. Packages with the same name can be
  296. accessed with the Group.
  297. */
  298. struct pkgCache::Package
  299. {
  300. /** \brief Name of the package */
  301. map_ptrloc Name; // StringItem
  302. /** \brief Architecture of the package */
  303. map_ptrloc Arch; // StringItem
  304. /** \brief Base of a singly linked list of versions
  305. Each structure represents a unique version of the package.
  306. The version structures contain links into PackageFile and the
  307. original text file as well as detailed information about the size
  308. and dependencies of the specific package. In this way multiple
  309. versions of a package can be cleanly handled by the system.
  310. Furthermore, this linked list is guaranteed to be sorted
  311. from Highest version to lowest version with no duplicate entries. */
  312. map_ptrloc VersionList; // Version
  313. /** \brief index to the installed version */
  314. map_ptrloc CurrentVer; // Version
  315. /** \brief indicates the deduced section
  316. Should be the index to the string "Unknown" or to the section
  317. of the last parsed item. */
  318. map_ptrloc Section; // StringItem
  319. /** \brief index of the group this package belongs to */
  320. map_ptrloc Group; // Group the Package belongs to
  321. // Linked list
  322. /** \brief Link to the next package in the same bucket */
  323. map_ptrloc NextPackage; // Package
  324. /** \brief List of all dependencies on this package */
  325. map_ptrloc RevDepends; // Dependency
  326. /** \brief List of all "packages" this package provide */
  327. map_ptrloc ProvidesList; // Provides
  328. // Install/Remove/Purge etc
  329. /** \brief state that the user wishes the package to be in */
  330. unsigned char SelectedState; // What
  331. /** \brief installation state of the package
  332. This should be "ok" but in case the installation failed
  333. it will be different.
  334. */
  335. unsigned char InstState; // Flags
  336. /** \brief indicates if the package is installed */
  337. unsigned char CurrentState; // State
  338. /** \brief unique sequel ID
  339. ID is a unique value from 0 to Header->PackageCount assigned by the generator.
  340. This allows clients to create an array of size PackageCount and use it to store
  341. state information for the package map. For instance the status file emitter uses
  342. this to track which packages have been emitted already. */
  343. unsigned int ID;
  344. /** \brief some useful indicators of the package's state */
  345. unsigned long Flags;
  346. };
  347. /*}}}*/
  348. // Package File structure /*{{{*/
  349. /** \brief stores information about the files used to generate the cache
  350. Package files are referenced by Version structures to be able to know
  351. after the generation still from which Packages file includes this Version
  352. as we need this information later on e.g. for pinning. */
  353. struct pkgCache::PackageFile
  354. {
  355. /** \brief physical disk file that this PackageFile represents */
  356. map_ptrloc FileName; // StringItem
  357. /** \brief the release information
  358. Please see the files document for a description of what the
  359. release information means. */
  360. map_ptrloc Archive; // StringItem
  361. map_ptrloc Codename; // StringItem
  362. map_ptrloc Component; // StringItem
  363. map_ptrloc Version; // StringItem
  364. map_ptrloc Origin; // StringItem
  365. map_ptrloc Label; // StringItem
  366. map_ptrloc Architecture; // StringItem
  367. /** \brief The site the index file was fetched from */
  368. map_ptrloc Site; // StringItem
  369. /** \brief indicates what sort of index file this is
  370. @TODO enumerate at least the possible indexes */
  371. map_ptrloc IndexType; // StringItem
  372. /** \brief Size of the file
  373. Used together with the modification time as a
  374. simple check to ensure that the Packages
  375. file has not been altered since Cache generation. */
  376. unsigned long Size;
  377. /** \brief Modification time for the file */
  378. time_t mtime;
  379. /* @TODO document PackageFile::Flags */
  380. unsigned long Flags;
  381. // Linked list
  382. /** \brief Link to the next PackageFile in the Cache */
  383. map_ptrloc NextFile; // PackageFile
  384. /** \brief unique sequel ID */
  385. unsigned int ID;
  386. };
  387. /*}}}*/
  388. // VerFile structure /*{{{*/
  389. /** \brief associates a version with a PackageFile
  390. This allows a full description of all Versions in all files
  391. (and hence all sources) under consideration. */
  392. struct pkgCache::VerFile
  393. {
  394. /** \brief index of the package file that this version was found in */
  395. map_ptrloc File; // PackageFile
  396. /** \brief next step in the linked list */
  397. map_ptrloc NextFile; // PkgVerFile
  398. /** \brief position in the package file */
  399. map_ptrloc Offset; // File offset
  400. /* @TODO document pkgCache::VerFile::Size */
  401. unsigned long Size;
  402. };
  403. /*}}}*/
  404. // DescFile structure /*{{{*/
  405. /** \brief associates a description with a Translation file */
  406. struct pkgCache::DescFile
  407. {
  408. /** \brief index of the file that this description was found in */
  409. map_ptrloc File; // PackageFile
  410. /** \brief next step in the linked list */
  411. map_ptrloc NextFile; // PkgVerFile
  412. /** \brief position in the file */
  413. map_ptrloc Offset; // File offset
  414. /* @TODO document pkgCache::DescFile::Size */
  415. unsigned long Size;
  416. };
  417. /*}}}*/
  418. // Version structure /*{{{*/
  419. /** \brief information for a single version of a package
  420. The version list is always sorted from highest version to lowest
  421. version by the generator. Equal version numbers are either merged
  422. or handled as separate versions based on the Hash value. */
  423. struct pkgCache::Version
  424. {
  425. /** \brief complete version string */
  426. map_ptrloc VerStr; // StringItem
  427. /** \brief section this version is filled in */
  428. map_ptrloc Section; // StringItem
  429. /** \brief stores the MultiArch capabilities of this version
  430. None is the default and doesn't trigger special behaviour,
  431. Foreign means that this version can fulfill dependencies even
  432. if it is built for another architecture as the requester.
  433. Same indicates that builds for different architectures can
  434. be co-installed on the system and All is the marker for a
  435. version with the Architecture: all. */
  436. enum {None, All, Foreign, Same, Allowed} MultiArch;
  437. /** \brief references all the PackageFile's that this version came from
  438. FileList can be used to determine what distribution(s) the Version
  439. applies to. If FileList is 0 then this is a blank version.
  440. The structure should also have a 0 in all other fields excluding
  441. pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. */
  442. map_ptrloc FileList; // VerFile
  443. /** \brief next (lower or equal) version in the linked list */
  444. map_ptrloc NextVer; // Version
  445. /** \brief next description in the linked list */
  446. map_ptrloc DescriptionList; // Description
  447. /** \brief base of the dependency list */
  448. map_ptrloc DependsList; // Dependency
  449. /** \brief links to the owning package
  450. This allows reverse dependencies to determine the package */
  451. map_ptrloc ParentPkg; // Package
  452. /** \brief list of pkgCache::Provides */
  453. map_ptrloc ProvidesList; // Provides
  454. /** \brief archive size for this version
  455. For Debian this is the size of the .deb file. */
  456. unsigned long long Size; // These are the .deb size
  457. /** \brief uncompressed size for this version */
  458. unsigned long long InstalledSize;
  459. /** \brief characteristic value representing this version
  460. No two packages in existence should have the same VerStr
  461. and Hash with different contents. */
  462. unsigned short Hash;
  463. /** \brief unique sequel ID */
  464. unsigned int ID;
  465. /** \brief parsed priority value */
  466. unsigned char Priority;
  467. };
  468. /*}}}*/
  469. // Description structure /*{{{*/
  470. /** \brief datamember of a linked list of available description for a version */
  471. struct pkgCache::Description
  472. {
  473. /** \brief Language code of this description (translation)
  474. If the value has a 0 length then this is read using the Package
  475. file else the Translation-CODE file is used. */
  476. map_ptrloc language_code; // StringItem
  477. /** \brief MD5sum of the original description
  478. Used to map Translations of a description to a version
  479. and to check that the Translation is up-to-date. */
  480. map_ptrloc md5sum; // StringItem
  481. /* @TODO document pkgCache::Description::FileList */
  482. map_ptrloc FileList; // DescFile
  483. /** \brief next translation for this description */
  484. map_ptrloc NextDesc; // Description
  485. /** \brief the text is a description of this package */
  486. map_ptrloc ParentPkg; // Package
  487. /** \brief unique sequel ID */
  488. unsigned int ID;
  489. };
  490. /*}}}*/
  491. // Dependency structure /*{{{*/
  492. /** \brief information for a single dependency record
  493. The records are split up like this to ease processing by the client.
  494. The base of the linked list is pkgCache::Version::DependsList.
  495. All forms of dependencies are recorded here including Depends,
  496. Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */
  497. struct pkgCache::Dependency
  498. {
  499. /** \brief string of the version the dependency is applied against */
  500. map_ptrloc Version; // StringItem
  501. /** \brief index of the package this depends applies to
  502. The generator will - if the package does not already exist -
  503. create a blank (no version records) package. */
  504. map_ptrloc Package; // Package
  505. /** \brief next dependency of this version */
  506. map_ptrloc NextDepends; // Dependency
  507. /** \brief next reverse dependency of this package */
  508. map_ptrloc NextRevDepends; // Dependency
  509. /** \brief version of the package which has the reverse depends */
  510. map_ptrloc ParentVer; // Version
  511. /** \brief unique sequel ID */
  512. map_ptrloc ID;
  513. /** \brief Dependency type - Depends, Recommends, Conflicts, etc */
  514. unsigned char Type;
  515. /** \brief comparison operator specified on the depends line
  516. If the high bit is set then it is a logical OR with the previous record. */
  517. unsigned char CompareOp;
  518. };
  519. /*}}}*/
  520. // Provides structure /*{{{*/
  521. /** \brief handles virtual packages
  522. When a Provides: line is encountered a new provides record is added
  523. associating the package with a virtual package name.
  524. The provides structures are linked off the package structures.
  525. This simplifies the analysis of dependencies and other aspects A provides
  526. refers to a specific version of a specific package, not all versions need to
  527. provide that provides.*/
  528. struct pkgCache::Provides
  529. {
  530. /** \brief index of the package providing this */
  531. map_ptrloc ParentPkg; // Package
  532. /** \brief index of the version this provide line applies to */
  533. map_ptrloc Version; // Version
  534. /** \brief version in the provides line (if any)
  535. This version allows dependencies to depend on specific versions of a
  536. Provides, as well as allowing Provides to override existing packages.
  537. This is experimental. Note that Debian doesn't allow versioned provides */
  538. map_ptrloc ProvideVersion; // StringItem
  539. /** \brief next provides (based of package) */
  540. map_ptrloc NextProvides; // Provides
  541. /** \brief next provides (based of version) */
  542. map_ptrloc NextPkgProv; // Provides
  543. };
  544. /*}}}*/
  545. // StringItem structure /*{{{*/
  546. /** \brief used for generating single instances of strings
  547. Some things like Section Name are are useful to have as unique tags.
  548. It is part of a linked list based at pkgCache::Header::StringList
  549. All strings are simply inlined any place in the file that is natural
  550. for the writer. The client should make no assumptions about the positioning
  551. of strings. All StringItems should be null-terminated. */
  552. struct pkgCache::StringItem
  553. {
  554. /** \brief string this refers to */
  555. map_ptrloc String; // StringItem
  556. /** \brief Next link in the chain */
  557. map_ptrloc NextItem; // StringItem
  558. };
  559. /*}}}*/
  560. #include <apt-pkg/cacheiterators.h>
  561. inline pkgCache::GrpIterator pkgCache::GrpBegin()
  562. {return GrpIterator(*this);};
  563. inline pkgCache::GrpIterator pkgCache::GrpEnd()
  564. {return GrpIterator(*this,GrpP);};
  565. inline pkgCache::PkgIterator pkgCache::PkgBegin()
  566. {return PkgIterator(*this);};
  567. inline pkgCache::PkgIterator pkgCache::PkgEnd()
  568. {return PkgIterator(*this,PkgP);};
  569. inline pkgCache::PkgFileIterator pkgCache::FileBegin()
  570. {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);};
  571. inline pkgCache::PkgFileIterator pkgCache::FileEnd()
  572. {return PkgFileIterator(*this,PkgFileP);};
  573. // Oh I wish for Real Name Space Support
  574. class pkgCache::Namespace /*{{{*/
  575. {
  576. public:
  577. typedef pkgCache::GrpIterator GrpIterator;
  578. typedef pkgCache::PkgIterator PkgIterator;
  579. typedef pkgCache::VerIterator VerIterator;
  580. typedef pkgCache::DescIterator DescIterator;
  581. typedef pkgCache::DepIterator DepIterator;
  582. typedef pkgCache::PrvIterator PrvIterator;
  583. typedef pkgCache::PkgFileIterator PkgFileIterator;
  584. typedef pkgCache::VerFileIterator VerFileIterator;
  585. typedef pkgCache::Version Version;
  586. typedef pkgCache::Description Description;
  587. typedef pkgCache::Package Package;
  588. typedef pkgCache::Header Header;
  589. typedef pkgCache::Dep Dep;
  590. typedef pkgCache::Flag Flag;
  591. };
  592. /*}}}*/
  593. #endif