apt: apt-pkg/history.h Source File

apt 3.3.0 commandline package manager

history.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 History - Parse history logs to structured data.
6
7 ##################################################################### */
8/*}}}*/
9#ifndef APTPKG_HISTORY_H
10#define APTPKG_HISTORY_H
11
12#include <apt-pkg/fileutl.h>
13#include <apt-pkg/macros.h>
14#include <apt-pkg/tagfile.h>
15
16#include <map>
17#include <string>
18#include <vector>
19
20namespace APT::History
21{
22
27enum class Kind
28{
29 Install,
30 Reinstall,
31 Upgrade,
32 Downgrade,
33 InstallEnd = Downgrade,
34 Remove,
35 Purge,
36};
37
47std::string KindToString(const Kind &kind);
48
53 struct Change
54{
55 Kind kind;
56 std::string package;
57 std::string currentVersion;
58 std::string candidateVersion;
59 bool automatic = false;
60
61 private:
62 void *d; // pointer for future extension;
63};
64
65static inline bool IsRemoval(const Kind &kind) { return kind > Kind::InstallEnd; }
66
71 struct Entry
72{
73 // Strings instead of string_view to avoid reference errors
74 std::string startDate;
75 std::string endDate;
76 std::string cmdLine;
77 std::string comment;
78 std::string error;
79 std::string requestingUser;
80 std::map<Kind, std::vector<Change>> changeMap;
81
82 private:
83 void *d;
84};
85
86// History is defined as the collection of entries in the history log(s).
87typedef std::vector<Entry> HistoryBuffer;
88
95APT_PUBLIC Entry ParseSection(const pkgTagSection &section);
96
106APT_PUBLIC bool ParseFile(FileFd &fd, HistoryBuffer &buf);
107
108// ParseLogDir - Parse the apt history log directory to the buffer.
115APT_PUBLIC bool ParseLogDir(HistoryBuffer &buf);
116
117} // namespace APT::History
118
119#endif
FileFd
Definition fileutl.h:43
pkgTagSection
Definition tagfile.h:46
APT::History::Change
Represents a package change.
Definition history.h:54
APT::History::Change::automatic
bool automatic
If the change was automatically performed.
Definition history.h:59
APT::History::Entry
Represents an entry in the APT history log.
Definition history.h:72