Utils: Make port.h slimmer

Fix the fallout. Also make comparisons hidden friends.

Change-Id: Ib16a294391f5732f94f9f411a48220b497691de2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-07-27 12:38:07 +02:00
parent df358c7833
commit 072489829d
10 changed files with 47 additions and 34 deletions

View File

@@ -25,8 +25,11 @@
#include "port.h"
#include "qtcassert.h"
#include "stringutils.h"
#include <limits>
/*! \class Utils::Port
\brief The Port class implements a wrapper around a 16 bit port number
@@ -35,6 +38,21 @@
namespace Utils {
Port::Port(int port)
: m_port((port < 0 || port > std::numeric_limits<quint16>::max()) ? -1 : port)
{
}
Port::Port(uint port)
: m_port(port > std::numeric_limits<quint16>::max() ? -1 : port)
{
}
quint16 Port::number() const
{
QTC_ASSERT(isValid(), return -1); return quint16(m_port);
}
QList<Port> Port::parseFromSedOutput(const QByteArray &output)
{
QList<Port> ports;