lab_hash
Hellish Hash Tables
LogfileParser Class Reference

LogfileParser class: Provides an interface for querying logfiles of a particular format. More...

#include "logfile_parser.h"

+ Collaboration diagram for LogfileParser:

Classes

class  LogLine
 LogLine structure: Represents the information contained in a single line of the logfile. More...
 

Public Member Functions

 LogfileParser (const std::string &fname)
 Constructs a new LogfileParser from the name of a log file. More...
 
bool hasVisited (const std::string &customer, const std::string &url) const
 Determines if a given customer has ever visited the given url. More...
 
time_t dateVisited (const std::string &customer, const std::string &url) const
 Determines when a customer last visited a given url. More...
 
std::vector< std::stringuniquePages () const
 Gets all of the unique urls that have been visited. More...
 

Private Attributes

LPHashTable< std::string, time_t > whenVisitedTable
 HashTable used to determine when a customer visited a given url. More...
 
std::vector< std::stringuniqueURLs
 Vector containing the unique urls found in the logfile. More...
 

Detailed Description

LogfileParser class: Provides an interface for querying logfiles of a particular format.

Author
Chase Geigle
Date
Spring 2011
Summer 2012

Constructor & Destructor Documentation

◆ LogfileParser()

LogfileParser::LogfileParser ( const std::string fname)

Constructs a new LogfileParser from the name of a log file.

Parameters
fnameThe name of the log file to open.
Todo:
Finish implementing this function.

Given the LogLine above, you should be able to update the member variable hash table and any other hash tables necessary to solve this problem. This should also build the uniqueURLs member vector as well.

Member Function Documentation

◆ hasVisited()

bool LogfileParser::hasVisited ( const std::string customer,
const std::string url 
) const

Determines if a given customer has ever visited the given url.

Parameters
customerThe customer name.
urlThe url.
Returns
A boolean value indicating whether the customer visited the url.
Todo:
Implement this function.

◆ dateVisited()

time_t LogfileParser::dateVisited ( const std::string customer,
const std::string url 
) const

Determines when a customer last visited a given url.

If the customer has not visited the given url, the output of this function should be the default time_t.

Parameters
customerThe customer name.
urlThe url.
Returns
A time_t representing when the customer last visited the given url.
Todo:
Implement this function.

◆ uniquePages()

vector< string > LogfileParser::uniquePages ( ) const

Gets all of the unique urls that have been visited.

Returns
A vector of urls that were visited in the logfile. Note that there should be no duplicates in this vector.

Member Data Documentation

◆ whenVisitedTable

LPHashTable<std::string, time_t> LogfileParser::whenVisitedTable
private

HashTable used to determine when a customer visited a given url.

Hint: think about what your key should be for this. How could you construct a unique, string key to find information for a given customer and url?

◆ uniqueURLs

std::vector<std::string> LogfileParser::uniqueURLs
private

Vector containing the unique urls found in the logfile.

You should fill this in the constructor.

Note
This vector should not contain duplicates!

The documentation for this class was generated from the following files: