Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
libktorrent
Commits
511b8665
Commit
511b8665
authored
Jul 25, 2022
by
Nicolas Fella
Browse files
Port away from QStringRef
parent
b8ef3422
Pipeline
#208551
failed with stage
in 1 minute and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/upnp/upnpdescriptionparser.cpp
View file @
511b8665
...
...
@@ -8,13 +8,18 @@
#include
<QFile>
#include
<QStack>
#include
<QStringRef>
#include
<QXmlStreamReader>
#include
"upnprouter.h"
#include
<util/fileops.h>
#include
<util/log.h>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
using
StringView
=
QStringView
;
#else
using
StringView
=
QStringRef
;
#endif
using
namespace
bt
;
namespace
bt
...
...
@@ -43,12 +48,12 @@ public:
bool
startDocument
();
bool
endDocument
();
bool
startElement
(
const
Q
String
Ref
&
namespaceUri
,
const
Q
String
Ref
&
localName
,
const
Q
String
Ref
&
qName
,
const
QXmlStreamAttributes
&
atts
);
bool
endElement
(
const
Q
String
Ref
&
namespaceUri
,
const
Q
String
Ref
&
localName
,
const
Q
String
Ref
&
qName
);
bool
characters
(
const
Q
String
Ref
&
chars
);
bool
startElement
(
const
String
View
&
namespaceUri
,
const
String
View
&
localName
,
const
String
View
&
qName
,
const
QXmlStreamAttributes
&
atts
);
bool
endElement
(
const
String
View
&
namespaceUri
,
const
String
View
&
localName
,
const
String
View
&
qName
);
bool
characters
(
const
String
View
&
chars
);
bool
interestingDeviceField
(
const
Q
String
Ref
&
name
);
bool
interestingServiceField
(
const
Q
String
Ref
&
name
);
bool
interestingDeviceField
(
const
String
View
&
name
);
bool
interestingServiceField
(
const
String
View
&
name
);
};
UPnPDescriptionParser
::
UPnPDescriptionParser
()
...
...
@@ -160,17 +165,19 @@ bool XMLContentHandler::endDocument()
return
true
;
}
bool
XMLContentHandler
::
interestingDeviceField
(
const
Q
String
Ref
&
name
)
bool
XMLContentHandler
::
interestingDeviceField
(
const
String
View
&
name
)
{
return
name
==
"friendlyName"
||
name
==
"manufacturer"
||
name
==
"modelDescription"
||
name
==
"modelName"
||
name
==
"modelNumber"
;
return
name
==
QLatin1String
(
"friendlyName"
)
||
name
==
QLatin1String
(
"manufacturer"
)
||
name
==
QLatin1String
(
"modelDescription"
)
||
name
==
QLatin1String
(
"modelName"
)
||
name
==
QLatin1String
(
"modelNumber"
);
}
bool
XMLContentHandler
::
interestingServiceField
(
const
Q
String
Ref
&
name
)
bool
XMLContentHandler
::
interestingServiceField
(
const
String
View
&
name
)
{
return
name
==
"serviceType"
||
name
==
"serviceId"
||
name
==
"SCPDURL"
||
name
==
"controlURL"
||
name
==
"eventSubURL"
;
return
name
==
QLatin1String
(
"serviceType"
)
||
name
==
QLatin1String
(
"serviceId"
)
||
name
==
QLatin1String
(
"SCPDURL"
)
||
name
==
QLatin1String
(
"controlURL"
)
||
name
==
QLatin1String
(
"eventSubURL"
);
}
bool
XMLContentHandler
::
startElement
(
const
Q
String
Ref
&
namespaceUri
,
const
Q
String
Ref
&
localName
,
const
Q
String
Ref
&
qName
,
const
QXmlStreamAttributes
&
atts
)
bool
XMLContentHandler
::
startElement
(
const
String
View
&
namespaceUri
,
const
String
View
&
localName
,
const
String
View
&
qName
,
const
QXmlStreamAttributes
&
atts
)
{
Q_UNUSED
(
namespaceUri
)
Q_UNUSED
(
qName
)
...
...
@@ -180,7 +187,7 @@ bool XMLContentHandler::startElement(const QStringRef &namespaceUri, const QStri
switch
(
status_stack
.
top
())
{
case
TOPLEVEL
:
// from toplevel we can only go to root
if
(
localName
==
"root"
)
if
(
localName
==
QLatin1String
(
"root"
)
)
status_stack
.
push
(
ROOT
);
else
return
false
;
...
...
@@ -188,7 +195,7 @@ bool XMLContentHandler::startElement(const QStringRef &namespaceUri, const QStri
case
ROOT
:
// from the root we can go to device or specVersion
// we are not interested in the specVersion
if
(
localName
==
"device"
)
if
(
localName
==
QLatin1String
(
"device"
)
)
status_stack
.
push
(
DEVICE
);
else
status_stack
.
push
(
OTHER
);
...
...
@@ -207,9 +214,9 @@ bool XMLContentHandler::startElement(const QStringRef &namespaceUri, const QStri
status_stack
.
push
(
OTHER
);
break
;
case
OTHER
:
if
(
localName
==
"service"
)
if
(
localName
==
QLatin1String
(
"service"
)
)
status_stack
.
push
(
SERVICE
);
else
if
(
localName
==
"device"
)
else
if
(
localName
==
QLatin1String
(
"device"
)
)
status_stack
.
push
(
DEVICE
);
else
status_stack
.
push
(
OTHER
);
...
...
@@ -220,7 +227,7 @@ bool XMLContentHandler::startElement(const QStringRef &namespaceUri, const QStri
return
true
;
}
bool
XMLContentHandler
::
endElement
(
const
Q
String
Ref
&
namespaceUri
,
const
Q
String
Ref
&
localName
,
const
Q
String
Ref
&
qName
)
bool
XMLContentHandler
::
endElement
(
const
String
View
&
namespaceUri
,
const
String
View
&
localName
,
const
String
View
&
qName
)
{
Q_UNUSED
(
namespaceUri
)
Q_UNUSED
(
qName
)
...
...
@@ -254,7 +261,7 @@ bool XMLContentHandler::endElement(const QStringRef &namespaceUri, const QString
return
true
;
}
bool
XMLContentHandler
::
characters
(
const
Q
String
Ref
&
chars
)
bool
XMLContentHandler
::
characters
(
const
String
View
&
chars
)
{
tmp
.
append
(
chars
);
return
true
;
...
...
src/upnp/upnpmcastsocket.cpp
View file @
511b8665
...
...
@@ -269,7 +269,11 @@ void UPnPMCastSocket::UPnPMCastSocketPrivate::leaveUPnPMCastGroup(int fd)
UPnPRouter
*
UPnPMCastSocket
::
UPnPMCastSocketPrivate
::
parseResponse
(
const
QByteArray
&
arr
)
{
const
QString
response
=
QString
::
fromLatin1
(
arr
);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QVector
<
QStringView
>
lines
=
QStringView
(
response
).
split
(
QStringLiteral
(
"
\r\n
"
));
#else
QVector
<
QStringRef
>
lines
=
response
.
splitRef
(
"
\r\n
"
);
#endif
QString
server
;
QUrl
location
;
...
...
@@ -280,7 +284,7 @@ UPnPRouter *UPnPMCastSocket::UPnPMCastSocketPrivate::parseResponse(const QByteAr
*/
// first read first line and see if contains a HTTP 200 OK message
QStringRef
line
=
lines
.
first
();
auto
line
=
lines
.
first
();
if
(
!
line
.
contains
(
QLatin1String
(
"HTTP"
)))
{
// it is either a 200 OK or a NOTIFY
if
(
!
line
.
contains
(
QLatin1String
(
"NOTIFY"
))
&&
!
line
.
contains
(
QLatin1String
(
"200"
)))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment