I'm stuck on how I can creat a LE object and pass it the line just input..than could i use a for loop and the .push_back to get the lines into the vector?
vector<Log_Entr y> parse(string);
This function does the following:
Open a log file specified by the parameter name (File I/O).
Read lines from the opened file.
Create a Log_Entry object passing the line just input.
Push each Log_Entry object onto a vector.
Return the vector of Log_Entrys.
I'm unsure on how I'm going to create a Log_Entry object and pass the line just input...
Here is what I have so far:
vector<Log_Entr y> parse(string);
This function does the following:
Open a log file specified by the parameter name (File I/O).
Read lines from the opened file.
Create a Log_Entry object passing the line just input.
Push each Log_Entry object onto a vector.
Return the vector of Log_Entrys.
I'm unsure on how I'm going to create a Log_Entry object and pass the line just input...
Here is what I have so far:
Code:
std::vector<Log_Entry> parse(const string& filename)
{
vector<Log_Entry> log_entries;
std::string line;
ifstream in_file(filename.c_str());
if(!in_file)
{
// couldn't open input file, exit
cerr << "Error: couldn't open "
<< filename
<< " exiting\n";
exit(1);
}
while(!in_file.eof())
{
getline(in_file, line);
}
in_file.close();
return log_entries;
}
Comment