diff --git a/CMakeLists.txt b/CMakeLists.txt index fdfc5cc..61d056e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,13 +13,13 @@ add_executable( file(GLOB Source_Files2 src2/*.cpp) add_executable( - COptionParser + ExampleProgram ${Source_Files2} ) -find_package (Boost REQUIRED) +find_package (Boost COMPONENTS log log_setup REQUIRED) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(CodeGenerator ${Boost_LIBRARIES}) diff --git a/config-file b/config-file index 7723b87..d921596 100644 --- a/config-file +++ b/config-file @@ -815,7 +815,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ./src +INPUT = ./src, ./include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/example/Example.xml b/example/Example.xml deleted file mode 100644 index 9a20bdd..0000000 --- a/example/Example.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - options.h - options.cpp - DHBW - COptionParser - - Erstellt einen Rumpf zum einlesen von Argumente aus der Kommandozeile. - Es kann sowohl mit innenliegenden Container wie externer Klassenanbindung eine Datenhaltung erfolgen. - Sobald ein Methodenaufruf abstrakt ist, wird die Basisklasse abstrakt. - Fuer die Formatierung der generierten Dateien wird astyle verwendet. - - - getoptgen [options] ... QUELLE - getoptgen [--out-path] ... QUELLE - - - - - diff --git a/include/CodeGenerator.h b/include/CodeGenerator.h new file mode 100644 index 0000000..37f3a41 --- /dev/null +++ b/include/CodeGenerator.h @@ -0,0 +1,62 @@ +/* + * Editors: Tobias Goetz + */ + +#ifndef PROGRAMMING_C_CODEGENERATOR_H +#define PROGRAMMING_C_CODEGENERATOR_H + +#include + +/** + * @brief Class for the CodeGenerator + */ +class CodeGenerator { +private: + /** + * @brief String containing path to the file + */ + std::string filePath; + + /** + * @brief Output directory + */ + std::string outputDir; + +public: + /** + * @brief Constructor + */ + CodeGenerator() = default; + + /** + * @brief Get the path to the file + * @return + */ + std::string getFilePath(); + + /** + * Get the output directory + * @return the out directory as string + */ + std::string getOutputDir(); + + /** + * @brief Set the path to the file + * @param filename + */ + void setFilePath(const std::string &filename); + + /** + * @brief Set the output directory + * @param dir + */ + void setOutputDir(const std::string &dir); + + /** + * @brief Runs the CodeGenerator + */ + void run(); +}; + + +#endif //PROGRAMMING_C_CODEGENERATOR_H diff --git a/include/HelpText.h b/include/HelpText.h new file mode 100644 index 0000000..6e1a50c --- /dev/null +++ b/include/HelpText.h @@ -0,0 +1,110 @@ +/* + * Editors: Sebastian Wolf, Tobias Goetz + */ + +#ifndef CODEGENERATOR_HELPTEXT_H +#define CODEGENERATOR_HELPTEXT_H + +#include "Justify.h" +#include "models/GetOptSetup.h" +#include +#include +#include + +using namespace std; + +/** + * @brief Class for the HelpText parsing + */ +class HelpText +{ +public: + /** + * @brief Constructor for the HelpText + */ + explicit HelpText(GetOptSetup *getOptSetup); + /** + * @brief Destructor for the HelpText + */ + ~HelpText(); + + /** + * @brief add function wrapper and call parse methods + * @return getHelp() Function with message as string + */ + string parseHelpMessage(); + +private: + /** + * @brief concatenate the description strings to one string + * @brief and add to printHelpText + */ + void parseDescription(); + + /** + * @brief concatenate usage strings to one string + * @brief and add to printHelpText + * @return all usage strings as a string with line break. + */ + void parseUsage(); + + /** + * @brief concatenate the author information to one string + * @brief and add to printHelpText + */ + void parseAuthor(); + + /** + * @brief concatenate the options to one string + * @brief and add to printHelpText + * call the getMaxParamLength() Method. Get concatenated params + * by calling concatParams function with i as iterator. + * write strings to buffer with a spacing using set() + * calculate a new signPerLine to space out the + * option description accordingly to the length + * of param and the shift. + * calculate a new shift for every line of the description + * that is pushed to the next line because of signPerLine, + * in order to shift the line to the right, matching the above. + * Justify the description text. Write justified text to + * class variable. + */ + void parseOption(); + + /** + * @brief concatenate short opt and long opt to one string + * different checks if shortOpt and LongOpt are empty + * to concatenate the right signs to the string + * @param i iteration counter to determine which option is parsed + * @return concatenated opts as string + */ + vector concatParams(const vector