This repository has been archived by the owner on Jul 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from DHBW-FN/develop
Release 1.1
- Loading branch information
Showing
32 changed files
with
1,580 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Editors: Tobias Goetz | ||
*/ | ||
|
||
#ifndef PROGRAMMING_C_CODEGENERATOR_H | ||
#define PROGRAMMING_C_CODEGENERATOR_H | ||
|
||
#include <string> | ||
|
||
/** | ||
* @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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <iostream> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
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<string> concatParams(const vector<Option>& sortedOpts); | ||
/** | ||
* @brief printHelp Text | ||
* stores the string for the printHelp method. | ||
*/ | ||
string printHelpText; | ||
/** | ||
* @brief Length of longest Parameter | ||
* Stores the length of the longest | ||
* parameter in options. | ||
*/ | ||
int maxOptionParamLength = 0; | ||
/** | ||
* @brief shift | ||
* extra shift / space can be defined | ||
* for the space between parameters | ||
* and description in options. | ||
*/ | ||
const int shift = 5; | ||
/** | ||
* @brief Justify object | ||
*/ | ||
Justify justify; | ||
/** | ||
* @brief GetOptSetup object | ||
*/ | ||
GetOptSetup *getOptSetup; | ||
}; | ||
|
||
#endif //CODEGENERATOR_HELPTEXT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Editors: Sebastian Wolf | ||
*/ | ||
|
||
#ifndef CODEGENERATOR_JUSTIFY_H | ||
#define CODEGENERATOR_JUSTIFY_H | ||
#include "bits/stdc++.h" | ||
#include <iostream> | ||
#include <boost/tokenizer.hpp> | ||
#include <string> | ||
|
||
using namespace std; | ||
using namespace boost; | ||
|
||
/** | ||
* @brief Class to justify a string | ||
* Custom Justify class according to https://www.geeksforgeeks.org/justify-the-given-text-based-on-the-given-width-of-each-line/ | ||
*/ | ||
class Justify | ||
{ | ||
private: | ||
/** | ||
* @brief Function to join the words with spaces spread evenly | ||
* @param words vector with separated words | ||
* @param start current line start | ||
* @param end iterator | ||
* @param num_spaces | ||
* @param isOption check if its an options string | ||
* @param curr_line current line string is in | ||
* @param optionShift shift that needs to be added to aline lines | ||
* @return justified text | ||
*/ | ||
static string JoinALineWithSpace( | ||
vector<string>& words, | ||
int start, int end, | ||
int num_spaces, | ||
bool isOption, | ||
int curr_line, | ||
int optionShift); | ||
/** | ||
* @brief Function that justify the words of sentence of length of line L | ||
* @param words vector with separated words | ||
* @param L length of sign per line | ||
* @param isOption check if its an options string | ||
* @param optionShift shift that needs to be added to aline lines | ||
* @return whole justified string | ||
*/ | ||
static vector<string> JustifyText( | ||
vector<string>& words, | ||
int L, | ||
bool isOption, | ||
int optionShift); | ||
/** | ||
* @brief separates a string in single words | ||
* @param str string to parse | ||
* @return vector with splitted words | ||
*/ | ||
static vector<string> splitWords(const string& str); | ||
|
||
/** | ||
* @brief Function to return justified text | ||
* @param result vector with justified strings | ||
* @return justified text in as a string | ||
*/ | ||
static string returnJustifiedText(vector<string>& result); | ||
|
||
public: | ||
/** | ||
* @brief function to call the justification | ||
* @param str string to justify | ||
* @param L length of sign per line | ||
* @param isOption check if its an options string | ||
* @param optionShift shift that needs to be added to aline lines | ||
* @return justified text as a string | ||
*/ | ||
string justifyTheText(const string& str, int L, bool isOption, int optionShift); | ||
}; | ||
|
||
|
||
#endif //CODEGENERATOR_JUSTIFY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Editors: Tobias Goetz, Sebastian Wolf | ||
*/ | ||
|
||
#ifndef LOG_LOGGER_H | ||
#define LOG_LOGGER_H | ||
#pragma once | ||
|
||
#include <boost/log/trivial.hpp> | ||
#include <boost/log/sources/global_logger_storage.hpp> | ||
#include <boost/log/sources/severity_channel_logger.hpp> | ||
#include <boost/log/attributes/mutable_constant.hpp> | ||
#include <boost/log/utility/manipulators/add_value.hpp> | ||
#include <string> | ||
|
||
BOOST_LOG_GLOBAL_LOGGER(sysLogger, | ||
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>); | ||
BOOST_LOG_GLOBAL_LOGGER(dataLogger, | ||
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>); | ||
|
||
/** | ||
* @brief Custom logger class. | ||
* Custom logger according to https://objectcomputing.com/resources/publications/sett/may-2016-boostlog-library | ||
*/ | ||
class Logger { | ||
public: | ||
/// Init with default trivial logging | ||
static void init(); | ||
|
||
/// @param configFileName config ini file that contains boost logging properties. | ||
/// If configFileName.empty() then default initialization. | ||
static void initFromConfig(const std::string& configFileName); | ||
|
||
/// Disable logging | ||
static void disable(); | ||
|
||
/// Add a file sink for LOG_DATA_* for >= INFO. | ||
/// This file sink will be used along with any configured via Config in init(). | ||
static void addDataFileLog(const std::string& logFileName); | ||
}; | ||
|
||
#define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG) \ | ||
BOOST_LOG_SEV(LOGGER, boost::log::trivial::LEVEL) \ | ||
<< boost::log::add_value("Line", __LINE__) \ | ||
<< boost::log::add_value("File", __FILE__) \ | ||
<< boost::log::add_value("Function", __FUNCTION__) << ARG; | ||
|
||
/// System Log macros. | ||
/// TRACE < DEBUG < INFO < WARN < ERROR < FATAL | ||
#define LOG_TRACE(ARG) LOG_LOG_LOCATION(sysLogger::get(), trace, ARG); | ||
#define LOG_DEBUG(ARG) LOG_LOG_LOCATION(sysLogger::get(), debug, ARG); | ||
#define LOG_INFO(ARG) LOG_LOG_LOCATION(sysLogger::get(), info, ARG); | ||
#define LOG_WARN(ARG) LOG_LOG_LOCATION(sysLogger::get(), warning, ARG); | ||
#define LOG_ERROR(ARG) LOG_LOG_LOCATION(sysLogger::get(), error, ARG); | ||
#define LOG_FATAL(ARG) LOG_LOG_LOCATION(sysLogger::get(), fatal, ARG); | ||
|
||
/// Data Log macros. Does not include LINE, FILE, FUNCTION. | ||
/// TRACE < DEBUG < INFO < WARN < ERROR < FATAL | ||
#define LOG_DATA_TRACE(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::trace) << ARG | ||
#define LOG_DATA_DEBUG(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::debug) << ARG | ||
#define LOG_DATA_INFO(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::info) << ARG | ||
#define LOG_DATA_WARN(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::warning) << ARG | ||
#define LOG_DATA_ERROR(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::error) << ARG | ||
#define LOG_DATA_FATAL(ARG) BOOST_LOG_SEV(dataLogger::get(), boost::log::trivial::fatal) << ARG | ||
|
||
#endif /* LOG_LOGGER_H */ |
Oops, something went wrong.