Qtopia library API Documentation

quuid.cpp

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #include "quuid.h"
00022 
00054 #ifndef QT_NO_QUUID_STRING
00055 
00060 QUuid::QUuid( const QString &text )
00061 {
00062     bool ok;
00063     QString temp = text.upper();
00064 
00065     data1 = temp.mid( 1, 8 ).toULong( &ok, 16 );
00066     if ( !ok ) {
00067     *this = QUuid();
00068     return;
00069     }
00070 
00071     data2 = temp.mid( 10, 4 ).toUInt( &ok, 16 );
00072     if ( !ok ) {
00073     *this = QUuid();
00074     return;
00075     }
00076     data3 = temp.mid( 15, 4 ).toUInt( &ok, 16 );
00077     if ( !ok ) {
00078     *this = QUuid();
00079     return;
00080     }
00081     data4[0] = temp.mid( 20, 2 ).toUInt( &ok, 16 );
00082     if ( !ok ) {
00083     *this = QUuid();
00084     return;
00085     }
00086     data4[1] = temp.mid( 22, 2 ).toUInt( &ok, 16 );
00087     if ( !ok ) {
00088     *this = QUuid();
00089     return;
00090     }
00091     for ( int i = 2; i<8; i++ ) {
00092     data4[i] = temp.mid( 25 + (i-2)*2, 2 ).toUShort( &ok, 16 );
00093     if ( !ok ) {
00094         *this = QUuid();
00095         return;
00096     }
00097     }
00098 }
00099 #endif
00100 
00117 #ifndef QT_NO_QUUID_STRING
00118 
00123 QString QUuid::toString() const
00124 {
00125     QString result;
00126 
00127     result = "{" + QString::number( data1, 16 ).rightJustify( 8, '0' ) + "-";
00128     result += QString::number( (int)data2, 16 ).rightJustify( 4, '0' ) + "-";
00129     result += QString::number( (int)data3, 16 ).rightJustify( 4, '0' ) + "-";
00130     result += QString::number( (int)data4[0], 16 ).rightJustify( 2, '0' );
00131     result += QString::number( (int)data4[1], 16 ).rightJustify( 2, '0' ) + "-";
00132     for ( int i = 2; i < 8; i++ )
00133     result += QString::number( (int)data4[i], 16 ).rightJustify( 2, '0' );
00134 
00135     return result + "}";
00136 }
00137 #endif
00138 
00141 bool QUuid::isNull() const
00142 {
00143     return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 &&
00144        data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 &&
00145        data1 == 0 && data2 == 0 && data3 == 0;
00146 }
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:08 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001