Skip to content
Snippets Groups Projects
Commit 09d556ab authored by Nubben's avatar Nubben
Browse files

Add browser history class

parent cb35b9db
No related branches found
No related tags found
No related merge requests found
#include "BrowsingHistory.h"
BrowsingHistory::BrowsingHistory() :
history(),
currentPosition(0) {}
void BrowsingHistory::addEntry(URL url) {
if (!history.empty()) {
++currentPosition;
}
if (currentPosition < history.size()) {
history.erase(history.begin() + currentPosition, history.end());
}
history.push_back(url);
}
URL const& BrowsingHistory::goForward() {
if (currentPosition < history.size()) {
++currentPosition;
}
return history[currentPosition];
}
URL const& BrowsingHistory::goBack() {
if (currentPosition > 0) {
--currentPosition;
}
return history[currentPosition];
}
std::vector<URL> const& BrowsingHistory::getHistory() const {
return history;
}
#ifndef BROWSINGHISTORY_H
#define BROWSINGHISTORY_H
#include <vector>
#include "URL.h"
class BrowsingHistory {
public:
BrowsingHistory();
void addEntry(URL url);
URL const& goForward();
URL const& goBack();
std::vector<URL> const& getHistory() const;
private:
std::vector<URL> history;
unsigned int currentPosition;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment