This commit is contained in:
2024-02-20 15:35:19 +01:00
parent a5816720e4
commit 93c619a3c7
267 changed files with 10113 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
cpp01/ex06/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp01/ex06",
"program": "/home/fgras-ca/Bureau/fgras-ca/CPP/cpp01/ex06/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

105
cpp01/ex06/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,105 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
}
}

65
cpp01/ex06/Harl.cpp Normal file
View File

@@ -0,0 +1,65 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Harl.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 15:12:29 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 16:35:25 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
Harl::Harl() {}
void Harl::debug(void)
{
std::cout << "[DEBUG]\nI love having extra bacon for my 7XL-double-cheese-triple-pickle-specialketchup burger.\nI really do!" << std::endl;
}
void Harl::info(void)
{
std::cout << "[INFO]\n I cannot believe adding extra bacon costs more money.\nYou didn’t put enough bacon in my burger! If you did, I wouldn’t be asking for more!" << std::endl;
}
void Harl::warning(void)
{
std::cout << "[WARNING]\n I think I deserve to have some extra bacon for free.\nI’ve been coming for years whereas you started working here since last month." << std::endl;
}
void Harl::error(void)
{
std::cout << "[ERROR]\nThis is unacceptable! I want to speak to the manager now." << std::endl;
}
void Harl::complain(std::string level)
{
void (Harl::*complaints[])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
int i = 0;
while (levels[i] != level and i < 4)
i++;
switch (i)
{
case 0:
(this->*complaints[0])();
case 1:
(this->*complaints[1])();
case 2:
(this->*complaints[2])();
case 3:
{
(this->*complaints[3])();
break;
}
default:
std::cout << "[ Probably complaining about insignifiant problems ]" << std::endl;
break;
}
}
Harl::~Harl() {}

33
cpp01/ex06/Harl.hpp Normal file
View File

@@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Harl.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 15:08:34 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 15:11:58 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef HARL_HPP
# define HARL_HPP
#include <string>
#include <iostream>
class Harl
{
public:
Harl();
~Harl();
void complain(std::string level);
private:
void debug(void);
void info(void);
void warning(void);
void error(void);
};
#endif

BIN
cpp01/ex06/Harl.o Normal file

Binary file not shown.

62
cpp01/ex06/Makefile Normal file
View File

@@ -0,0 +1,62 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/27 16:19:19 by fgras-ca #+# #+# #
# Updated: 2023/12/27 16:20:59 by fgras-ca ### ########.fr #
# #
# **************************************************************************** #
LOGO = @echo " __, ____, ____, ____, ____ ____, ___, ____,";\
echo "(-| (-/_| (-| \ (-|_, (-|__) (-|_, (- / (-|_,";\
echo " _|__, _/ |, _|__/ _|__, _|__) _|__, _/__, _|__,";\
echo "( ( ( ( ( ( ( ("
DEF_COLOR = \033[0m
GRAY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
ORANGE = \033[38;5;214m
NAME = harlFilter
SRC = Harl.cpp \
main.cpp \
OBJS = ${SRC:.cpp=.o}
CC = c++
CFLAGS = -Wall -Werror -Wextra -std=c++98
RM = rm -f
all : $(NAME)
$(NAME) : $(OBJS)
@echo "$(RED)Compilation harlFilter... $(DEF_COLOR)"
$(CC) $(CFLAGS) $(OBJS) -g -o $(NAME)
@echo "$(GREEN)Compilation complete. $(ORANGE)Type "./harlFilter" to execute the program!!$(DEF_COLOR)"
$(LOGO)
clean :
@echo "$(RED)Deleating files objects... $(DEF_COLOR)"
$(RM) $(OBJS)
@echo "$(GREEN)files deleted!! $(DEF_COLOR)"
$(LOGO)
fclean : clean
@echo "$(RED)Delete program name... $(DEF_COLOR)"
$(RM) $(NAME)
@echo "$(GREEN)File program deleted!! $(DEF_COLOR)"
$(LOGO)
re : fclean all
.PHONY : all clean fclean re

BIN
cpp01/ex06/harlFilter Executable file

Binary file not shown.

29
cpp01/ex06/main.cpp Normal file
View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/27 16:05:56 by fgras-ca #+# #+# */
/* Updated: 2023/12/27 16:08:43 by fgras-ca ### ########.fr */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
int main(int argc, char **argv)
{
Harl harl;
if (argc != 2)
{
std::cerr << "Usage: ./harlFilter <level>" << std::endl;
return (1);
}
std::string level = argv[1];
harl.complain(level);
return (0);
}

BIN
cpp01/ex06/main.o Normal file

Binary file not shown.