Qt 4.8
Public Functions | Public Variables | Friends | List of all members
QHostAddressPrivate Class Reference

Public Functions

void clear ()
 
bool parse ()
 
 QHostAddressPrivate ()
 
void setAddress (quint32 a_=0)
 
void setAddress (const quint8 *a_)
 
void setAddress (const Q_IPV6ADDR &a_)
 

Public Variables

quint32 a
 
Q_IPV6ADDR a6
 
QString ipString
 
bool isParsed
 
QAbstractSocket::NetworkLayerProtocol protocol
 
QString scopeId
 

Friends

class QHostAddress
 

Detailed Description

Definition at line 105 of file qhostaddress.cpp.

Constructors and Destructors

◆ QHostAddressPrivate()

QHostAddressPrivate::QHostAddressPrivate ( )

Definition at line 128 of file qhostaddress.cpp.

130 {
131  memset(&a6, 0, sizeof(a6));
132 }
QAbstractSocket::NetworkLayerProtocol protocol

Functions

◆ clear()

void QHostAddressPrivate::clear ( )

Definition at line 290 of file qhostaddress.cpp.

Referenced by QHostAddress::clear().

291 {
292  a = 0;
294  isParsed = true;
295  memset(&a6, 0, sizeof(a6));
296 }
QAbstractSocket::NetworkLayerProtocol protocol

◆ parse()

bool QHostAddressPrivate::parse ( )

Definition at line 261 of file qhostaddress.cpp.

Referenced by QHostAddress::setAddress().

262 {
263  isParsed = true;
266 
267  // All IPv6 addresses contain a ':', and may contain a '.'.
268  if (a.contains(QLatin1Char(':'))) {
269  quint8 maybeIp6[16];
270  if (parseIp6(a, maybeIp6, &scopeId)) {
271  setAddress(maybeIp6);
273  return true;
274  }
275  }
276 
277  // All IPv4 addresses contain a '.'.
278  if (a.contains(QLatin1Char('.'))) {
279  quint32 maybeIp4 = 0;
280  if (parseIp4(a, &maybeIp4)) {
281  setAddress(maybeIp4);
283  return true;
284  }
285  }
286 
287  return false;
288 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
QAbstractSocket::NetworkLayerProtocol protocol
unsigned char quint8
Definition: qglobal.h:934
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setAddress(quint32 a_=0)
static bool parseIp4(const QString &address, quint32 *addr)
static bool parseIp6(const QString &address, quint8 *addr, QString *scopeId)
QString simplified() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end, and that has each sequence o...
Definition: qstring.cpp:4415
unsigned int quint32
Definition: qglobal.h:938
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ setAddress() [1/3]

void QHostAddressPrivate::setAddress ( quint32  a_ = 0)

Definition at line 134 of file qhostaddress.cpp.

Referenced by parse(), QNetmaskAddress::setAddress(), and QHostAddress::setAddress().

135 {
136  a = a_;
138  isParsed = true;
139 }
QAbstractSocket::NetworkLayerProtocol protocol

◆ setAddress() [2/3]

void QHostAddressPrivate::setAddress ( const quint8 a_)

Definition at line 141 of file qhostaddress.cpp.

142 {
143  for (int i = 0; i < 16; i++)
144  a6[i] = a_[i];
146  isParsed = true;
147 }
QAbstractSocket::NetworkLayerProtocol protocol

◆ setAddress() [3/3]

void QHostAddressPrivate::setAddress ( const Q_IPV6ADDR a_)

Definition at line 149 of file qhostaddress.cpp.

150 {
151  a6 = a_;
152  a = 0;
154  isParsed = true;
155 }
QAbstractSocket::NetworkLayerProtocol protocol

Friends and Related Functions

◆ QHostAddress

friend class QHostAddress
friend

Definition at line 125 of file qhostaddress.cpp.

Properties

◆ a

quint32 QHostAddressPrivate::a

◆ a6

Q_IPV6ADDR QHostAddressPrivate::a6

◆ ipString

QString QHostAddressPrivate::ipString

Definition at line 121 of file qhostaddress.cpp.

Referenced by parse(), QHostAddress::QHostAddress(), and QHostAddress::setAddress().

◆ isParsed

bool QHostAddressPrivate::isParsed

Definition at line 122 of file qhostaddress.cpp.

Referenced by clear(), parse(), QHostAddress::QHostAddress(), and setAddress().

◆ protocol

QAbstractSocket::NetworkLayerProtocol QHostAddressPrivate::protocol

◆ scopeId

QString QHostAddressPrivate::scopeId

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