Qt 4.8
Classes | Functions
qabstractnetworkcache.cpp File Reference
#include "qabstractnetworkcache.h"
#include "qabstractnetworkcache_p.h"
#include <qdatetime.h>
#include <qurl.h>
#include <qdebug.h>

Go to the source code of this file.

Classes

class  QNetworkCacheMetaDataPrivate
 

Functions

static QDataStreamoperator<< (QDataStream &out, const QNetworkCacheMetaData::AttributesMap &hash)
 
static QDataStreamoperator>> (QDataStream &in, QNetworkCacheMetaData::AttributesMap &hash)
 

Function Documentation

◆ operator<<()

static QDataStream& operator<< ( QDataStream out,
const QNetworkCacheMetaData::AttributesMap hash 
)
inlinestatic

Definition at line 338 of file qabstractnetworkcache.cpp.

339 {
340  out << quint32(hash.size());
343  while (it != begin) {
344  --it;
345  out << int(it.key()) << it.value();
346  }
347  return out;
348 }
#define it(className, varName)
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition: qhash.h:474
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
unsigned int quint32
Definition: qglobal.h:938
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464

◆ operator>>()

static QDataStream& operator>> ( QDataStream in,
QNetworkCacheMetaData::AttributesMap hash 
)
inlinestatic

Definition at line 379 of file qabstractnetworkcache.cpp.

380 {
381  hash.clear();
382  QDataStream::Status oldStatus = in.status();
383  in.resetStatus();
384  hash.clear();
385 
386  quint32 n;
387  in >> n;
388 
389  for (quint32 i = 0; i < n; ++i) {
390  if (in.status() != QDataStream::Ok)
391  break;
392 
393  int k;
394  QVariant t;
395  in >> k >> t;
397  }
398 
399  if (in.status() != QDataStream::Ok)
400  hash.clear();
401  if (oldStatus != QDataStream::Ok)
402  in.setStatus(oldStatus);
403  return in;
404 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
Status status() const
Returns the status of the data stream.
void clear()
Removes all items from the hash.
Definition: qhash.h:574
Status
This enum describes the current status of the data stream.
Definition: qdatastream.h:101
void setStatus(Status status)
Sets the status of the data stream to the status given.
Attribute
Attribute codes for the QNetworkRequest and QNetworkReply.
void resetStatus()
Resets the status of the data stream.
unsigned int quint32
Definition: qglobal.h:938
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:772