/// \return A string representation of the address.
std::string toText() const;
+ /// \brief Convert the address to a C-style null-terminated string.
+ ///
+ /// \return A string representation of the address.
+ operator const char*() const { return toText().c_str(); }
+
/// \brief Returns const reference to the underlying address object.
///
/// This is useful, when access to interface offerted by
#include <asiolink/io_error.h>
#include <asiolink/io_address.h>
+#include <cstring>
+
using namespace isc::asiolink;
TEST(IOAddressTest, fromText) {
IOAddress io_address_v4("192.0.2.1");
EXPECT_EQ("192.0.2.1", io_address_v4.toText());
+ EXPECT_EQ(0, strcmp("192.0.2.1", (const char *)io_address_v4));
IOAddress io_address_v6("2001:db8::1234");
EXPECT_EQ("2001:db8::1234", io_address_v6.toText());