Network: Replace some String by std::string

This commit is contained in:
Lynix
2020-07-25 14:32:53 +02:00
parent d298e93c13
commit aff617f147
13 changed files with 58 additions and 47 deletions

View File

@@ -51,7 +51,7 @@ namespace Nz
bool CheckEvents(ENetEvent* event);
ENetPeer* Connect(const IpAddress& remoteAddress, std::size_t channelCount = 0, UInt32 data = 0);
ENetPeer* Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr, std::size_t channelCount = 0, UInt32 data = 0);
ENetPeer* Connect(const std::string& hostName, NetProtocol protocol = NetProtocol_Any, const std::string& service = "http", ResolveError* error = nullptr, std::size_t channelCount = 0, UInt32 data = 0);
inline bool Create(NetProtocol protocol, UInt16 port, std::size_t peerCount, std::size_t channelCount = 0);
bool Create(const IpAddress& listenAddress, std::size_t peerCount, std::size_t channelCount = 0);

View File

@@ -47,7 +47,7 @@ namespace Nz
inline IPv4 ToIPv4() const;
inline IPv6 ToIPv6() const;
String ToString() const;
std::string ToString() const;
inline UInt32 ToUInt32() const;
inline explicit operator bool() const;
@@ -55,8 +55,8 @@ namespace Nz
IpAddress& operator=(const IpAddress&) = default;
IpAddress& operator=(IpAddress&&) noexcept = default;
static String ResolveAddress(const IpAddress& address, String* service = nullptr, ResolveError* error = nullptr);
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const String& hostname, const String& protocol = "http", ResolveError* error = nullptr);
static std::string ResolveAddress(const IpAddress& address, std::string* service = nullptr, ResolveError* error = nullptr);
static std::vector<HostnameInfo> ResolveHostname(NetProtocol procol, const std::string& hostname, const std::string& protocol = "http", ResolveError* error = nullptr);
inline friend std::ostream& operator<<(std::ostream& out, const IpAddress& address);
@@ -91,7 +91,7 @@ namespace Nz
IpAddress address;
NetProtocol protocol;
SocketType socketType;
String canonicalName;
std::string canonicalName;
};
}

View File

@@ -199,7 +199,6 @@ namespace Nz
* \param out The stream
* \param address The address to output
*/
inline std::ostream& operator<<(std::ostream& out, const IpAddress& address)
{
out << "IpAddress(" << address.ToString() << ')';

View File

@@ -37,7 +37,7 @@ namespace Nz
inline void Close();
bool Connect(const IpAddress& remoteAddress);
bool Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr);
bool Connect(const std::string& hostName, NetProtocol protocol = NetProtocol_Any, const std::string& service = "http", ResolveError* error = nullptr);
inline void Disconnect();
inline IpAddress GetBoundAddress() const;

View File

@@ -12,6 +12,7 @@
#include <Nazara/Core/Stream.hpp>
#include <Nazara/Network/AbstractSocket.hpp>
#include <Nazara/Network/IpAddress.hpp>
#include <string>
namespace Nz
{
@@ -28,7 +29,7 @@ namespace Nz
~TcpClient() = default;
SocketState Connect(const IpAddress& remoteAddress);
SocketState Connect(const String& hostName, NetProtocol protocol = NetProtocol_Any, const String& service = "http", ResolveError* error = nullptr);
SocketState Connect(const std::string& hostName, NetProtocol protocol = NetProtocol_Any, const std::string& service = "http", ResolveError* error = nullptr);
inline void Disconnect();
void EnableLowDelay(bool lowDelay);