diff options
Diffstat (limited to 'Swiften/Network/HostAddress.cpp')
-rw-r--r-- | Swiften/Network/HostAddress.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp index 84a0012..ea324cb 100644 --- a/Swiften/Network/HostAddress.cpp +++ b/Swiften/Network/HostAddress.cpp @@ -1,10 +1,14 @@ #include "Swiften/Network/HostAddress.h" #include <boost/numeric/conversion/cast.hpp> +#include <boost/lexical_cast.hpp> #include <cassert> #include <sstream> #include <iomanip> +#include "Swiften/Base/foreach.h" +#include "Swiften/Base/String.h" + namespace Swift { HostAddress::HostAddress() { @@ -13,6 +17,14 @@ HostAddress::HostAddress() { } } +HostAddress::HostAddress(const String& address) { + std::vector<String> components = address.split('.'); + assert(components.size() == 4); + foreach(const String& component, components) { + address_.push_back(boost::lexical_cast<int>(component.getUTF8String())); + } +} + HostAddress::HostAddress(const unsigned char* address, int length) { assert(length == 4 || length == 16); address_.reserve(length); |