history.h
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* ######################################################################
History - Parse history logs to structured data.
##################################################################### */
/*}}}*/
#ifndef APTPKG_HISTORY_H
#define APTPKG_HISTORY_H
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/tagfile.h>
#include <map>
#include <string>
#include <vector>
namespace APT::History
{
enum class Kind
{
Install,
Reinstall,
Upgrade,
Downgrade,
InstallEnd = Downgrade,
Remove,
Purge,
};
std::string KindToString(const Kind &kind);
struct Change
{
Kind kind;
std::string package;
std::string currentVersion;
std::string candidateVersion;
bool automatic = false;
private:
void *d; // pointer for future extension;
};
static inline bool IsRemoval(const Kind &kind) { return kind > Kind::InstallEnd; }
struct Entry
{
// Strings instead of string_view to avoid reference errors
std::string startDate;
std::string endDate;
std::string cmdLine;
std::string comment;
std::string error;
std::string requestingUser;
std::map<Kind, std::vector<Change>> changeMap;
private:
void *d;
};
// History is defined as the collection of entries in the history log(s).
typedef std::vector<Entry> HistoryBuffer;
APT_PUBLIC Entry ParseSection(const pkgTagSection &section);
APT_PUBLIC bool ParseFile(FileFd &fd, HistoryBuffer &buf);
// ParseLogDir - Parse the apt history log directory to the buffer.
APT_PUBLIC bool ParseLogDir(HistoryBuffer &buf);
} // namespace APT::History
#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