39 lines
760 B
C++
39 lines
760 B
C++
|
#include <filesystem>
|
||
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include "CommandLineArgs.h"
|
||
|
#include "XmlParser.h"
|
||
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
CommandLineArgs command_line_args;
|
||
|
command_line_args.Process(argc, argv);
|
||
|
|
||
|
if(command_line_args.GetNumberOfArgs() < 2)
|
||
|
{
|
||
|
std::cerr << "Expected a filepath argument" << std::endl;
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
XmlParser parser;
|
||
|
const auto filepath = command_line_args.GetArg(1);
|
||
|
|
||
|
if(!std::filesystem::exists(filepath))
|
||
|
{
|
||
|
std::cerr << "Couldn't find file: " << filepath << std::endl;
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
std::ifstream xml_file;
|
||
|
xml_file.open(filepath, std::ifstream::in);
|
||
|
while(xml_file.good())
|
||
|
{
|
||
|
std::string line;
|
||
|
std::getline(xml_file, line);
|
||
|
parser.ProcessLine(line);
|
||
|
}
|
||
|
xml_file.close();
|
||
|
|
||
|
return 0;
|
||
|
}
|