Dokumentation mit Doxygen hinzugefügt
This commit is contained in:
parent
6ef408d6db
commit
5b682d5310
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ CMakeCache.txt
|
|||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
Makefile
|
Makefile
|
||||||
/C
|
/C
|
||||||
|
doc/
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
cmake_minimum_required(VERSION 3.3)
|
cmake_minimum_required(VERSION 3.3)
|
||||||
project(C/C++)
|
project(C/C++)
|
||||||
|
|
||||||
|
# add a target to generate API documentation with Doxygen
|
||||||
|
find_package(Doxygen)
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||||
|
add_custom_target(doc
|
||||||
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
COMMENT "Generating API documentation with Doxygen" VERBATIM
|
||||||
|
)
|
||||||
|
endif(DOXYGEN_FOUND)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||||
SET(CMAKE_BUILD_TYPE Debug)
|
SET(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
|
42
Doxyfile
Normal file
42
Doxyfile
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
PROJECT_NAME = C/C++
|
||||||
|
PROJECT_NUMBER =
|
||||||
|
OUTPUT_DIRECTORY = @CMAKE_CURRENT_SOURCE_DIR@/doc
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = German
|
||||||
|
...
|
||||||
|
JAVADOC_AUTOBRIEF = YES
|
||||||
|
...
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = NO
|
||||||
|
...
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/
|
||||||
|
FILE_PATTERNS =
|
||||||
|
RECURSIVE = YES
|
||||||
|
EXCLUDE =
|
||||||
|
...
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
...
|
||||||
|
...
|
||||||
|
|
||||||
|
GENERATE_LATEX = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to the search engine
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SEARCHENGINE = YES
|
||||||
|
|
||||||
|
|
@ -1,33 +1,13 @@
|
|||||||
|
file(GLOB 05_00a_MP_SRC "MP/*.h" "MP/*.cpp")
|
||||||
|
|
||||||
add_executable(05_OOa_MP
|
add_executable(05_OOa_MP
|
||||||
MP/shapes_main.cpp
|
${05_00a_MP_SRC}
|
||||||
MP/Shape.cpp
|
|
||||||
MP/Position.h
|
|
||||||
MP/Shape.h
|
|
||||||
MP/Point.cpp
|
|
||||||
MP/Point.h
|
|
||||||
MP/Circle.cpp
|
|
||||||
MP/Circle.h
|
|
||||||
MP/Rectangle.cpp
|
|
||||||
MP/Rectangle.h
|
|
||||||
MP/Scene.cpp
|
|
||||||
MP/Scene.h
|
|
||||||
../../helpers/AnsiConsole.cpp
|
../../helpers/AnsiConsole.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
file(GLOB 05_00a_Testat_SRC "Testat/*.h" "Testat/*.cpp")
|
||||||
|
|
||||||
add_executable(05_OOa_Testat
|
add_executable(05_OOa_Testat
|
||||||
Testat/shapes_main.cpp
|
${05_00a_Testat_SRC}
|
||||||
Testat/Shape.cpp
|
|
||||||
Testat/Position.h
|
|
||||||
Testat/Shape.h
|
|
||||||
Testat/Point.cpp
|
|
||||||
Testat/Point.h
|
|
||||||
Testat/Circle.cpp
|
|
||||||
Testat/Circle.h
|
|
||||||
Testat/Rectangle.cpp
|
|
||||||
Testat/Rectangle.h
|
|
||||||
Testat/Scene.cpp
|
|
||||||
Testat/Scene.h
|
|
||||||
Testat/Sign.cpp
|
|
||||||
Testat/Sign.h
|
|
||||||
../../helpers/AnsiConsole.cpp
|
../../helpers/AnsiConsole.cpp
|
||||||
)
|
)
|
@ -1,2 +1,2 @@
|
|||||||
add_executable(07_STD_MP MP/grundgeruest.cpp)
|
add_executable(07_STD_MP MP/grundgeruest.cpp MP/BinaryOctet.cpp MP/BinaryOctet.h)
|
||||||
add_executable(07_STD_Testat Testat/grundgeruest.cpp)
|
add_executable(07_STD_Testat Testat/grundgeruest.cpp)
|
162
src/07_STD/MP/BinaryOctet.cpp
Normal file
162
src/07_STD/MP/BinaryOctet.cpp
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <math.h>
|
||||||
|
#include "BinaryOctet.h"
|
||||||
|
|
||||||
|
BinaryOctet::BinaryOctet(int x) {
|
||||||
|
for (char &bitsAsDigit : bitsAsDigits) {
|
||||||
|
bitsAsDigit = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
int remainder;
|
||||||
|
int temp = 0;
|
||||||
|
while (x != 0) {
|
||||||
|
remainder = x % 2;
|
||||||
|
x /= 2;
|
||||||
|
bitsAsDigits[temp] = static_cast<char>(remainder + '0');
|
||||||
|
temp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::reverse(std::begin(bitsAsDigits), std::end(bitsAsDigits));
|
||||||
|
|
||||||
|
int ones = 0;
|
||||||
|
for (char c : bitsAsDigits) {
|
||||||
|
if (c == '1') ones++;
|
||||||
|
}
|
||||||
|
|
||||||
|
evenParity = ones % 2 == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BinaryOctet BinaryOctet::operator--(int) {
|
||||||
|
return operator-(*new BinaryOctet(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
const BinaryOctet BinaryOctet::operator++(int) {
|
||||||
|
return operator+(*new BinaryOctet(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryOctet BinaryOctet::operator+(BinaryOctet a) {
|
||||||
|
BinaryOctet result;
|
||||||
|
bool over = false;
|
||||||
|
for (int i = bitsPerOctet - 1; i >= 0; --i) {
|
||||||
|
//Arbeitsvariablen anlegen und char in int umwandeln für einfachere Rechnung
|
||||||
|
int tmp;
|
||||||
|
int aI = a.bitsAsDigits[i] - '0';
|
||||||
|
int bI = bitsAsDigits[i] - '0';
|
||||||
|
|
||||||
|
|
||||||
|
if(over) tmp = aI + bI + 1;
|
||||||
|
else tmp = aI + bI;
|
||||||
|
over = false;
|
||||||
|
|
||||||
|
|
||||||
|
if(tmp >= 2) {
|
||||||
|
over = true;
|
||||||
|
if (tmp % 2 == 0) tmp = 0;
|
||||||
|
else tmp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Umwandlung in char und ins Ergebnis schreiben
|
||||||
|
result.bitsAsDigits[i] = static_cast<char>(tmp + '0');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryOctet BinaryOctet::operator-(BinaryOctet a) {
|
||||||
|
BinaryOctet result;
|
||||||
|
bool over = false;
|
||||||
|
for(int i = bitsPerOctet - 1; i >= 0; --i) {
|
||||||
|
int tmp;
|
||||||
|
int aI = a.bitsAsDigits[i] - '0';
|
||||||
|
int bI = bitsAsDigits[i] - '0';
|
||||||
|
|
||||||
|
if(over) tmp = bI - aI - 1;
|
||||||
|
else tmp = bI - aI;
|
||||||
|
over = false;
|
||||||
|
|
||||||
|
if(tmp < 0) {
|
||||||
|
over = true;
|
||||||
|
tmp = tmp + 1;
|
||||||
|
}
|
||||||
|
result.bitsAsDigits[i] = static_cast<char>(tmp + '0');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryOctet BinaryOctet::operator/(BinaryOctet &a) {
|
||||||
|
BinaryOctet result = *new BinaryOctet(0);
|
||||||
|
|
||||||
|
while(*this >= a) {
|
||||||
|
*this = *this - a;
|
||||||
|
result = result + 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BinaryOctet::operator!=(BinaryOctet &a) {
|
||||||
|
if (a.evenParity !=evenParity) return false;
|
||||||
|
for (int i = 0; i < bitsPerOctet; ++i) {
|
||||||
|
if (a.bitsAsDigits[i] != bitsAsDigits[i]) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BinaryOctet::operator>=(BinaryOctet &a) {
|
||||||
|
|
||||||
|
int power = 8;
|
||||||
|
int aI = 0;
|
||||||
|
for(int i = 0; i <= bitsPerOctet - 1; i++) {
|
||||||
|
power--;
|
||||||
|
aI = aI + (a.bitsAsDigits[i] - '0') * pow(2, power);
|
||||||
|
}
|
||||||
|
|
||||||
|
power = 8;
|
||||||
|
int bI = 0;
|
||||||
|
for(int i = 0; i <= bitsPerOctet - 1; i++) {
|
||||||
|
power--;
|
||||||
|
bI = bI + (bitsAsDigits[i] - '0') * pow(2, power);
|
||||||
|
}
|
||||||
|
return bI >= aI;
|
||||||
|
}
|
||||||
|
|
||||||
|
BinaryOctet doCalculation(BinaryOctet a, BinaryOctet b) {
|
||||||
|
BinaryOctet result;
|
||||||
|
for (; a != b; b--) {
|
||||||
|
a = a + 1;
|
||||||
|
a = a / b;
|
||||||
|
}
|
||||||
|
result = a + b;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for println();
|
||||||
|
std::string as_string(BinaryOctet a) {
|
||||||
|
std::string result = "(";
|
||||||
|
for (char c : a.bitsAsDigits) {
|
||||||
|
result += c;
|
||||||
|
}
|
||||||
|
result += ")";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string as_string(BinaryOctet *a) {
|
||||||
|
std::string result = "(";
|
||||||
|
for (char c : a->bitsAsDigits) {
|
||||||
|
result += c;
|
||||||
|
}
|
||||||
|
result += ")";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for std::cout
|
||||||
|
std::ostream &operator<<(std::ostream &os, const BinaryOctet &toBePrinted) {
|
||||||
|
os << as_string(toBePrinted);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &os, BinaryOctet *toBePrinted) {
|
||||||
|
os << as_string(toBePrinted);
|
||||||
|
return os;
|
||||||
|
}
|
21
src/07_STD/MP/BinaryOctet.h
Normal file
21
src/07_STD/MP/BinaryOctet.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef C_C_BINARYOCTET_H
|
||||||
|
#define C_C_BINARYOCTET_H
|
||||||
|
|
||||||
|
const int bitsPerOctet = 8;
|
||||||
|
|
||||||
|
struct BinaryOctet {
|
||||||
|
bool evenParity;
|
||||||
|
char bitsAsDigits[bitsPerOctet]{};
|
||||||
|
|
||||||
|
BinaryOctet(int x = 0);
|
||||||
|
BinaryOctet(const BinaryOctet&) = default;
|
||||||
|
const BinaryOctet operator--(int);
|
||||||
|
const BinaryOctet operator++(int);
|
||||||
|
bool operator!=(BinaryOctet &a);
|
||||||
|
bool operator>=(BinaryOctet &a);
|
||||||
|
BinaryOctet operator-(BinaryOctet a);
|
||||||
|
BinaryOctet operator+(BinaryOctet a);
|
||||||
|
BinaryOctet operator/(BinaryOctet &a);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //C_C_BINARYOCTET_H
|
@ -8,17 +8,9 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
#include "grundgeruest.hpp"
|
#include "grundgeruest.hpp"
|
||||||
|
|
||||||
struct BinaryOctet {
|
|
||||||
bool evenParity;
|
|
||||||
char bitsAsDigits[8];
|
|
||||||
|
|
||||||
BinaryOctet(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
||||||
int array[41];
|
int array[41];
|
||||||
@ -32,6 +24,21 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unittest_stringSimilarity();
|
unittest_stringSimilarity();
|
||||||
|
|
||||||
|
std::vector<int> vector;
|
||||||
|
for (int i = 0; i <= 41; i++) {
|
||||||
|
int rnd = distribution(generator);
|
||||||
|
auto found = std::find(vector.begin(), vector.end(), rnd);
|
||||||
|
if(found == vector.end()) {
|
||||||
|
vector.push_back(rnd);
|
||||||
|
}
|
||||||
|
std::sort(vector.begin(), vector.end());
|
||||||
|
}
|
||||||
|
for (int ai : vector) {
|
||||||
|
std::cout << ai << ",";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,2 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @param string1 ein String
|
||||||
|
* @param string2 noch ein String
|
||||||
|
*/
|
||||||
int stringSimilarity(std::string string1, std::string string2);
|
int stringSimilarity(std::string string1, std::string string2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein test
|
||||||
|
*/
|
||||||
void unittest_stringSimilarity();
|
void unittest_stringSimilarity();
|
Loading…
x
Reference in New Issue
Block a user