diff --git a/src/main/cpp/datagrampacket.cpp b/src/main/cpp/datagrampacket.cpp
index 4482e99f8..7d5eb9d0b 100644
--- a/src/main/cpp/datagrampacket.cpp
+++ b/src/main/cpp/datagrampacket.cpp
@@ -20,25 +20,34 @@
using namespace LOG4CXX_NS::helpers;
+namespace
+{
+#if LOG4CXX_ABI_VERSION <= 15
+using PacketSizeType = int;
+#else
+using PacketSizeType = std::size_t;
+#endif
+}
+
struct DatagramPacket::DatagramPacketPriv
{
- DatagramPacketPriv(void* buf1, int length1)
+ DatagramPacketPriv(void* buf1, PacketSizeType length1)
: buf(buf1), offset(0), length(length1), address(), port(0)
{
}
- DatagramPacketPriv(void* buf1, int length1, InetAddressPtr address1,
+ DatagramPacketPriv(void* buf1, PacketSizeType length1, InetAddressPtr address1,
int port1)
: buf(buf1), offset(0), length(length1), address(address1), port(port1)
{
}
- DatagramPacketPriv(void* buf1, int offset1, int length1)
+ DatagramPacketPriv(void* buf1, PacketSizeType offset1, PacketSizeType length1)
: buf(buf1), offset(offset1), length(length1), address(), port(0)
{
}
- DatagramPacketPriv(void* buf1, int offset1, int length1,
+ DatagramPacketPriv(void* buf1, PacketSizeType offset1, PacketSizeType length1,
InetAddressPtr address1, int port1)
: buf(buf1), offset(offset1), length(length1), address(address1), port(port1)
{
@@ -48,10 +57,10 @@ struct DatagramPacket::DatagramPacketPriv
void* buf;
/** The offset of the data for this packet. */
- int offset;
+ PacketSizeType offset;
/** The length of the data for this packet. */
- int length;
+ PacketSizeType length;
/** The IP address for this packet. */
InetAddressPtr address;
@@ -64,7 +73,7 @@ IMPLEMENT_LOG4CXX_OBJECT(DatagramPacket)
/** Constructs a DatagramPacket for receiving packets of length
length. */
-DatagramPacket::DatagramPacket(void* buf1, int length1)
+DatagramPacket::DatagramPacket(void* buf1, PacketSizeType length1)
: m_priv(std::make_unique(buf1, length1))
{
}
@@ -72,7 +81,7 @@ DatagramPacket::DatagramPacket(void* buf1, int length1)
/** Constructs a datagram packet for sending packets of length
length/ to the specified port number on the specified
host. */
-DatagramPacket::DatagramPacket(void* buf1, int length1, InetAddressPtr address1,
+DatagramPacket::DatagramPacket(void* buf1, PacketSizeType length1, InetAddressPtr address1,
int port1)
: m_priv(std::make_unique(buf1, length1, address1, port1))
{
@@ -80,14 +89,14 @@ DatagramPacket::DatagramPacket(void* buf1, int length1, InetAddressPtr address1,
/** Constructs a DatagramPacket for receiving packets of length
length, specifying an offset into the buffer. */
-DatagramPacket::DatagramPacket(void* buf1, int offset1, int length1)
+DatagramPacket::DatagramPacket(void* buf1, PacketSizeType offset1, PacketSizeType length1)
: m_priv(std::make_unique(buf1, offset1, length1))
{
}
/** Constructs a datagram packet for sending packets of length
length with offset offset to the
specified port number on the specified host. */
-DatagramPacket::DatagramPacket(void* buf1, int offset1, int length1,
+DatagramPacket::DatagramPacket(void* buf1, PacketSizeType offset1, PacketSizeType length1,
InetAddressPtr address1, int port1)
: m_priv(std::make_unique(buf1, offset1, length1, address1, port1))
{
@@ -107,12 +116,12 @@ void* DatagramPacket::getData() const
return m_priv->buf;
}
-int DatagramPacket::getLength() const
+PacketSizeType DatagramPacket::getLength() const
{
return m_priv->length;
}
-int DatagramPacket::getOffset() const
+PacketSizeType DatagramPacket::getOffset() const
{
return m_priv->offset;
}
@@ -132,14 +141,14 @@ void DatagramPacket::setData(void* buf1)
m_priv->buf = buf1;
}
-void DatagramPacket::setData(void* buf1, int offset1, int length1)
+void DatagramPacket::setData(void* buf1, PacketSizeType offset1, PacketSizeType length1)
{
m_priv->buf = buf1;
m_priv->offset = offset1;
m_priv->length = length1;
}
-void DatagramPacket::setLength(int length1)
+void DatagramPacket::setLength(PacketSizeType length1)
{
m_priv->length = length1;
}
diff --git a/src/main/include/log4cxx/helpers/datagrampacket.h b/src/main/include/log4cxx/helpers/datagrampacket.h
index 92918f5c2..ee1519411 100644
--- a/src/main/include/log4cxx/helpers/datagrampacket.h
+++ b/src/main/include/log4cxx/helpers/datagrampacket.h
@@ -20,6 +20,7 @@
#include
#include
+#include
namespace LOG4CXX_NS
{
@@ -44,6 +45,7 @@ class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
LOG4CXX_CAST_ENTRY(DatagramPacket)
END_LOG4CXX_CAST_MAP()
+#if LOG4CXX_ABI_VERSION <= 15
/** Constructs a DatagramPacket for receiving packets of length
length. */
DatagramPacket(void* buf, int length);
@@ -62,6 +64,26 @@ class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
specified port number on the specified host. */
DatagramPacket(void* buf, int offset, int length, InetAddressPtr address,
int port);
+#else
+ /** Constructs a DatagramPacket for receiving packets of length
+ length. */
+ DatagramPacket(void* buf, std::size_t length);
+
+ /** Constructs a datagram packet for sending packets of length
+ length to the specified port number on the specified
+ host. */
+ DatagramPacket(void* buf, std::size_t length, InetAddressPtr address, int port);
+
+ /** Constructs a DatagramPacket for receiving packets of length
+ length, specifying an offset into the buffer. */
+ DatagramPacket(void* buf, std::size_t offset, std::size_t length);
+
+ /** Constructs a datagram packet for sending packets of length
+ length with offset offset to the
+ specified port number on the specified host. */
+ DatagramPacket(void* buf, std::size_t offset, std::size_t length, InetAddressPtr address,
+ int port);
+#endif
~DatagramPacket();
@@ -72,6 +94,7 @@ class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
/** Returns the data received or the data to be sent. */
void* getData() const;
+#if LOG4CXX_ABI_VERSION <= 15
/** Returns the length of the data to be sent or the length of the
data received. */
int getLength() const;
@@ -79,6 +102,15 @@ class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
/** Returns the offset of the data to be sent or the offset of the
data received. */
int getOffset() const;
+#else
+ /** Returns the length of the data to be sent or the length of the
+ data received. */
+ std::size_t getLength() const;
+
+ /** Returns the offset of the data to be sent or the offset of the
+ data received. */
+ std::size_t getOffset() const;
+#endif
/** Returns the port number on the remote host to which this
datagram is being sent or from which the datagram was received. */
@@ -89,11 +121,19 @@ class LOG4CXX_EXPORT DatagramPacket : public helpers::Object
/** Set the data buffer for this packet. */
void setData(void* buf1);
+#if LOG4CXX_ABI_VERSION <= 15
/** Set the data buffer for this packet. */
void setData(void* buf1, int offset1, int length1);
/** Set the length for this packet. */
void setLength(int length1);
+#else
+ /** Set the data buffer for this packet. */
+ void setData(void* buf1, std::size_t offset1, std::size_t length1);
+
+ /** Set the length for this packet. */
+ void setLength(std::size_t length1);
+#endif
void setPort(int port1);