Network: Replace some String by std::string
This commit is contained in:
@@ -15,12 +15,12 @@ namespace Nz
|
||||
{
|
||||
using addrinfoImpl = addrinfo;
|
||||
|
||||
int GetAddressInfo(const String& hostname, const String& service, const addrinfoImpl* hints, addrinfoImpl** results)
|
||||
int GetAddressInfo(const std::string& hostname, const std::string& service, const addrinfoImpl* hints, addrinfoImpl** results)
|
||||
{
|
||||
return getaddrinfo(hostname.GetConstBuffer(), service.GetConstBuffer(), hints, results);
|
||||
return getaddrinfo(hostname.c_str(), service.c_str(), hints, results);
|
||||
}
|
||||
|
||||
int GetHostnameInfo(sockaddr* socketAddress, socklen_t socketLen, String* hostname, String* service, int flags)
|
||||
int GetHostnameInfo(sockaddr* socketAddress, socklen_t socketLen, std::string* hostname, std::string* service, int flags)
|
||||
{
|
||||
std::array<char, NI_MAXHOST> hostnameBuffer;
|
||||
std::array<char, NI_MAXSERV> serviceBuffer;
|
||||
@@ -29,10 +29,10 @@ namespace Nz
|
||||
if (result == 0)
|
||||
{
|
||||
if (hostname)
|
||||
hostname->Set(hostnameBuffer.data());
|
||||
hostname->assign(hostnameBuffer.data());
|
||||
|
||||
if (service)
|
||||
service->Set(serviceBuffer.data());
|
||||
service->assign(serviceBuffer.data());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -117,7 +117,7 @@ namespace Nz
|
||||
return IpAddress(ip6Address, ntohs(addressv6->sin6_port));
|
||||
}
|
||||
|
||||
bool IpAddressImpl::ResolveAddress(const IpAddress& ipAddress, String* hostname, String* service, ResolveError* error)
|
||||
bool IpAddressImpl::ResolveAddress(const IpAddress& ipAddress, std::string* hostname, std::string* service, ResolveError* error)
|
||||
{
|
||||
SockAddrBuffer socketAddress;
|
||||
socklen_t socketAddressLen = ToSockAddr(ipAddress, socketAddress.data());
|
||||
@@ -136,7 +136,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<HostnameInfo> IpAddressImpl::ResolveHostname(NetProtocol procol, const String& hostname, const String& service, ResolveError* error)
|
||||
std::vector<HostnameInfo> IpAddressImpl::ResolveHostname(NetProtocol procol, const std::string& hostname, const std::string& service, ResolveError* error)
|
||||
{
|
||||
std::vector<HostnameInfo> results;
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Nz
|
||||
{
|
||||
HostnameInfo result;
|
||||
result.address = FromAddrinfo(p);
|
||||
result.canonicalName = String::Unicode(p->ai_canonname);
|
||||
result.canonicalName = p->ai_canonname;
|
||||
result.protocol = TranslatePFToNetProtocol(p->ai_family);
|
||||
result.socketType = TranslateSockToNetProtocol(p->ai_socktype);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_IPADDRESSIMPL_HPP
|
||||
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
#include <string>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
@@ -26,8 +27,8 @@ namespace Nz
|
||||
static IpAddress FromSockAddr(const sockaddr_in* addressv4);
|
||||
static IpAddress FromSockAddr(const sockaddr_in6* addressv6);
|
||||
|
||||
static bool ResolveAddress(const IpAddress& ipAddress, String* hostname, String* service, ResolveError* error);
|
||||
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const String& hostname, const String& service, ResolveError* error);
|
||||
static bool ResolveAddress(const IpAddress& ipAddress, std::string* hostname, std::string* service, ResolveError* error);
|
||||
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const std::string& hostname, const std::string& service, ResolveError* error);
|
||||
|
||||
static socklen_t ToSockAddr(const IpAddress& ipAddress, void* buffer);
|
||||
static NetProtocol TranslatePFToNetProtocol(int family);
|
||||
@@ -36,4 +37,4 @@ namespace Nz
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_IPADDRESSIMPL_HPP
|
||||
#endif // NAZARA_IPADDRESSIMPL_HPP
|
||||
|
||||
Reference in New Issue
Block a user