Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Meinst du damit, dass andere Bibliotheken generell keine Exceptions werfen dürften (wenn man Exceptions, die in anderen Bibliotheken geworfen werden, in seinem eigenen Code behandelt, wird ja die Grenze der Bibliothek bereits überschritten)? Falls ja, dann bin ich anderer Meinung.Zitat von »"knivil"«
Ueber Bibliotheksgrenzen hinweg sollten auch keine Exceptions geworfen werden.
Zitat von »"Nox"«
Genau das meinte ich mit den zwei Lagern am Anfang. Vorallem man kann noch soviele Argumente bringen. Am Ende macht es jeder wie er will und wir haben die typische Diskussion :roll: .
Zitat von »"Nox"«
Hmm ich weiß nicht wielange du im Forum bist
Zitat
Nexus
Anmeldedatum: 18.05.2008
Naja, so pauschal würde ich das nicht sagen. Du kannst ja auch void-Funktionen mit Exceptions behandeln.Zitat von »"Databyte"«
Ich denke ich werde das in Zukunft so machen, dass ich exeptions in eine funktion
einbaue, wenn ich unbedingt einen return-Wert und eine Fehlerabfrage haben will.
Was sind denn Result-Klassen?Zitat von »"Databyte"«
Für den Rest mach ich mir Result-Klassen ( die find ich nämlich schlich gesagt TOLL xD)
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
#pragma once class TNotify; template<class T_ErrorAbleClass_> class TNotifyAble; /* * + TNotify * ------------------------------------------------------------------------------------------------------------- * TNotify besteht aus einem INT, der einen Errorcode enthält. * Diese Klasse enthält einen operatore für BOOL und kann so bei if (etc) benutzt werden * behandelt werden * ------------------------------------------------------------------------------------------------------------- * * * * + TNotifyAble< Erbende Klasse > * ------------------------------------------------------------------------------------------------------------- * Macht eine Klasse Notifyable. * Kann eine Notify Klassenweit(static) speichern. * Enthält Funktionen zum setzen und Abrufen von fehlern. * ------------------------------------------------------------------------------------------------------------- * * * * + TNotifyAble< Erbende Klasse > * + TStdNotifyCatcher * ------------------------------------------------------------------------------------------------------------- * Klasse zum speichern von Fehlern für normale Funktionen. * Hat keine eigenen Variablen oder Funktionen... erbt nur von TNotifyAble * ------------------------------------------------------------------------------------------------------------- * * * */ ///////////////////////////////////////////////// TNotify ///////////////////////////////////////////////// class TNotify { private: int _m_NotifyCode_; public: /* Konstruktor ( Keine Parameter ) */ TNotify() : _m_NotifyCode_( 0 ) {} /* Konstruktor ( NotifyCode ) */ TNotify(int _notifyCode) : _m_NotifyCode_( _notifyCode) {} /* Gebt eine Referenz auf den Notifycode zurück */ inline int GetNotifyCode() const { return (_m_NotifyCode_); } /* Setzt einen Notifycode */ inline int SetNotifyCode(int _notifyCode) { return (_m_NotifyCode_ = _notifyCode); } /* Gibt zurück ob ein Fehler vorliegt true = Fehler false = Kein Fehler */ inline bool IsNotify() const { return ((_m_NotifyCode_ == 0)? (false):(true)); } /* Gibt zurück ob ein Fehler vorliegt true = Kein Fehler false = Fehler */ inline bool IsValid() const { return ((_m_NotifyCode_ == 0)? (true):(false)); } /* überladener cast-operator -> IsValid() */ inline operator bool() const { return (IsValid()); } }; ///////////////////////////////////////////////// TNotifyAble ///////////////////////////////////////////////// template<class T_ErrorAbleClass_> class TNotifyAble { private: static TNotify _m_LastNotify_; public: /* Setzt einen Klasseweiten Notifycode */ static TNotify SetNotify( TNotify _notify) { if( _notify.IsNotify() ) return (_m_LastNotify_ = _notify); return (_notify); } /* Gint das letzte Notify zurück */ static inline TNotify GetLastNotify() { return (_m_LastNotify_); } /* Gibt zurück ob eine Notify vorliegt true = Fehler false = Kein Fehler */ inline bool IsNotify() const { return (_m_LastNotify_.IsNotify()); } }; template<class T_ErrorAbleClass_> TNotify TNotifyAble<T_ErrorAbleClass_> ::_m_LastNotify_ = 0; ///////////////////////////////////////////////// TStdNotifyCatcher ///////////////////////////////////////////////// struct TStdNotifyCatcher : public TNotifyAble<TStdNotifyCatcher> {}; |
Werbeanzeige