You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.4 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud </var/spool/mail/narnaud> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/08/04 16:48:40 by narnaud #+# #+# */
/* Updated: 2022/08/04 16:52:56 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include "Data.h"
#include "iostream"
#include "stdint.h"
uintptr_t serialize(t_Data* ptr) {
return reinterpret_cast<uintptr_t>(ptr);
}
t_Data* deserialize(uintptr_t raw) {
return reinterpret_cast<t_Data *>(raw);
}
int main(void) {
t_Data * data = new t_Data;
uintptr_t raw;
t_Data * ptr;
data->content = "Hi";
raw = serialize(data);
ptr = deserialize(raw);
std::cout
<< "Original content: " << data->content << std::endl
<< "Serialized: " << raw << std::endl
<< "Deserialized: " << ptr->content << std::endl;
delete data;
return (0);
}