class History

Library: Net Responsibility
Package: Core
Header: History.h

Description

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().

Inheritance

Known Derived Classes: Warnings

Member Summary

Member Functions: addRow, getDate, getDateTime, getHostname, getIndex, getPath, getTime, getUrl, hasMore, next, previous, setRows

Constructors

History

History();

Destructor

~History virtual

virtual ~History();

Member Functions

addRow

void addRow(
    HistoryRow
);

Use this method to only add a single HistoryRow.

getDate

Timestamp getDate() const;

Get the current date as a Timestamp.

getDate

Timestamp getDate(
    int index
) const;

Get the date of index as a Timestamp.

getDateTime

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.

getDateTime

string getDateTime(
    string fmt,
    int index
) const;

getDateTime

Timestamp getDateTime() const;

Get the current date and time as a Timestamp.

getDateTime

Timestamp getDateTime(
    int index
) const;

Get the date and time of index as a Timestamp.

getHostname

string getHostname() const;

Returns the current hostname as a string.

getHostname

string getHostname(
    int index
) const;

Returns the hostname of index as a string.

getIndex

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().

getPath

string getPath() const;

Returns the current path as a string. In the URL "www.netresponsibility.com/dev/docs", "/dev/docs" is the path.

getPath

string getPath(
    int index
) const;

Same as getPath() but for the given index.

getTime

Timestamp getTime() const;

Get the current time as a Timestamp.

getTime

Timestamp getTime(
    int index
) const;

Get the time of index as a Timestamp.

getUrl

string getUrl() const;

Returns the current URL (both hostname and path) as a string.

getUrl

string getUrl(
    int index
) const;

Returns the URL of index as a string.

hasMore

bool hasMore() const;

Returns true if there are any more rows to iterate through. Very useful to put inside a while condition e.g.

next

void next();

Go to the next row. Useful to put in the end of a while loop.

previous

void previous();

Go to the previous row.

setRows

void setRows(
    vector < HistoryRow,
    allocator < HistoryRow > > & rows
);

This method is used to add all the HistoryRows to History.

Variables

_historyRows protected

vector < HistoryRow, allocator < HistoryRow > > _historyRows;

_index protected

int _index;