File indexing completed on 2024-06-16 03:57:55
0001 /* 0002 This file is part of the KDE games library 0003 SPDX-FileCopyrightText: 2001 Andreas Beckermann <b_mann@gmx.de> 0004 SPDX-FileCopyrightText: 2001 Martin Heni <kde at heni-online.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef __KGAMEERROR_H_ 0010 #define __KGAMEERROR_H_ 0011 0012 // Qt 0013 #include <QString> 0014 0015 /** 0016 * \class KGameError kgameerror.h <KGame/KGameError> 0017 */ 0018 class KGameError 0019 { 0020 public: 0021 KGameError() 0022 { 0023 } 0024 ~KGameError() 0025 { 0026 } 0027 0028 enum ErrorCodes { 0029 Cookie = 0, // Cookie mismatch 0030 Version = 1 // Version mismatch 0031 }; 0032 0033 /** 0034 * Generate an error message with Erorr Code = ErrCookie 0035 */ 0036 static QByteArray errCookie(int localCookie, int remoteCookie); 0037 static QByteArray errVersion(int remoteVersion); 0038 0039 /** 0040 * Create an erorr text using a QDataStream (QByteArray) which was 0041 * created using @ref KGameError. This is the opposite function to all 0042 * the errXYZ() function (e.g. @ref errVersion). 0043 * You want to use this to generate the message that shall be 0044 * displayed to the user. 0045 * @return an error message 0046 */ 0047 static QString errorText(int errorCode, QDataStream &message); 0048 static QString errorText(int errorCode, const QByteArray &message); 0049 }; 0050 0051 #endif