OpenClonk
C4Network2Address Class Reference

#include <C4Network2Address.h>

Public Member Functions

 C4Network2Address ()=default
 
 C4Network2Address (C4NetIO::addr_t addr, C4Network2IOProtocol eProtocol)
 
 C4Network2Address (const C4Network2Address &addr)
 
void operator= (const C4Network2Address &addr)
 
bool operator== (const C4Network2Address &addr) const
 
const C4NetIO::addr_tgetAddr () const
 
C4NetIO::addr_tgetAddr ()
 
bool isIPNull () const
 
uint16_t getPort () const
 
C4Network2IOProtocol getProtocol () const
 
StdStrBuf toString () const
 
void SetAddr (C4NetIO::addr_t naddr)
 
void SetIP (C4NetIO::addr_t ip)
 
void SetPort (uint16_t iPort)
 
void SetProtocol (C4Network2IOProtocol enProtocol)
 
void CompileFunc (StdCompiler *pComp)
 

Protected Attributes

C4NetIO::addr_t addr
 
C4Network2IOProtocol eProtocol {P_NONE}
 

Detailed Description

Definition at line 22 of file C4Network2Address.h.

Constructor & Destructor Documentation

◆ C4Network2Address() [1/3]

C4Network2Address::C4Network2Address ( )
default

◆ C4Network2Address() [2/3]

C4Network2Address::C4Network2Address ( C4NetIO::addr_t  addr,
C4Network2IOProtocol  eProtocol 
)
inline

Definition at line 27 of file C4Network2Address.h.

29  { }
C4Network2IOProtocol eProtocol
C4NetIO::addr_t addr
EndpointAddress AsIPv4() const
Definition: C4NetIO.cpp:341

◆ C4Network2Address() [3/3]

C4Network2Address::C4Network2Address ( const C4Network2Address addr)
inline

Definition at line 31 of file C4Network2Address.h.

32  : addr(addr.getAddr()), eProtocol(addr.getProtocol())
33  { }

Member Function Documentation

◆ CompileFunc()

void C4Network2Address::CompileFunc ( StdCompiler pComp)

Definition at line 29 of file C4Network2Address.cpp.

30 {
31  // Clear
32  if (pComp->isDeserializer())
33  {
34  addr.Clear();
35  }
36 
37  // Write protocol
39  {
40  { "UDP", P_UDP },
41  { "TCP", P_TCP },
42 
43  { nullptr, P_NONE },
44  };
45  pComp->Value(mkEnumAdaptT<uint8_t>(eProtocol, Protocols));
46  pComp->Separator(StdCompiler::SEP_PART2); // ':'
47 
49 }
@ P_NONE
Definition: C4Network2IO.h:31
@ P_UDP
Definition: C4Network2IO.h:31
@ P_TCP
Definition: C4Network2IO.h:31
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:64
Definition: StdAdaptors.h:795
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References addr, C4NetIO::EndpointAddress::Clear(), eProtocol, StdCompiler::isDeserializer(), mkDefaultAdapt(), P_NONE, P_TCP, P_UDP, StdCompiler::SEP_PART2, StdCompiler::Separator(), and StdCompiler::Value().

Here is the call graph for this function:

◆ getAddr() [1/2]

C4NetIO::addr_t& C4Network2Address::getAddr ( )
inline

Definition at line 46 of file C4Network2Address.h.

46 { return addr; }

References addr.

◆ getAddr() [2/2]

const C4NetIO::addr_t& C4Network2Address::getAddr ( ) const
inline

Definition at line 45 of file C4Network2Address.h.

45 { return addr; }

References addr.

Referenced by C4Network2Client::DoConnectAttempt(), C4Network2Client::DoTCPSimultaneousOpen(), C4Network2ClientList::HandlePacket(), operator==(), and C4Network2Client::SendAddresses().

Here is the caller graph for this function:

◆ getPort()

uint16_t C4Network2Address::getPort ( ) const
inline

Definition at line 49 of file C4Network2Address.h.

49 { return addr.GetPort(); }
uint16_t GetPort() const
Definition: C4NetIO.cpp:547

References addr, and C4NetIO::EndpointAddress::GetPort().

Here is the call graph for this function:

◆ getProtocol()

C4Network2IOProtocol C4Network2Address::getProtocol ( ) const
inline

Definition at line 50 of file C4Network2Address.h.

50 { return eProtocol; }

References eProtocol.

Referenced by C4Network2Client::DoConnectAttempt(), C4Network2Client::DoTCPSimultaneousOpen(), and operator==().

Here is the caller graph for this function:

◆ isIPNull()

bool C4Network2Address::isIPNull ( ) const
inline

Definition at line 48 of file C4Network2Address.h.

48 { return addr.IsNull(); }

References addr, and C4NetIO::EndpointAddress::IsNull().

Referenced by C4Network2Client::DoTCPSimultaneousOpen(), and C4Network2ClientList::HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

void C4Network2Address::operator= ( const C4Network2Address addr)
inline

Definition at line 35 of file C4Network2Address.h.

36  { SetAddr(addr.getAddr()); SetProtocol(addr.getProtocol()); }
void SetProtocol(C4Network2IOProtocol enProtocol)
void SetAddr(C4NetIO::addr_t naddr)

References addr, SetAddr(), and SetProtocol().

Here is the call graph for this function:

◆ operator==()

bool C4Network2Address::operator== ( const C4Network2Address addr) const

Definition at line 61 of file C4Network2Address.cpp.

62 {
63  return eProtocol == addr2.getProtocol() && addr == addr2.getAddr();
64 }

References addr, eProtocol, getAddr(), and getProtocol().

Here is the call graph for this function:

◆ SetAddr()

void C4Network2Address::SetAddr ( C4NetIO::addr_t  naddr)
inline

Definition at line 54 of file C4Network2Address.h.

54 { addr = naddr.AsIPv4(); }

References addr, and C4NetIO::EndpointAddress::AsIPv4().

Referenced by operator=(), and C4Network2Reference::SetSourceAddress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetIP()

void C4Network2Address::SetIP ( C4NetIO::addr_t  ip)
inline

Definition at line 56 of file C4Network2Address.h.

56 { addr.SetAddress(ip.AsIPv4()); }
void SetAddress(const sockaddr *addr)
Definition: C4NetIO.cpp:364

References addr, C4NetIO::EndpointAddress::AsIPv4(), and C4NetIO::EndpointAddress::SetAddress().

Referenced by C4Network2ClientList::HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPort()

void C4Network2Address::SetPort ( uint16_t  iPort)
inline

Definition at line 57 of file C4Network2Address.h.

57 { addr.SetPort(iPort); }
void SetPort(uint16_t port)
Definition: C4NetIO.cpp:531

References addr, and C4NetIO::EndpointAddress::SetPort().

Here is the call graph for this function:

◆ SetProtocol()

void C4Network2Address::SetProtocol ( C4Network2IOProtocol  enProtocol)
inline

Definition at line 58 of file C4Network2Address.h.

58 { eProtocol = enProtocol; }

References eProtocol.

Referenced by operator=().

Here is the caller graph for this function:

◆ toString()

StdStrBuf C4Network2Address::toString ( ) const

Definition at line 51 of file C4Network2Address.cpp.

52 {
53  switch (eProtocol)
54  {
55  case P_UDP: return FormatString("UDP:%s", addr.ToString().getData());
56  case P_TCP: return FormatString("TCP:%s", addr.ToString().getData());
57  default: return StdStrBuf("INVALID");
58  }
59 }
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf ToString(int flags=0) const
Definition: C4NetIO.cpp:604

References addr, eProtocol, FormatString(), StdStrBuf::getData(), P_TCP, P_UDP, and C4NetIO::EndpointAddress::ToString().

Referenced by C4StartupNetListEntry::SetReference(), and C4Network2ClientDlg::UpdateText().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ addr

C4NetIO::addr_t C4Network2Address::addr
protected

◆ eProtocol

C4Network2IOProtocol C4Network2Address::eProtocol {P_NONE}
protected

Definition at line 42 of file C4Network2Address.h.

Referenced by CompileFunc(), getProtocol(), operator==(), SetProtocol(), and toString().


The documentation for this class was generated from the following files: