Library: Net Responsibility
Package: Core
Header: History.h
The History class is especially important to understand if you're writing a report plugin. When running Database.getHistory(), you'll get the return as a History object. It is designed to be easy to iterate through and holds every URL with some additional info about it.
The following is an example of how the History object may be used to iterate through:
History history = _db->getHistory(); while (history.hasMore()) { _body <<history.getDateTime("%d/%m - %H:%M:%S")) <<" - " <<history.getUrl() <<endl; history.next(); }
Pay extra attention to how the History is recieved from the database, used in a while loop, and the next object is accessed by the next() method.
You may also access information about any row in the History object if you have its index. You can get the index of the current URL with the method getIndex().
Known Derived Classes: Warnings
Member Functions: addRow, getDate, getDateTime, getHostname, getIndex, getPath, getTime, getUrl, hasMore, next, previous, setRows
History();
virtual ~History();
void addRow(
HistoryRow
);
Use this method to only add a single HistoryRow.
Timestamp getDate() const;
Get the current date as a Timestamp.
Timestamp getDate(
int index
) const;
Get the date of index as a Timestamp.
string getDateTime(
string fmt
) const;
Returns a formatted date and time as a string. fmt is the format you wish to return. See Poco::DateTimeFormatter::format() for more information on exactly how the format may be written.
string getDateTime(
string fmt,
int index
) const;
Timestamp getDateTime() const;
Get the current date and time as a Timestamp.
Timestamp getDateTime(
int index
) const;
Get the date and time of index as a Timestamp.
string getHostname() const;
Returns the current hostname as a string.
string getHostname(
int index
) const;
Returns the hostname of index as a string.
int getIndex() const;
Returns the index of the current row. The index may be used to access a row at any time, without having to use next() and previous().
string getPath() const;
Returns the current path as a string. In the URL "www.netresponsibility.com/dev/docs", "/dev/docs" is the path.
string getPath(
int index
) const;
Same as getPath() but for the given index.
Timestamp getTime() const;
Get the current time as a Timestamp.
Timestamp getTime(
int index
) const;
Get the time of index as a Timestamp.
string getUrl() const;
Returns the current URL (both hostname and path) as a string.
string getUrl(
int index
) const;
Returns the URL of index as a string.
bool hasMore() const;
Returns true if there are any more rows to iterate through. Very useful to put inside a while condition e.g.
void next();
Go to the next row. Useful to put in the end of a while loop.
void previous();
Go to the previous row.
void setRows(
vector < HistoryRow,
allocator < HistoryRow > > & rows
);
This method is used to add all the HistoryRows to History.
vector < HistoryRow, allocator < HistoryRow > > _historyRows;
int _index;