summaryrefslogtreecommitdiffstats
path: root/src/tools/qdatastream.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-06-17 17:28:28 -0500
committerTimothy Pearson <[email protected]>2012-06-17 17:28:28 -0500
commit6dec101d43dcbd4195c47d54bd388db1a8d7230e (patch)
tree7c336cbed3a93807a34cd4df39b2f92a7d48a141 /src/tools/qdatastream.cpp
parentf27c2533f735d53c6b555f387c6390c0690cc246 (diff)
downloadtqt3-6dec101d43dcbd4195c47d54bd388db1a8d7230e.tar.gz
tqt3-6dec101d43dcbd4195c47d54bd388db1a8d7230e.zip
Automated update from Qt3
Diffstat (limited to 'src/tools/qdatastream.cpp')
-rw-r--r--src/tools/qdatastream.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/tools/qdatastream.cpp b/src/tools/qdatastream.cpp
index 1af0d649b..33cec9b37 100644
--- a/src/tools/qdatastream.cpp
+++ b/src/tools/qdatastream.cpp
@@ -83,7 +83,7 @@
file.open( IO_WriteOnly );
TQDataStream stream( &file ); // we will serialize the data into the file
stream << "the answer is"; // serialize a string
- stream << (Q_INT32)42; // serialize an integer
+ stream << (TQ_INT32)42; // serialize an integer
\endcode
Example (read binary data from a stream):
@@ -92,7 +92,7 @@
file.open( IO_ReadOnly );
TQDataStream stream( &file ); // read the data serialized from the file
TQString str;
- Q_INT32 a;
+ TQ_INT32 a;
stream >> str >> a; // extract "the answer is" and 42
\endcode
@@ -139,8 +139,8 @@
TQDataStream stream( &file );
// Write a header with a "magic number" and a version
- stream << (Q_UINT32)0xA0B0C0D0;
- stream << (Q_INT32)123;
+ stream << (TQ_UINT32)0xA0B0C0D0;
+ stream << (TQ_INT32)123;
// Write the data
stream << [lots of interesting data]
@@ -154,13 +154,13 @@
TQDataStream stream( &file );
// Read and check the header
- Q_UINT32 magic;
+ TQ_UINT32 magic;
stream >> magic;
if ( magic != 0xA0B0C0D0 )
return XXX_BAD_FILE_FORMAT;
// Read the version
- Q_INT32 version;
+ TQ_INT32 version;
stream >> version;
if ( version < 100 )
return XXX_BAD_FILE_TOO_OLD;
@@ -193,11 +193,11 @@
A similar pair of functions is readBytes() and writeBytes(). These
differ from their \e raw counterparts as follows: readBytes()
- reads a Q_UINT32 which is taken to be the length of the data to be
+ reads a TQ_UINT32 which is taken to be the length of the data to be
read, then that number of bytes is read into the preallocated
- char*; writeBytes() writes a Q_UINT32 containing the length of the
+ char*; writeBytes() writes a TQ_UINT32 containing the length of the
data, followed by the data. Notice that any encoding/decoding of
- the data (apart from the length Q_UINT32) must be done by you.
+ the data (apart from the length TQ_UINT32) must be done by you.
\sa TQTextStream TQVariant
*/
@@ -491,7 +491,7 @@ void TQDataStream::setByteOrder( int bo )
extern "C" long long __strtoll( const char *, char**, int );
#endif
-static Q_INT64 read_int_ascii( TQDataStream *s )
+static TQ_INT64 read_int_ascii( TQDataStream *s )
{
register int n = 0;
char buf[40];
@@ -522,7 +522,7 @@ static Q_INT64 read_int_ascii( TQDataStream *s )
}
/*!
- \overload TQDataStream &TQDataStream::operator>>( Q_UINT8 &i )
+ \overload TQDataStream &TQDataStream::operator>>( TQ_UINT8 &i )
Reads an unsigned byte from the stream into \a i, and returns a
reference to the stream.
@@ -533,25 +533,25 @@ static Q_INT64 read_int_ascii( TQDataStream *s )
reference to the stream.
*/
-TQDataStream &TQDataStream::operator>>( Q_INT8 &i )
+TQDataStream &TQDataStream::operator>>( TQ_INT8 &i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
- i = (Q_INT8)dev->getch();
+ i = (TQ_INT8)dev->getch();
if ( i == '\\' ) { // read octal code
char buf[4];
dev->readBlock( buf, 3 );
i = (buf[2] & 0x07)+((buf[1] & 0x07) << 3)+((buf[0] & 0x07) << 6);
}
} else { // data or text
- i = (Q_INT8)dev->getch();
+ i = (TQ_INT8)dev->getch();
}
return *this;
}
/*!
- \overload TQDataStream &TQDataStream::operator>>( Q_UINT16 &i )
+ \overload TQDataStream &TQDataStream::operator>>( TQ_UINT16 &i )
Reads an unsigned 16-bit integer from the stream into \a i, and
returns a reference to the stream.
@@ -564,13 +564,13 @@ TQDataStream &TQDataStream::operator>>( Q_INT8 &i )
returns a reference to the stream.
*/
-TQDataStream &TQDataStream::operator>>( Q_INT16 &i )
+TQDataStream &TQDataStream::operator>>( TQ_INT16 &i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
- i = (Q_INT16)read_int_ascii( this );
+ i = (TQ_INT16)read_int_ascii( this );
} else if ( noswap ) { // no conversion needed
- dev->readBlock( (char *)&i, sizeof(Q_INT16) );
+ dev->readBlock( (char *)&i, sizeof(TQ_INT16) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[2];
@@ -583,7 +583,7 @@ TQDataStream &TQDataStream::operator>>( Q_INT16 &i )
/*!
- \overload TQDataStream &TQDataStream::operator>>( Q_UINT32 &i )
+ \overload TQDataStream &TQDataStream::operator>>( TQ_UINT32 &i )
Reads an unsigned 32-bit integer from the stream into \a i, and
returns a reference to the stream.
@@ -596,13 +596,13 @@ TQDataStream &TQDataStream::operator>>( Q_INT16 &i )
returns a reference to the stream.
*/
-TQDataStream &TQDataStream::operator>>( Q_INT32 &i )
+TQDataStream &TQDataStream::operator>>( TQ_INT32 &i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
- i = (Q_INT32)read_int_ascii( this );
+ i = (TQ_INT32)read_int_ascii( this );
} else if ( noswap ) { // no conversion needed
- dev->readBlock( (char *)&i, sizeof(Q_INT32) );
+ dev->readBlock( (char *)&i, sizeof(TQ_INT32) );
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[4];
@@ -616,7 +616,7 @@ TQDataStream &TQDataStream::operator>>( Q_INT32 &i )
}
/*!
- \overload TQDataStream &TQDataStream::operator>>( Q_UINT64 &i )
+ \overload TQDataStream &TQDataStream::operator>>( TQ_UINT64 &i )
Reads an unsigned 64-bit integer from the stream, into \a i, and
returns a reference to the stream.
@@ -629,17 +629,17 @@ TQDataStream &TQDataStream::operator>>( Q_INT32 &i )
returns a reference to the stream.
*/
-TQDataStream &TQDataStream::operator>>( Q_INT64 &i )
+TQDataStream &TQDataStream::operator>>( TQ_INT64 &i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
i = read_int_ascii( this );
} else if ( version() < 6 ) {
- Q_UINT32 i1, i2;
+ TQ_UINT32 i1, i2;
*this >> i2 >> i1;
- i = ((Q_UINT64)i1 << 32) + i2;
+ i = ((TQ_UINT64)i1 << 32) + i2;
} else if ( noswap ) { // no conversion needed
- dev->readBlock( (char *)&i, sizeof(Q_INT64) );
+ dev->readBlock( (char *)&i, sizeof(TQ_INT64) );
} else { // swap bytes
uchar *p = (uchar *)(&i);
char b[8];
@@ -658,7 +658,7 @@ TQDataStream &TQDataStream::operator>>( Q_INT64 &i )
/*!
- \overload TQDataStream &TQDataStream::operator>>( Q_ULONG &i )
+ \overload TQDataStream &TQDataStream::operator>>( TQ_ULONG &i )
Reads an unsigned integer of the system's word length from the
stream, into \a i, and returns a reference to the stream.
@@ -673,18 +673,18 @@ TQDataStream &TQDataStream::operator>>( Q_INT64 &i )
*/
-TQDataStream &TQDataStream::operator>>( Q_LONG &i )
+TQDataStream &TQDataStream::operator>>( TQ_LONG &i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
- i = (Q_LONG)read_int_ascii( this );
+ i = (TQ_LONG)read_int_ascii( this );
} else if ( noswap ) { // no conversion needed
- dev->readBlock( (char *)&i, sizeof(Q_LONG) );
+ dev->readBlock( (char *)&i, sizeof(TQ_LONG) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
- char b[sizeof(Q_LONG)];
- dev->readBlock( b, sizeof(Q_LONG) );
- for ( int j = sizeof(Q_LONG); j; )
+ char b[sizeof(TQ_LONG)];
+ dev->readBlock( b, sizeof(TQ_LONG) );
+ for ( int j = sizeof(TQ_LONG); j; )
*p++ = b[--j];
}
return *this;
@@ -793,7 +793,7 @@ TQDataStream &TQDataStream::operator>>( char *&s )
The \a l parameter will be set to the length of the buffer.
- The serialization format is a Q_UINT32 length specifier first,
+ The serialization format is a TQ_UINT32 length specifier first,
then \a l bytes of data. Note that the data is \e not encoded.
\sa readRawBytes(), writeBytes()
@@ -802,7 +802,7 @@ TQDataStream &TQDataStream::operator>>( char *&s )
TQDataStream &TQDataStream::readBytes( char *&s, uint &l )
{
CHECK_STREAM_PRECOND
- Q_UINT32 len;
+ TQ_UINT32 len;
*this >> len; // first read length spec
l = (uint)len;
if ( len == 0 || eof() ) {
@@ -831,10 +831,10 @@ TQDataStream &TQDataStream::readRawBytes( char *s, uint len )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
- register Q_INT8 *p = (Q_INT8*)s;
+ register TQ_INT8 *p = (TQ_INT8*)s;
if ( version() < 4 ) {
while ( len-- ) {
- Q_INT32 tmp;
+ TQ_INT32 tmp;
*this >> tmp;
*p++ = tmp;
}
@@ -855,7 +855,7 @@ TQDataStream &TQDataStream::readRawBytes( char *s, uint len )
/*!
- \overload TQDataStream &TQDataStream::operator<<( Q_UINT8 i )
+ \overload TQDataStream &TQDataStream::operator<<( TQ_UINT8 i )
Writes an unsigned byte, \a i, to the stream and returns a
reference to the stream.
@@ -866,7 +866,7 @@ TQDataStream &TQDataStream::readRawBytes( char *s, uint len )
to the stream.
*/
-TQDataStream &TQDataStream::operator<<( Q_INT8 i )
+TQDataStream &TQDataStream::operator<<( TQ_INT8 i )
{
CHECK_STREAM_PRECOND
if ( printable && (i == '\\' || !isprint((uchar) i)) ) {
@@ -885,7 +885,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT8 i )
/*!
- \overload TQDataStream &TQDataStream::operator<<( Q_UINT16 i )
+ \overload TQDataStream &TQDataStream::operator<<( TQ_UINT16 i )
Writes an unsigned 16-bit integer, \a i, to the stream and returns
a reference to the stream.
@@ -898,7 +898,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT8 i )
reference to the stream.
*/
-TQDataStream &TQDataStream::operator<<( Q_INT16 i )
+TQDataStream &TQDataStream::operator<<( TQ_INT16 i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
@@ -906,7 +906,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT16 i )
sprintf( buf, "%d\n", i );
dev->writeBlock( buf, strlen(buf) );
} else if ( noswap ) { // no conversion needed
- dev->writeBlock( (char *)&i, sizeof(Q_INT16) );
+ dev->writeBlock( (char *)&i, sizeof(TQ_INT16) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[2];
@@ -924,7 +924,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT16 i )
reference to the stream.
*/
-TQDataStream &TQDataStream::operator<<( Q_INT32 i )
+TQDataStream &TQDataStream::operator<<( TQ_INT32 i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
@@ -932,7 +932,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT32 i )
sprintf( buf, "%d\n", i );
dev->writeBlock( buf, strlen(buf) );
} else if ( noswap ) { // no conversion needed
- dev->writeBlock( (char *)&i, sizeof(Q_INT32) );
+ dev->writeBlock( (char *)&i, sizeof(TQ_INT32) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[4];
@@ -946,7 +946,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT32 i )
}
/*!
- \overload TQDataStream &TQDataStream::operator<<( Q_UINT64 i )
+ \overload TQDataStream &TQDataStream::operator<<( TQ_UINT64 i )
Writes an unsigned 64-bit integer, \a i, to the stream and returns a
reference to the stream.
@@ -959,7 +959,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT32 i )
reference to the stream.
*/
-TQDataStream &TQDataStream::operator<<( Q_INT64 i )
+TQDataStream &TQDataStream::operator<<( TQ_INT64 i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
@@ -971,11 +971,11 @@ TQDataStream &TQDataStream::operator<<( Q_INT64 i )
#endif
dev->writeBlock( buf, strlen(buf) );
} else if ( version() < 6 ) {
- Q_UINT32 i1 = i & 0xffffffff;
- Q_UINT32 i2 = i >> 32;
+ TQ_UINT32 i1 = i & 0xffffffff;
+ TQ_UINT32 i2 = i >> 32;
*this << i2 << i1;
} else if ( noswap ) { // no conversion needed
- dev->writeBlock( (char *)&i, sizeof(Q_INT64) );
+ dev->writeBlock( (char *)&i, sizeof(TQ_INT64) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
char b[8];
@@ -993,7 +993,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT64 i )
}
/*!
- \overload TQDataStream &TQDataStream::operator<<( Q_ULONG i )
+ \overload TQDataStream &TQDataStream::operator<<( TQ_ULONG i )
Writes an unsigned integer \a i, of the system's word length, to
the stream and returns a reference to the stream.
@@ -1007,7 +1007,7 @@ TQDataStream &TQDataStream::operator<<( Q_INT64 i )
stream and returns a reference to the stream.
*/
-TQDataStream &TQDataStream::operator<<( Q_LONG i )
+TQDataStream &TQDataStream::operator<<( TQ_LONG i )
{
CHECK_STREAM_PRECOND
if ( printable ) { // printable data
@@ -1015,13 +1015,13 @@ TQDataStream &TQDataStream::operator<<( Q_LONG i )
sprintf( buf, "%ld\n", i );
dev->writeBlock( buf, strlen(buf) );
} else if ( noswap ) { // no conversion needed
- dev->writeBlock( (char *)&i, sizeof(Q_LONG) );
+ dev->writeBlock( (char *)&i, sizeof(TQ_LONG) );
} else { // swap bytes
register uchar *p = (uchar *)(&i);
- char b[sizeof(Q_LONG)];
- for ( int j = sizeof(Q_LONG); j; )
+ char b[sizeof(TQ_LONG)];
+ for ( int j = sizeof(TQ_LONG); j; )
b[--j] = *p++;
- dev->writeBlock( b, sizeof(Q_LONG) );
+ dev->writeBlock( b, sizeof(TQ_LONG) );
}
return *this;
}
@@ -1029,10 +1029,10 @@ TQDataStream &TQDataStream::operator<<( Q_LONG i )
/*!
- \overload TQDataStream &TQDataStream::operator<<( Q_UINT32 i )
+ \overload TQDataStream &TQDataStream::operator<<( TQ_UINT32 i )
Writes an unsigned integer, \a i, to the stream as a 32-bit
- unsigned integer (Q_UINT32). Returns a reference to the stream.
+ unsigned integer (TQ_UINT32). Returns a reference to the stream.
*/
/*!
@@ -1112,11 +1112,11 @@ TQDataStream &TQDataStream::operator<<( double f )
TQDataStream &TQDataStream::operator<<( const char *s )
{
if ( !s ) {
- *this << (Q_UINT32)0;
+ *this << (TQ_UINT32)0;
return *this;
}
uint len = tqstrlen( s ) + 1; // also write null terminator
- *this << (Q_UINT32)len; // write length specifier
+ *this << (TQ_UINT32)len; // write length specifier
return writeRawBytes( s, len );
}
@@ -1125,7 +1125,7 @@ TQDataStream &TQDataStream::operator<<( const char *s )
Writes the length specifier \a len and the buffer \a s to the
stream and returns a reference to the stream.
- The \a len is serialized as a Q_UINT32, followed by \a len bytes
+ The \a len is serialized as a TQ_UINT32, followed by \a len bytes
from \a s. Note that the data is \e not encoded.
\sa writeRawBytes(), readBytes()
@@ -1134,7 +1134,7 @@ TQDataStream &TQDataStream::operator<<( const char *s )
TQDataStream &TQDataStream::writeBytes(const char *s, uint len)
{
CHECK_STREAM_PRECOND
- *this << (Q_UINT32)len; // write length specifier
+ *this << (TQ_UINT32)len; // write length specifier
if ( len )
writeRawBytes( s, len );
return *this;
@@ -1157,7 +1157,7 @@ TQDataStream &TQDataStream::writeRawBytes( const char *s, uint len )
while ( len-- )
*this << *p++;
} else {
- register Q_INT8 *p = (Q_INT8*)s;
+ register TQ_INT8 *p = (TQ_INT8*)s;
while ( len-- )
*this << *p++;
}