/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Converter.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/30 08:45:12 by narnaud #+# #+# */ /* Updated: 2022/07/12 08:42:27 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "Converter.hpp" Converter::Converter (void) { cout << "Converter default constructor called " << endl; } Converter::Converter (string str){ if (str[0] == '\'' || str[0] == '"') { _c = str[1]; cout << "Char: " << _c << endl; _d = static_cast(_c); } else { cout << "Char: "; _d = std::strtod(str.c_str(), 0); _c = static_cast(_d); if (_d < 0 || _d > 255) cout << "Invalid" << endl; else if (std::isprint(_c)) cout << "Not Printable" << endl; else cout << _c << endl; } cout << "Double: " << _d << endl; cout << "Integer: "; _i = static_cast(_d); if (_d < std::numeric_limits::min() || _d > std::numeric_limits::max()) cout << "Off limits -> "; cout << _i << endl; _f = static_cast(_d); cout << "Float: " << _f << "f"<< endl; } Converter::Converter (Converter const & src) { (void)src; cout << "Converter copy constructor called" << endl; } Converter & Converter::operator= (Converter const & src) { (void)src; cout << "Converter assignment operator called" << endl; return (*this); } Converter::~Converter (void) { cout << "Converter default destructor called" << endl; }