#ifndef _LogFileScanner_h_
#define _LogFileScanner_h_
#include <string>
#include <cassert>
#include <iostream>
#include <fstream>
#include <list>
#include <set>
#include <map>
#include <vector>
class LogFileScanner
{
public:
struct RepresentationData
{
RepresentationData() : valid(false) {}
bool valid;
std::vector<char> data;
};
//
typedef std::map<std::string, RepresentationData > Frame;
typedef std::list<unsigned int>::const_iterator FrameIterator;
public:
LogFileScanner(const std::string& file);
void readFrame(unsigned int currentFrame, Frame& frame);
void open(const std::string& filePath);<--- Function 'LogFileScanner' argument 1 names different: declaration 'file' definition 'filePath'.<--- Class 'LogFileScanner' has a constructor with 1 argument that is not explicit. [+]Class 'LogFileScanner' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
const std::set<std::string>& getIncludedRepresentations() {
return includedRepresentations;
}<--- Technically the member function 'LogFileScanner::getIncludedRepresentations' can be const. [+]The member function 'LogFileScanner::getIncludedRepresentations' can be made a const function. Making this function 'const' should not cause compiler errors. Even though the function can be made const function technically it may not make sense conceptually. Think about your design and the task of the function first - is it a function that must not change object internal state?
FrameIterator begin() {
return frames.begin();
}
FrameIterator end() {
return frames.end();
}
FrameIterator last() {
return --frames.end();
}
private:
void open_internal(const std::string& filePath);
std::ifstream logFile;
typedef std::map<unsigned int, std::streampos> FramesMap;
FramesMap frameNumber2Pos;
std::list<unsigned int> frames;
// list of representation names included in the logfile
std::set<std::string> includedRepresentations;
void scanFile();
};
#endif //_LogFileScanner_h_