#include "ipaddr.h"
#include <sstream>
+/// Constructor
+IPAddr::IPAddr()
+{
+ atoms[0] = 0;
+ atoms[1] = 0;
+ atoms[2] = 0;
+ atoms[3] = 0;
+}
+
/// Constructor
IPAddr::IPAddr(atom a1, atom a2, atom a3, atom a4)
{
}
/// Constructor
-IPAddr::IPAddr(unsigned ip)
+IPAddr::IPAddr(int ip)
{
atoms[0] = ip >> 24;
atoms[1] = ip >> 16;
}
/// Constructor
-IPAddr::IPAddr(std::string ip) throw (std::logic_error)
+IPAddr::IPAddr(const char* ip) throw (std::logic_error)
{
std::istringstream iss(ip);
+ std::string ips;
for (int i = 0; i < 4; ++i)
{
- if (!std::getline(iss, ip, '.'))
+ if (!std::getline(iss, ips, '.'))
throw std::logic_error("Dirección IP inválida");
- atoms[i] = std::atoi(ip.c_str());
+ atoms[i] = std::atoi(ips.c_str());
}
}