Skip to content

Commit

Permalink
Begin with function for printing element tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
radicke-atix-de committed Nov 18, 2011
1 parent 3744fca commit cceedb8
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 28 deletions.
12 changes: 10 additions & 2 deletions Makefile
Expand Up @@ -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



Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions src/PrintElementTree.cpp
@@ -0,0 +1,19 @@

#include <iostream>
#include <string>

#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;


}
16 changes: 16 additions & 0 deletions src/PrintElementTree.h
@@ -0,0 +1,16 @@
#ifndef PRINTELEMETTREE_H
#define PRINTELEMETTREE_H


#include <string>
#include <list>

#include "TexDocElement.h"

class PrintElementTree
{
public:
static void printTree( TexDocElement& parentElement );
};

#endif
10 changes: 8 additions & 2 deletions src/TexParser.cpp
Expand Up @@ -4,14 +4,14 @@
#include <string>
#include <boost/regex.hpp>

using namespace std;

#include "TexParser.h"
#include "TexDocElement.h"

/** get debugging info */
#define DBINF cout << "[debug]"

using namespace std;


// B =========================================================================

Expand Down Expand Up @@ -289,6 +289,12 @@ DBINF << "TexParser::DOCUMENT gefunden!\n";
throw;
}


TexDocElement& TexParser::getRootElement(void)
{
return TexParser::rootElement;
}

// P =========================================================================

void TexParser::pars()
Expand Down
6 changes: 6 additions & 0 deletions src/TexParser.h
Expand Up @@ -20,6 +20,12 @@ class TexParser
*/
void setInputFileName(std::string);

/**
* Get back the rootElement.
* @return The root elemet.
*/
TexDocElement& getRootElement(void);

private:

// Properties ------------------------------------------------------------
Expand Down
83 changes: 59 additions & 24 deletions src/main.cpp
Expand Up @@ -3,19 +3,24 @@
#include "TexParser.h"
#include <string>
#include <iostream>

#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;


}
Expand All @@ -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)
Expand All @@ -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;
}


Expand Down

0 comments on commit cceedb8

Please sign in to comment.