mirror of
https://github.com/supleed2/svd2cpp.git
synced 2024-12-22 13:45:50 +00:00
Added XmlParser
This commit is contained in:
parent
2fac6035ab
commit
a00ced6aa1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.o
|
10
Makefile
10
Makefile
|
@ -1,6 +1,6 @@
|
|||
OBJS = Build/main.o tinyxml2/tinyxml2.o
|
||||
OBJS = Build/main.o Build/XmlParser.o tinyxml2/libtinyxml2.a
|
||||
SOURCE = Src/main.cpp tinyxml2/tinyxml2.cpp
|
||||
INCLUDE = -I tinyxml2 -I cxxopts/include
|
||||
INCLUDE = -I tinyxml2 -I cxxopts/include -I Src
|
||||
OUT = svd2cpp
|
||||
CC = g++
|
||||
FLAGS = -g -c -Wall
|
||||
|
@ -12,7 +12,11 @@ Build/main.o: Src/main.cpp
|
|||
mkdir -p Build
|
||||
$(CC) $(FLAGS) Src/main.cpp $(INCLUDE) -o Build/main.o
|
||||
|
||||
tinyxml2/tinyxml2.o:
|
||||
Build/XmlParser.o: Src/XmlParser.cpp
|
||||
mkdir -p Build
|
||||
$(CC) $(FLAGS) Src/XmlParser.cpp $(INCLUDE) -o Build/XmlParser.o
|
||||
|
||||
tinyxml2/libtinyxml2.a:
|
||||
$(MAKE) -C tinyxml2/ staticlib
|
||||
|
||||
|
||||
|
|
6
Src/XmlParser.cpp
Normal file
6
Src/XmlParser.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include <XmlParser.hpp>
|
||||
#include <iostream>
|
||||
|
||||
XmlParser::XmlParser(const std::string& inputFile){
|
||||
std::cout << inputFile;
|
||||
}
|
14
Src/XmlParser.hpp
Normal file
14
Src/XmlParser.hpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef XML_PARSER
|
||||
#define XML_PARSER
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include <string>
|
||||
|
||||
struct XmlParser{
|
||||
XmlParser(const std::string& inputFile);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
32
Src/main.cpp
32
Src/main.cpp
|
@ -1,6 +1,32 @@
|
|||
#include <tinyxml2.h>
|
||||
#include <iostream>
|
||||
#include <cxxopts.hpp>
|
||||
#include <XmlParser.hpp>
|
||||
|
||||
int main(){
|
||||
|
||||
int main(int argc, char** argv){
|
||||
// Create and configure options for the program
|
||||
cxxopts::Options options("svd2cpp", "Parser from svd files to C++ header");
|
||||
options.add_options()
|
||||
("i, input", "File to be parsed", cxxopts::value<std::string>())
|
||||
("o, output", "OutputFile", cxxopts::value<std::string>());
|
||||
std::string inputFile, outputFile;
|
||||
try
|
||||
{
|
||||
auto result = options.parse(argc, argv);
|
||||
if(result.count("input") != 1){
|
||||
std::cout << "Missing input file!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if(result.count("output") != 1){
|
||||
std::cout << "Missing output file!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
inputFile = result["input"].as<std::string>();
|
||||
outputFile = result["output"].as<std::string>();
|
||||
std::cout << "Input: " << inputFile << "\tOutput: " << outputFile << std::endl;
|
||||
}
|
||||
catch(cxxopts::OptionException& ex){
|
||||
std::cout << ex.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
XmlParser xmlParser(inputFile);
|
||||
}
|
Loading…
Reference in a new issue