diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-06-19 22:30:07 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-06-19 22:30:07 +0200 |
| commit | dd8f1658c47db665481c725b9469408cf17e8c2e (patch) | |
| tree | 185d0354c57f717068e348b322482dd4f826b77d /le/le_file_parser.cpp | |
| parent | de95ca22ec87cc8b79ceb7beba475301461713a6 (diff) | |
| download | openwar-dd8f1658c47db665481c725b9469408cf17e8c2e.tar.gz openwar-dd8f1658c47db665481c725b9469408cf17e8c2e.tar.bz2 openwar-dd8f1658c47db665481c725b9469408cf17e8c2e.zip | |
implements a LE file parser and bare outputter.
Diffstat (limited to 'le/le_file_parser.cpp')
| -rw-r--r-- | le/le_file_parser.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/le/le_file_parser.cpp b/le/le_file_parser.cpp new file mode 100644 index 0000000..2d5eed9 --- /dev/null +++ b/le/le_file_parser.cpp @@ -0,0 +1,56 @@ + +#include "le_file.hpp" + +#include <boost/program_options.hpp> +#include <boost/filesystem.hpp> + +#include <iostream> + +int main(int argc, char* argv[]) { + boost::program_options::options_description description; + description.add_options() + ("help,h", "produces this help message") + ("exe,e", boost::program_options::value<std::string>(), "The LE executable to parse the header for.") + ; + + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), vm); + boost::program_options::notify(vm); + + if(vm.count("help")) { + std::cout << description << std::endl; + return 0; + } + + boost::filesystem::path file_path; + if(vm.count("exe")) { + std::string exe_file = vm["exe"].as<std::string>(); + + if(boost::filesystem::exists(exe_file)) { + if(!boost::filesystem::is_directory(exe_file)) { + file_path = exe_file; + } else { + std::cerr << exe_file << " is a folder" << std::endl; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + } else { + std::cerr << "file: " << exe_file << " does not exist" << std::endl; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + } else { + std::cerr << "Option \"exe_file\" is required"; + std::cerr << std::endl; + std::cerr << description << std::endl; + return -1; + } + + std::ifstream file(file_path.string()); + auto x = le::parse_file(file); + std::cout << x << std::endl; + + return 0; +} |
