diff --git a/Makefile b/Makefile index 77a1830..5be679a 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,10 @@ LIBS = -lboost_regex SOURCE = ./src/main.cpp -OBJECTS = main.o TexDocElement.o TexParser.o +OBJECTS = main.o \ +PrintElementTree.o \ +TexDocElement.o \ +TexParser.o @@ -54,6 +57,9 @@ TexParser.o: ./src/TexParser.cpp TexDocElement.o: ./src/TexDocElement.cpp $(CC) $(CPPFLAGS) -o $@ -c $^ $(LIBS) +PrintElementTree.o: ./src/PrintElementTree.cpp + $(CC) $(CPPFLAGS) -o $@ -c $^ $(LIBS) + # cleaning the build-tmp-files clean: #rm -f *.rpm @@ -100,7 +106,9 @@ uninstall: # simple function check of bin-file. bin-test: - ./texconv --input=./testfiles/simple_tex_document.tex --output=./muell.html + ./texconv --help + ./texconv pars --input=./testfiles/simple_tex_document.tex --output=./muell.html + ./texconv doctree --input=./testfiles/simple_tex_document.tex bin-gdb: gdb ./texconv diff --git a/src/PrintElementTree.cpp b/src/PrintElementTree.cpp new file mode 100644 index 0000000..8cc8b25 --- /dev/null +++ b/src/PrintElementTree.cpp @@ -0,0 +1,19 @@ + +#include +#include + +#include "PrintElementTree.h" +#include "TexDocElement.h" + +/** get debugging info */ +#define DBINF cout << "[debug]" + + +using namespace std; + +void PrintElementTree::printTree( TexDocElement& parentElement ) +{ +DBINF "######### Starte mit PrintElementTree::printTree ############" << std::endl; + + +} \ No newline at end of file diff --git a/src/PrintElementTree.h b/src/PrintElementTree.h new file mode 100644 index 0000000..8c66ab7 --- /dev/null +++ b/src/PrintElementTree.h @@ -0,0 +1,16 @@ +#ifndef PRINTELEMETTREE_H +#define PRINTELEMETTREE_H + + +#include +#include + +#include "TexDocElement.h" + +class PrintElementTree +{ +public: + static void printTree( TexDocElement& parentElement ); +}; + +#endif \ No newline at end of file diff --git a/src/TexParser.cpp b/src/TexParser.cpp index 303927a..d7c0e25 100644 --- a/src/TexParser.cpp +++ b/src/TexParser.cpp @@ -4,14 +4,14 @@ #include #include -using namespace std; - #include "TexParser.h" #include "TexDocElement.h" /** get debugging info */ #define DBINF cout << "[debug]" +using namespace std; + // B ========================================================================= @@ -289,6 +289,12 @@ DBINF << "TexParser::DOCUMENT gefunden!\n"; throw; } + +TexDocElement& TexParser::getRootElement(void) +{ + return TexParser::rootElement; +} + // P ========================================================================= void TexParser::pars() diff --git a/src/TexParser.h b/src/TexParser.h index 07a5036..874528c 100644 --- a/src/TexParser.h +++ b/src/TexParser.h @@ -20,6 +20,12 @@ class TexParser */ void setInputFileName(std::string); + /** + * Get back the rootElement. + * @return The root elemet. + */ + TexDocElement& getRootElement(void); + private: // Properties ------------------------------------------------------------ diff --git a/src/main.cpp b/src/main.cpp index a0c84d5..0a85277 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,19 +3,24 @@ #include "TexParser.h" #include #include + +#include "PrintElementTree.h" #include "TexParser.h" /** get debugging info */ -#define DBINF std::cout << "[debug]" +#define DBINF cout << "[debug]" + +using namespace std; void get_help(void) { - std::cout << "\n--help" << std::endl; - std::cout << "\t\t Help text." << std::endl; - std::cout << "\n--input=[file name]" << std::endl; - std::cout << "\t\t Name of input file." << std::endl; - std::cout << "\n--output=[file name]" << std::endl; - std::cout << "\t\t Name of output file." << std::endl; + cout << "\ntexconv [pars|doctree|--help] --output=[file name] " << endl; + cout << "\n--help" << endl; + cout << "\t\t Help text." << endl; + cout << "\n--input=[file name]" << endl; + cout << "\t\t Name of input file." << endl; + cout << "\n--output=[file name]" << endl; + cout << "\t\t Name of output file." << endl; } @@ -28,16 +33,30 @@ int main(int argc,char *argv[]) imputFileName=""; std::string outputFileName; outputFileName=""; + string do_command = ""; for ( int i = 1; i < argc; i++) { -// std::cout << argv[i] << std::endl; str_arg = std::string(argv[i]); - found = str_arg.find("--help"); - if (found!=std::string::npos) +// DBINF << "Arg Nr.: " << i << " Wert: " << argv[i] << endl; + + if(i == 1) { - get_help(); + if (str_arg == "--help") + { + get_help(); + return 0; + } + if (str_arg == "pars") + { + do_command = str_arg; + } + if (str_arg == "doctree") + { + do_command = str_arg; + } + } found = str_arg.find("--input="); if (found!=std::string::npos) @@ -50,27 +69,43 @@ int main(int argc,char *argv[]) { size_t endIdentifier = std::string("--output=").length(); outputFileName = str_arg.substr( endIdentifier ); - } - - + } + } // end for-loop + + if( do_command == "") + { + cout << "No supported command found!" << endl; + return 1; } + + if( imputFileName == "" ) { - std::cout << "Name of input file is not set!" << std::endl; + cout << "Name of input file is not set!" << endl; return 1; } - if( outputFileName == "" ) + if( do_command == "doctree") { - std::cout << "Name of output file is not set!" << std::endl; - return 1; + TexParser texParser; + texParser.setInputFileName(imputFileName); + texParser.pars(); + PrintElementTree::printTree( texParser.getRootElement() ); + return 0; + } + if( do_command == "pars") + { + if( outputFileName == "" ) + { + cout << "Name of output file is not set!" << endl; + return 1; + } +DBINF << "convert " << imputFileName << " to " << outputFileName << endl; + TexParser texParser; + texParser.setInputFileName(imputFileName); + texParser.pars(); + return 0; } -DBINF << "convert " << imputFileName << " to " << outputFileName << std::endl; - TexParser texParser; - texParser.setInputFileName(imputFileName); - texParser.pars(); - - return 0; }