LibPkg
binary_control_table.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 // Copyright � 2003-2005 Graham Shaw.
3 // Distribution and use are subject to the GNU Lesser General Public License,
4 // a copy of which may be found in the file !LibPkg.Copyright.
5 
6 #ifndef LIBPKG_BINARY_CONTROL_TABLE
7 #define LIBPKG_BINARY_CONTROL_TABLE
8 
9 #include <map>
10 #include <string>
11 
12 #include "libpkg/version.h"
13 #include "libpkg/binary_control.h"
14 #include "libpkg/table.h"
15 
16 namespace pkg {
17 
18 using std::string;
19 
22  public table
23 {
24 public:
26  class key_type
27  {
28  public:
30  string pkgname;
34  string pkgenv;
36  key_type();
42  key_type(const string& _pkgname,const version& _pkgvrsn, const string &_pkgenv);
43  };
45  typedef std::map<key_type,mapped_type>::const_iterator const_iterator;
46  class commit_error;
47 private:
49  string _pathname;
50 
52  std::map<key_type,mapped_type> _data;
53 public:
57  binary_control_table(const string& pathname);
58 
60  virtual ~binary_control_table();
61 
66  const mapped_type& operator[](const key_type& key) const;
67 
72  const mapped_type& operator[](const string& pkgname) const;
73 
77  const_iterator begin() const
78  { return _data.begin(); }
79 
83  const_iterator end() const
84  { return _data.end(); }
85 
91  void insert(const mapped_type& ctrl);
92 
98  void commit();
99 
101  void update();
102 };
103 
110  const binary_control_table::key_type& rhs);
111 
114  public std::runtime_error
115 {
116 public:
118  commit_error();
119 };
120 
121 }; /* namespace pkg */
122 
123 #endif
const mapped_type & operator[](const key_type &key) const
Get control record for package given package name and version.
Definition: binary_control_table.cc:23
void update()
Re-read the underlying package index file.
Definition: binary_control_table.cc:51
A class for specifying the name and version of a package.
Definition: binary_control_table.h:26
The namespace used to hold the package management library.
Definition: auto_dir.cc:12
void commit()
Commit changes.
Definition: binary_control_table.cc:71
std::map< key_type, mapped_type >::const_iterator const_iterator
Definition: binary_control_table.h:45
bool operator<(const binary_control_table::key_type &lhs, const binary_control_table::key_type &rhs)
Compare two binary control table keys.
Definition: binary_control_table.cc:122
key_type()
Construct default key type.
Definition: binary_control_table.cc:111
version pkgvrsn
The package version.
Definition: binary_control_table.h:32
const_iterator begin() const
Get const iterator for start of table.
Definition: binary_control_table.h:77
virtual ~binary_control_table()
Destroy binary control table.
Definition: binary_control_table.cc:19
binary_control_table(const string &pathname)
Construct binary control table.
Definition: binary_control_table.cc:13
A class for mapping package name and version to binary control record.
Definition: binary_control_table.h:21
A class to represent a package version.
Definition: version.h:21
binary_control mapped_type
Definition: binary_control_table.h:44
string pkgname
The package name.
Definition: binary_control_table.h:30
const_iterator end() const
Get const iterator for end of table.
Definition: binary_control_table.h:83
string pkgenv
The package environment id.
Definition: binary_control_table.h:34
void insert(const mapped_type &ctrl)
Insert control record into table.
Definition: binary_control_table.cc:44
A class to represent the content of a RiscPkg binary control file.
Definition: binary_control.h:24
A base class to represent a data table.
Definition: table.h:18
An exception class for reporting failure to commit table.
Definition: binary_control_table.h:113

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)