<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qendian.qdoc --> <head> <title>Qt 4.6: <QtEndian> - Endian Conversion Functions</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title"><QtEndian> - Endian Conversion Functions<br /><span class="subtitle"></span> </h1> <p>The <QtEndian> header provides functions to convert between little and big endian representations of numbers. <a href="#details">More...</a></p> <ul> </ul> <a name="Functionsx"></a> <h2>Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qFromBigEndian">qFromBigEndian</a></b> ( const uchar * <i>src</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qFromBigEndian-2">qFromBigEndian</a></b> ( T <i>src</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qFromLittleEndian">qFromLittleEndian</a></b> ( const uchar * <i>src</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qFromLittleEndian-2">qFromLittleEndian</a></b> ( T <i>src</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qToBigEndian">qToBigEndian</a></b> ( T <i>src</i>, uchar * <i>dest</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qToBigEndian-2">qToBigEndian</a></b> ( T <i>src</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qToLittleEndian">qToLittleEndian</a></b> ( T <i>src</i>, uchar * <i>dest</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">T </td><td class="memItemRight" valign="bottom"><b><a href="qtendian.html#qToLittleEndian-2">qToLittleEndian</a></b> ( T <i>src</i> )</td></tr> </table> <hr /> <h2>Function Documentation</h2> <a name="//apple_ref/cpp/func//qFromBigEndian"></a> <h3 class="fn"><a name="qFromBigEndian"></a>T qFromBigEndian ( const <a href="qtglobal.html#uchar-typedef">uchar</a> * <i>src</i> )</h3> <p>Reads a big-endian number from memory location <i>src</i> and returns the number in the host byte order representation. On CPU architectures where the host byte order is little-endian (such as x86) this will swap the byte order; otherwise it will just read from <i>src</i>.</p> <p><b>Note:</b> Template type <tt>T</tt> can either be a qint16, qint32 or qint64. Other types of integers, e.g., qlong, are not applicable.</p> <p>There are no data alignment constraints for <i>src</i>.</p> <p>This function was introduced in Qt 4.3.</p> <p>See also <a href="qtendian.html#qFromLittleEndian">qFromLittleEndian</a>(), <a href="qtendian.html#qToBigEndian">qToBigEndian</a>(), and <a href="qtendian.html#qToLittleEndian">qToLittleEndian</a>().</p> <h3 class="fn"><a name="qFromBigEndian-2"></a>T qFromBigEndian ( T <i>src</i> )</h3> <p>This is an overloaded function.</p> <p>Converts <i>src</i> from big-endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is little-endian (such as x86) this will return <i>src</i> with the byte order swapped; otherwise it will return <i>src</i> unmodified.</p> <p>This function was introduced in Qt 4.3.</p> <a name="//apple_ref/cpp/func//qFromLittleEndian"></a> <h3 class="fn"><a name="qFromLittleEndian"></a>T qFromLittleEndian ( const <a href="qtglobal.html#uchar-typedef">uchar</a> * <i>src</i> )</h3> <p>Reads a little-endian number from memory location <i>src</i> and returns the number in the host byte order representation. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will swap the byte order; otherwise it will just read from <i>src</i>.</p> <p><b>Note:</b> Template type <tt>T</tt> can either be a qint16, qint32 or qint64. Other types of integers, e.g., qlong, are not applicable.</p> <p>There are no data alignment constraints for <i>src</i>.</p> <p>This function was introduced in Qt 4.3.</p> <p>See also <a href="qtendian.html#qFromBigEndian">qFromBigEndian</a>(), <a href="qtendian.html#qToBigEndian">qToBigEndian</a>(), and <a href="qtendian.html#qToLittleEndian">qToLittleEndian</a>().</p> <h3 class="fn"><a name="qFromLittleEndian-2"></a>T qFromLittleEndian ( T <i>src</i> )</h3> <p>This is an overloaded function.</p> <p>Converts <i>src</i> from little-endian byte order and returns the number in host byte order representation of that number. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will return <i>src</i> with the byte order swapped; otherwise it will return <i>src</i> unmodified.</p> <p>This function was introduced in Qt 4.3.</p> <a name="//apple_ref/cpp/func//qToBigEndian"></a> <h3 class="fn"><a name="qToBigEndian"></a>void qToBigEndian ( T <i>src</i>, <a href="qtglobal.html#uchar-typedef">uchar</a> * <i>dest</i> )</h3> <p>Writes the number <i>src</i> with template type <tt>T</tt> to the memory location at <i>dest</i> in big-endian byte order.</p> <p>Note that template type <tt>T</tt> can only be an integer data type (signed or unsigned).</p> <p>There are no data alignment constraints for <i>dest</i>.</p> <p>This function was introduced in Qt 4.3.</p> <p>See also <a href="qtendian.html#qFromBigEndian">qFromBigEndian</a>(), <a href="qtendian.html#qFromLittleEndian">qFromLittleEndian</a>(), and <a href="qtendian.html#qToLittleEndian">qToLittleEndian</a>().</p> <h3 class="fn"><a name="qToBigEndian-2"></a>T qToBigEndian ( T <i>src</i> )</h3> <p>This is an overloaded function.</p> <p>Converts <i>src</i> from host byte order and returns the number in big-endian byte order representation of that number. On CPU architectures where the host byte order is little-endian (such as x86) this will return <i>src</i> with the byte order swapped; otherwise it will return <i>src</i> unmodified.</p> <p>This function was introduced in Qt 4.3.</p> <a name="//apple_ref/cpp/func//qToLittleEndian"></a> <h3 class="fn"><a name="qToLittleEndian"></a>void qToLittleEndian ( T <i>src</i>, <a href="qtglobal.html#uchar-typedef">uchar</a> * <i>dest</i> )</h3> <p>Writes the number <i>src</i> with template type <tt>T</tt> to the memory location at <i>dest</i> in little-endian byte order.</p> <p>Note that template type <tt>T</tt> can only be an integer data type (signed or unsigned).</p> <p>There are no data alignment constraints for <i>dest</i>.</p> <p>This function was introduced in Qt 4.3.</p> <p>See also <a href="qtendian.html#qFromBigEndian">qFromBigEndian</a>(), <a href="qtendian.html#qFromLittleEndian">qFromLittleEndian</a>(), and <a href="qtendian.html#qToBigEndian">qToBigEndian</a>().</p> <h3 class="fn"><a name="qToLittleEndian-2"></a>T qToLittleEndian ( T <i>src</i> )</h3> <p>This is an overloaded function.</p> <p>Converts <i>src</i> from host byte order and returns the number in little-endian byte order representation of that number. On CPU architectures where the host byte order is big-endian (such as PowerPC) this will return <i>src</i> with the byte order swapped; otherwise it will return <i>src</i> unmodified.</p> <p>This function was introduced in Qt 4.3.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>