diff --git a/Learning/Parser/.gitignore b/Learning/Parser/.gitignore new file mode 100644 index 0000000..7f7adc5 --- /dev/null +++ b/Learning/Parser/.gitignore @@ -0,0 +1,2 @@ +/build +/.vscode \ No newline at end of file diff --git a/Learning/Parser/Assets/test.xml b/Learning/Parser/Assets/test.xml new file mode 100644 index 0000000..c10a927 --- /dev/null +++ b/Learning/Parser/Assets/test.xml @@ -0,0 +1,6 @@ + + + + Hello World + + diff --git a/Learning/Parser/CMakeLists.txt b/Learning/Parser/CMakeLists.txt new file mode 100644 index 0000000..b491c02 --- /dev/null +++ b/Learning/Parser/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0.0) +project(Parser VERSION 0.1.0) + +include(CTest) +enable_testing() + +add_executable(Parser main.cpp Parser.cpp Parser.hh) + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) +include(CPack) diff --git a/Learning/Parser/Parser.cpp b/Learning/Parser/Parser.cpp new file mode 100644 index 0000000..d113796 --- /dev/null +++ b/Learning/Parser/Parser.cpp @@ -0,0 +1,49 @@ +#include "Parser.hh" + +#include + +namespace Parser +{ + Parser::Parser() + { + + } + + bool Parser::Parse(char *path) + { + char ch; + std::fstream fin(path, std::fstream::in); + + if(!fin.is_open()){ + std::cout << "Could not open file " << path << "\n"; + return false; + } + + while (fin >> std::noskipws >> ch) + { + Parser::Consume(ch); + + } + fin.close(); + + return true; + } + + Parser::~Parser() + { + } + + void Parser::Consume(char c) + { + switch (c) + { + case '<': + + break; + + default: + std::cout << c; + break; + } + } +} \ No newline at end of file diff --git a/Learning/Parser/Parser.hh b/Learning/Parser/Parser.hh new file mode 100644 index 0000000..596cf96 --- /dev/null +++ b/Learning/Parser/Parser.hh @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace Parser +{ +class Parser { +public: + Parser(); + bool Parse(char* path); + ~Parser(); +private: + void Consume(char c); + int m_rowCount; + int m_colCount; +}; +} \ No newline at end of file diff --git a/Learning/Parser/main.cpp b/Learning/Parser/main.cpp new file mode 100644 index 0000000..8bbe1d1 --- /dev/null +++ b/Learning/Parser/main.cpp @@ -0,0 +1,10 @@ +#include +#include + +#include "Parser.hh" + +int main(int argc, char** argv) +{ + Parser::Parser* p = new Parser::Parser(); + bool result = p->Parse("../Assets/test.xml"); +}