」 feat: finished ex02

This commit is contained in:
2025-04-09 14:06:06 +02:00
parent df7ffd0aeb
commit 2cca13a331
8 changed files with 357 additions and 0 deletions

53
ex01/Serializer.cpp Normal file
View File

@ -0,0 +1,53 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Serializer.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 11:08:07 by adjoly #+# #+# */
/* Updated: 2025/04/09 12:23:14 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Serializer.hpp"
#include <string>
void _log(std::string emoji, std::string what, std::string who,
std::string str) {
#ifdef VERBOSE
if (who.empty())
std::cout << "" << emoji << "" << what << ": " << str << std::endl;
else
std::cout << "" << emoji << "" << what << "(" << who << "): " << str
<< std::endl;
#else
(void)emoji, (void)what, (void)who, (void)str;
#endif
}
uintptr_t Serializer::serialize(Data *ptr) {
return reinterpret_cast<uintptr_t>(ptr);
}
Data *Serializer::deserialize(uintptr_t raw) {
return reinterpret_cast<Data *>(raw);
}
Serializer::Serializer(void) {
_log("", "Serializer", "", "default constructor called");
}
Serializer::Serializer(const Serializer &cpy) {
_log("", "Serializer", "", "copy constructor called");
if (this != &cpy)
*this = cpy;
}
Serializer::~Serializer(void) {
_log("", "Serializer", "", "destructor called");
}
Serializer &Serializer::operator=(const Serializer &) {
return *this;
}