equal
deleted
inserted
replaced
1440 bool QIODevicePrivate::putCharHelper(char c) |
1440 bool QIODevicePrivate::putCharHelper(char c) |
1441 { |
1441 { |
1442 return q_func()->write(&c, 1) == 1; |
1442 return q_func()->write(&c, 1) == 1; |
1443 } |
1443 } |
1444 |
1444 |
|
1445 /*! |
|
1446 \internal |
|
1447 */ |
|
1448 qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) |
|
1449 { |
|
1450 qint64 readBytes = q_func()->read(data, maxSize); |
|
1451 if (readBytes <= 0) |
|
1452 return readBytes; |
|
1453 |
|
1454 buffer.ungetBlock(data, readBytes); |
|
1455 *pPos -= readBytes; |
|
1456 return readBytes; |
|
1457 } |
|
1458 |
|
1459 /*! |
|
1460 \internal |
|
1461 */ |
|
1462 QByteArray QIODevicePrivate::peek(qint64 maxSize) |
|
1463 { |
|
1464 QByteArray result = q_func()->read(maxSize); |
|
1465 |
|
1466 if (result.isEmpty()) |
|
1467 return result; |
|
1468 |
|
1469 buffer.ungetBlock(result.constData(), result.size()); |
|
1470 *pPos -= result.size(); |
|
1471 return result; |
|
1472 } |
|
1473 |
1445 /*! \fn bool QIODevice::getChar(char *c) |
1474 /*! \fn bool QIODevice::getChar(char *c) |
1446 |
1475 |
1447 Reads one character from the device and stores it in \a c. If \a c |
1476 Reads one character from the device and stores it in \a c. If \a c |
1448 is 0, the character is discarded. Returns true on success; |
1477 is 0, the character is discarded. Returns true on success; |
1449 otherwise returns false. |
1478 otherwise returns false. |
1474 |
1503 |
1475 \sa read() |
1504 \sa read() |
1476 */ |
1505 */ |
1477 qint64 QIODevice::peek(char *data, qint64 maxSize) |
1506 qint64 QIODevice::peek(char *data, qint64 maxSize) |
1478 { |
1507 { |
1479 qint64 readBytes = read(data, maxSize); |
1508 return d_func()->peek(data, maxSize); |
1480 int i = readBytes; |
|
1481 while (i > 0) |
|
1482 ungetChar(data[i-- - 1]); |
|
1483 return readBytes; |
|
1484 } |
1509 } |
1485 |
1510 |
1486 /*! |
1511 /*! |
1487 \since 4.1 |
1512 \since 4.1 |
1488 \overload |
1513 \overload |
1500 |
1525 |
1501 \sa read() |
1526 \sa read() |
1502 */ |
1527 */ |
1503 QByteArray QIODevice::peek(qint64 maxSize) |
1528 QByteArray QIODevice::peek(qint64 maxSize) |
1504 { |
1529 { |
1505 QByteArray result = read(maxSize); |
1530 return d_func()->peek(maxSize); |
1506 int i = result.size(); |
|
1507 const char *data = result.constData(); |
|
1508 while (i > 0) |
|
1509 ungetChar(data[i-- - 1]); |
|
1510 return result; |
|
1511 } |
1531 } |
1512 |
1532 |
1513 /*! |
1533 /*! |
1514 Blocks until new data is available for reading and the readyRead() |
1534 Blocks until new data is available for reading and the readyRead() |
1515 signal has been emitted, or until \a msecs milliseconds have |
1535 signal has been emitted, or until \a msecs milliseconds have |