63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "dtcore/inc/dtdefinitions.h"
|
|
#include "dtcore/inc/dtstring.h"
|
|
|
|
namespace dt
|
|
{
|
|
|
|
class Address
|
|
{
|
|
public:
|
|
class Ip
|
|
{
|
|
public:
|
|
DT_CORE_DLL_ENTRY Ip();
|
|
DT_CORE_DLL_ENTRY Ip(U32 rhs);
|
|
DT_CORE_DLL_ENTRY Ip(const Ip& rhs);
|
|
DT_CORE_DLL_ENTRY Ip& operator=(const Ip& rhs);
|
|
|
|
DT_CORE_DLL_ENTRY String ToString() const;
|
|
DT_CORE_DLL_ENTRY friend String& operator<<(String& out, const Ip& rhs);
|
|
|
|
DT_CORE_DLL_ENTRY operator U32() const { return m_Ip; }
|
|
DT_CORE_DLL_ENTRY operator U32&() { return m_Ip; }
|
|
|
|
private:
|
|
U32 m_Ip;
|
|
};
|
|
|
|
DT_CORE_DLL_ENTRY Address();
|
|
DT_CORE_DLL_ENTRY Address(U32 addr, U16 port);
|
|
DT_CORE_DLL_ENTRY Address(const String& addr, U16 port);
|
|
DT_CORE_DLL_ENTRY Address(const Address& rhs);
|
|
|
|
DT_CORE_DLL_ENTRY Address& operator=(const Address& rhs);
|
|
|
|
DT_CORE_DLL_ENTRY bool IsValid() const;
|
|
|
|
DT_CORE_DLL_ENTRY U16 GetPort() const;
|
|
|
|
DT_CORE_DLL_ENTRY Ip GetIp() const;
|
|
|
|
DT_CORE_DLL_ENTRY String ToString() const;
|
|
|
|
DT_CORE_DLL_ENTRY friend String& operator<<(String& out, const Address& desc);
|
|
|
|
DT_CORE_DLL_ENTRY String IpToString() const;
|
|
|
|
DT_CORE_DLL_ENTRY bool Parse(const String& value);
|
|
|
|
DT_CORE_DLL_ENTRY static Ip GetLoopBackIp();
|
|
|
|
DT_CORE_DLL_ENTRY static Vector<Ip> GetLocalIps();
|
|
|
|
DT_CORE_DLL_ENTRY static bool GetIpByHostName(const String& name, Ip* out);
|
|
|
|
private:
|
|
enum { DT_SHADOW_SIZE_SOCKET_ADDR = 16 };
|
|
U8 m_Shadow[DT_SHADOW_SIZE_SOCKET_ADDR];
|
|
};
|
|
|
|
}
|
|
|