本文整理汇总了C++中QStringMap::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringMap::clear方法的具体用法?C++ QStringMap::clear怎么用?C++ QStringMap::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringMap
的用法示例。
在下文中一共展示了QStringMap::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendSOAPRequest
//.........这里部分代码省略.........
// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------
QBuffer buff(&aBuffer);
LOG(VB_UPNP, LOG_DEBUG,
QString("SOAPClient(%1) sending:\n").arg(url.toString()) +
header.toString() + QString("\n%1\n").arg(aBuffer.constData()));
QString sXml =
HttpComms::postHttp(url,
&header,
&buff, // QIODevice*
10000, // ms -- Technically should be 30ms per spec
3, // retries
0, // redirects
false, // allow gzip
NULL, // login
bInQtThread,
QString() // userAgent, UPnP/1.0 very strict on
// format if set
);
// --------------------------------------------------------------
// Parse response
// --------------------------------------------------------------
LOG(VB_UPNP, LOG_DEBUG, "SOAPClient response:\n" +
QString("%1\n").arg(sXml));
// TODO handle timeout without response correctly.
list.clear();
QDomDocument doc;
if (!doc.setContent(sXml, true, &sErrDesc, &nErrCode))
{
LOG(VB_UPNP, LOG_ERR,
QString("SendSOAPRequest( %1 ) - Invalid response from %2")
.arg(sMethod).arg(url.toString()) +
QString("%1: %2").arg(nErrCode).arg(sErrDesc));
return xmlResult;
}
// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------
QString sResponseName = sMethod + "Response";
QDomNodeList oNodeList =
doc.elementsByTagNameNS(m_sNamespace, sResponseName);
if (oNodeList.count() == 0)
{
// --------------------------------------------------------------
// Must be a fault... parse it to return reason
// --------------------------------------------------------------
nErrCode = GetNodeValue(
doc, "Envelope/Body/Fault/detail/UPnPError/errorCode", 500);
sErrDesc = GetNodeValue(
doc, "Envelope/Body/Fault/detail/UPnPError/errorDescription", "");
if (sErrDesc.isEmpty())
示例2: SendSOAPRequest
QDomDocument SOAPClient::SendSOAPRequest(const QString &sMethod,
QStringMap &list,
int &nErrCode,
QString &sErrDesc)
{
QUrl url(m_url);
url.setPath(m_sControlPath);
nErrCode = UPnPResult_Success;
sErrDesc = "";
QDomDocument xmlResult;
if (m_sNamespace.isEmpty())
{
nErrCode = UPnPResult_MythTV_NoNamespaceGiven;
sErrDesc = "No namespace given";
return xmlResult;
}
// --------------------------------------------------------------
// Add appropriate headers
// --------------------------------------------------------------
QHash<QByteArray, QByteArray> headers;
headers.insert("Content-Type", "text/xml; charset=\"utf-8\"");
QString soapHeader = QString("\"%1#%2\"").arg(m_sNamespace).arg(sMethod);
headers.insert("SOAPACTION", soapHeader.toUtf8());
headers.insert("User-Agent", "Mozilla/9.876 (X11; U; Linux 2.2.12-20 i686, en) "
"Gecko/25250101 Netscape/5.432b1");
// --------------------------------------------------------------
// Build request payload
// --------------------------------------------------------------
QByteArray aBuffer;
QTextStream os( &aBuffer );
os.setCodec("UTF-8");
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
os << "<s:Envelope "
" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\""
" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
os << " <s:Body>\r\n";
os << " <u:" << sMethod << " xmlns:u=\"" << m_sNamespace << "\">\r\n";
// --------------------------------------------------------------
// Add parameters from list
// --------------------------------------------------------------
for (QStringMap::iterator it = list.begin(); it != list.end(); ++it)
{
os << " <" << it.key() << ">";
os << HTTPRequest::Encode( *it );
os << "</" << it.key() << ">\r\n";
}
os << " </u:" << sMethod << ">\r\n";
os << " </s:Body>\r\n";
os << "</s:Envelope>\r\n";
os.flush();
// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------
LOG(VB_UPNP, LOG_DEBUG,
QString("SOAPClient(%1) sending:\n %2").arg(url.toString()).arg(aBuffer.constData()));
QString sXml;
if (!GetMythDownloadManager()->postAuth(url.toString(), &aBuffer, NULL, NULL, &headers))
{
LOG(VB_GENERAL, LOG_ERR, QString("SOAPClient::SendSOAPRequest: request failed: %1")
.arg(url.toString()));
}
else
sXml = QString(aBuffer);
// --------------------------------------------------------------
// Parse response
// --------------------------------------------------------------
LOG(VB_UPNP, LOG_DEBUG, "SOAPClient response:\n" +
QString("%1\n").arg(sXml));
// TODO handle timeout without response correctly.
list.clear();
QDomDocument doc;
if (!doc.setContent(sXml, true, &sErrDesc, &nErrCode))
{
LOG(VB_UPNP, LOG_ERR,
QString("SendSOAPRequest( %1 ) - Invalid response from %2")
.arg(sMethod).arg(url.toString()) +
QString("%1: %2").arg(nErrCode).arg(sErrDesc));
//.........这里部分代码省略.........
示例3: SendSOAPRequest
bool SOAPClient::SendSOAPRequest( const QString &sMethod,
QStringMap &list,
int &nErrCode,
QString &sErrDesc,
bool bInQtThread )
{
QUrl url( m_url );
url.setPath( m_sControlPath );
// --------------------------------------------------------------
// Add appropriate headers
// --------------------------------------------------------------
QHttpRequestHeader header;
header.setValue("CONTENT-TYPE", "text/xml; charset=\"utf-8\"" );
header.setValue("SOAPACTION" , QString( "\"%1#GetConnectionInfo\"" )
.arg( m_sNamespace ));
// --------------------------------------------------------------
// Build request payload
// --------------------------------------------------------------
QByteArray aBuffer;
QTextStream os( &aBuffer );
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
os << "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
os << " <s:Body>\r\n";
os << " <u:" << sMethod << " xmlns:u=\"" << m_sNamespace << "\">\r\n";
// --------------------------------------------------------------
// Add parameters from list
// --------------------------------------------------------------
for ( QStringMap::iterator it = list.begin();
it != list.end();
++it )
{
os << " <" << it.key() << ">";
os << HTTPRequest::Encode( *it );
os << "</" << it.key() << ">\r\n";
}
os << " </u:" << sMethod << ">\r\n";
os << " </s:Body>\r\n";
os << "</s:Envelope>\r\n";
os.flush();
// --------------------------------------------------------------
// Perform Request
// --------------------------------------------------------------
QBuffer buff( &aBuffer );
QString sXml = HttpComms::postHttp( url,
&header,
(QIODevice *)&buff,
10000, // ms
3, // retries
0, // redirects
false, // allow gzip
NULL, // login
bInQtThread );
// --------------------------------------------------------------
// Parse response
// --------------------------------------------------------------
list.clear();
QDomDocument doc;
if ( !doc.setContent( sXml, true, &sErrDesc, &nErrCode ))
{
VERBOSE( VB_UPNP, QString( "MythXMLClient::SendSOAPRequest( %1 ) - Invalid response from %2" )
.arg( sMethod )
.arg( url.toString() ));
return false;
}
// --------------------------------------------------------------
// Is this a valid response?
// --------------------------------------------------------------
QString sResponseName = sMethod + "Response";
QDomNodeList oNodeList = doc.elementsByTagNameNS( m_sNamespace, sResponseName );
if (oNodeList.count() > 0)
{
QDomNode oMethod = oNodeList.item(0);
if (!oMethod.isNull())
{
for ( QDomNode oNode = oMethod.firstChild(); !oNode.isNull();
oNode = oNode.nextSibling() )
{
//.........这里部分代码省略.........