Skip to content

Commit 5ed7057

Browse files
Improved swig bindings
1 parent 90fb146 commit 5ed7057

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

include/la/networkInterfaceHelper/networkInterfaceHelper.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ struct Interface
302302
bool isEnabled{ false }; /** True if this interface is enabled */
303303
bool isConnected{ false }; /** True if this interface is connected to a working network (able to send and receive packets) */
304304
bool isVirtual{ false }; /** True if this interface is emulating a physical adapter (Like BlueTooth, VirtualMachine, or Software Loopback) */
305+
306+
constexpr friend bool operator==(Interface const& lhs, Interface const& rhs) noexcept
307+
{
308+
return lhs.id == rhs.id && lhs.description == rhs.description && lhs.alias == rhs.alias && lhs.macAddress == rhs.macAddress && lhs.ipAddressInfos == rhs.ipAddressInfos && lhs.gateways == rhs.gateways && lhs.type == rhs.type && lhs.isEnabled == rhs.isEnabled && lhs.isConnected == rhs.isConnected && lhs.isVirtual == rhs.isVirtual;
309+
}
310+
constexpr friend bool operator!=(Interface const& lhs, Interface const& rhs) noexcept
311+
{
312+
return !(lhs == rhs);
313+
}
305314
};
306315

307316
/** MacAddress hash functor to be used for std::hash */

include/la/networkInterfaceHelper/networkInterfaceHelper.i

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
////////////////////////////////////////
6161
%nspace la::networkInterface::IPAddress;
6262
%ignore la::networkInterface::IPAddress::IPAddress(IPAddress&&); // Ignore move constructor
63+
%ignore la::networkInterface::IPAddress::operator=(IPAddress const&); // Ignore copy assignment operator
64+
%ignore la::networkInterface::IPAddress::operator=(IPAddress&&); // Ignore move assignment operator
6365
%ignore la::networkInterface::IPAddress::operator bool; // Ignore bool operator (equivalent to isValid)
6466
%ignore la::networkInterface::IPAddress::operator value_type_v4; // Ignore value_type_v4 operator (equivalent to getIPV4)
6567
%ignore la::networkInterface::IPAddress::operator value_type_v6; // Ignore value_type_v6 operator (equivalent to getIPV6)
@@ -70,6 +72,12 @@
7072
%ignore la::networkInterface::IPAddress::hash; // Ignore hash (not needed)
7173
%rename("toString") la::networkInterface::IPAddress::operator std::string;
7274
%typemap(csattributes) la::networkInterface::IPAddress "[System.Diagnostics.DebuggerDisplay(\"{toString()}\")]" // Better debug display
75+
%ignore operator==(IPAddress const& lhs, IPAddress const& rhs); // Redefined in %extend
76+
%ignore operator!=(IPAddress const& lhs, IPAddress const& rhs); // Ignored
77+
%ignore operator<(IPAddress const& lhs, IPAddress const& rhs); // Ignored
78+
%ignore operator<=(IPAddress const& lhs, IPAddress const& rhs); // Ignored
79+
%ignore operator+(IPAddress const& lhs, std::uint32_t const value); // Ignored
80+
%ignore operator-(IPAddress const& lhs, std::uint32_t const value); // Ignored
7381
%ignore operator++(IPAddress& lhs); // Redefined in %extend
7482
%ignore operator--(IPAddress& lhs); // Redefined in %extend
7583
%ignore operator&(IPAddress const& lhs, IPAddress const& rhs); // Redefined in %extend
@@ -126,11 +134,17 @@
126134
// IPAddressInfo
127135
////////////////////////////////////////
128136
%nspace la::networkInterface::IPAddressInfo;
137+
%ignore operator==(IPAddressInfo const& lhs, IPAddressInfo const& rhs); // Ignored
138+
%ignore operator!=(IPAddressInfo const& lhs, IPAddressInfo const& rhs); // Ignored
139+
%ignore operator<(IPAddressInfo const& lhs, IPAddressInfo const& rhs); // Ignored
140+
%ignore operator<=(IPAddressInfo const& lhs, IPAddressInfo const& rhs); // Ignored
129141

130142
////////////////////////////////////////
131143
// Interface
132144
////////////////////////////////////////
133145
%nspace la::networkInterface::Interface;
146+
%ignore operator==(Interface const& lhs, Interface const& rhs); // Redefined in %extend
147+
%ignore operator!=(Interface const& lhs, Interface const& rhs); // Ignored
134148
// Extend the struct
135149
%extend la::networkInterface::Interface
136150
{
@@ -148,7 +162,7 @@
148162
// Provide a more native Equals() method
149163
bool Equals(la::networkInterface::Interface const& other) const noexcept
150164
{
151-
return $self->id == other.id && $self->description == other.description && $self->alias == other.alias && $self->macAddress == other.macAddress && $self->ipAddressInfos == other.ipAddressInfos && $self->gateways == other.gateways && $self->type == other.type && $self->isEnabled == other.isEnabled && $self->isConnected == other.isConnected && $self->isVirtual == other.isVirtual;
165+
return *$self == other;
152166
}
153167
#endif
154168
};

0 commit comments

Comments
 (0)