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
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 |
#include "Logfile.hpp" //Konstruktor //Aufgabe: // CLogfile::CLogfile() { } //Ende Konstruktor //Destruktor //Aufgabe: Endmeldung ausgeben und Logfile schließen // CLogfile::~CLogfile() { Textout ("<br><br>End of Logfile</font></body></html>"); fclose (mLogfile); } // Ende Destruktor //CreateLogfile //Aufgabe: Logfile erstellen und Kopf schreiben // void CLogfile::CreateLogfile(const char *LogName) { //Logfile leeren, Kopf schreiben mLogfile = fopen (LogName, "w"); Textout ("<html><head><title>Logfile</title></head>"); Textout ("<body><font face='courier new'>"); WriteTopic ("Logfile", 3); //Aktuelle Build-Konfiguration ausgeben #ifdef _DEBUG Textout ("BUILD: DEBUG<br>"); #else Textout ("BUILD: RELEASE<br>"); #endif //Link für E-Mail Adresse schreiben Textout ("<a href='mailto:support@gmx.de?subject=Logfile'>"); Textout ("Send E-Mail to me</a><br><br>"); //Logfile schließen und mit append wieder öffnen fclose (mLogfile); mLogfile = fopen (LogName, "a"); } //Ende CreateLogfile //WriteTopic //Aufgabe: Überschrift erzeugen // void CLogfile::WriteTopic(const char *Topic, int Size) { //Überschrift erzeugen und flushen Textout ("<table cellspacing='0' cellpadding='0' width='100%%' "); Textout ("bgcolor='#DFDFE5'>\n<tr>\n<td>\n<font face='arial' "); fTextout ("size='+%i'>\n", Size); Textout (Topic); Textout ("</font>\n</td>\n</tr>\n</table>\n<br>"); fflush (mLogfile); } //Ende WriteTopic //Textout //Aufgabe: Text ins Logfile schreiben (schwarz) // void CLogfile::Textout(const char *Text) { //Text schreiben und flushen fprintf (mLogfile, Text); fflush (mLogfile); } //Ende Textout schwarz //Textout //Aufgabe: Text ins Logfile schreiben (farbig) // void CLogfile::Textout(int Color, const char *Text) { Textout (Color, false, Text); } //Ende Textout farbig //Textout //Aufgabe: Text ins Logfile schreiben (farbis, Liste) // void CLogfile::Textout(int Color, bool List, const char *Text); { //Listen Tag schreiben if (List == true) Textout ("<li>"); //Farbtag schreiben switch (Color) { case BLACK: Textout ("<font color=black>"); break; case RED: Textout ("<font color=red>"); break; case GREEN: Textout ("<font color=green>"); break; case BLUE: Textout ("<font color=blue>"); break; case PURPLE: Textout ("<font color=purple>"); break; }; //Text schreiben Textout (Text); Textout ("</font>"); if (List == false) Textout ("<br>"); else Textout ("</li>"); } //Ende Textout (farbig, Liste) //fTextout //Aufgabe: formatierten Text ins Logfile schreiben (schwarz) // void CLogfile::fTextout(const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; //char-Buffer va_list pArgList; //Liste der zu übergebenden Argumente //String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); //Erzeugten String schreiben Textout (buffer); } //Ende fTextout (schwarz) //fTextout //Aufgabe: formatierten Text ins Logfile schreiben (farbig) // void CLogfile::fTextout(int Color, const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; //char-Buffer va_list pArgList; //Liste der zu übergebenden Argumente //String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); //Erzeugten String schreiben Textout (Color, buffer); } //Ende fTextout (farbig) //fTextout //Aufgabe: formatierten Text ins Logfile schreiben (farbig, Liste) // void CLogfile::fTextout(int Color, bool List, const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; //char-Buffer va_list pArgList; //Liste der zu übergebenden Argumente //String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); //Erzeugten String schreiben Textout (Color, List, buffer); } //Ende fTextout (farbig, Liste) //FunctionResult //Aufgabe: OK oder ERROR für Funbktionsaufruf geben // void CLogfile::FunctionResult(const char *Name, bool Result) { if (LOK == Result) { Textout ("<table width='100%%' cellSpacing='1' cellPadding='5'"); Textout (" border='0' bgcolor='#C0C0C0'><tr><td bgcolor="); fTextout ("'#FFFFFF' width='35%%'>%s</TD>", Name); Textout ("<td bgcolor='#FFFFFF' width='30%%'><font color ="); Textout ("'green'>OK</FONT></TD><td bgcolor='#FFFFFF' "); Textout ("width='35%%'>-/-</TD></tr></table>"); } else { Textout ("<table width='100%%' cellSpacing='1' cellPadding='5'"); Textout (" border='0' bgcolor='#C0C0C0'><tr><td bgcolor="); fTextout ("'#FFFFFF' width='35%%'>%s</TD>", Name); Textout ("<td bgcolor='#FFFFFF' width='30%%'><font color ="); Textout ("'red'>ERROR</FONT></TD><td bgcolor='#FFFFFF' "); Textout ("width='35%%'>-/-</TD></tr></table>"); } } //Ende FunctionResult |
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 |
#ifndef __CLOGFILE #define __CLOGFILE //Includes #include <windows.h> #include <stdio.h> #include "Singleton.hpp" //Defines #define MAX_BUFFER 1024 //Maximale größe des Buffers #define LFAIL false //Funktion war erfolgreich #define LOK true //Funktion ist fehlgeschlagen #define gpLogfile CLogfile::Get () //Makro zur einfachen Verwendung //Farben für Text enum FONTCOLORS { BLACK, RED, GREEN, BLUE, PURPLE, }; //Klassendeklaration class CLogfile : public TSingleton<CLogfile> { //Memberfunktionen public: CLogfile (); ~CLogfile (); void CreateLogfile (const char *LogName); void WriteTopic (const char *Topic, int Size); void Textout (const char *Text); void Textout (int Color, const char *Text); void Textout (int Color, bool List, const char *Text); void fTextout (const char *Text, ...); void fTextout (int Color, const char *Text, ...); void fTextout (int Color, bool List, const char *Text, ...); void FunctionResult (const char *Name, bool Result); //Membervariablen private: FILE *mLogfile; }; #endif |
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 |
//Anwendung der Logfile-Klasse #include <iostream> #include "Logfile.hpp" using namespace std; int main () { float Kontrolle = 123.456f; //Variable zum testen //neues Logfile erstellen gpLogfile->CreateLogfile ("Logfile.html"); //Überschrift erzeugen gpLogfile->WriteTopic ("Unformatierter Text", 2); //Unformatierten Text ausgeben gpLogfile->Textout ("normaler schwarzer Text<br>"); gpLogfile->Textout (RED, "farbiger Text"); gpLogfile->Textout (BLUE, "farbiger Text in liste (1)"); gpLogfile->Textout (BLUE, "farbiger Text in liste (2)"); gpLogfile->Textout (BLUE, "farbiger Text in liste (3)"); //Überschrift erzeugen gpLogfile->WriteTopic ("Formatierter Text", 2); //Formatierten Text ausgeben gpLogfile->fTextout ("Kontrollvariable %f<br>", Kontrolle); gpLogfile->fTextout (RED, "Kontrollvariable %f", Kontrolle); gpLogfile->fTextout (GREEN, true, "Liste Kontrolle: %f", Kontrolle); gpLogfile->fTextout (GREEN, true, "Liste Kontrolle: %f", Kontrolle*4.0f); gpLogfile->fTextout (GREEN, true, "Liste Kontrolle: %f", Kontrolle*8.0f); //Eine erfolgreiche und eine fehlgeschlagene Funktion gpLogfile->FunctionResult ("Funktion 1", LOK); gpLogfile->FunctionResult ("Funktion 2", LFAIL); gpLogfile->Del (); return 0; } |
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 |
1>------ Neues Erstellen gestartet: Projekt: Logfile, Konfiguration: Debug Win32 ------ 1>Die Zwischen- und Ausgabedateien für das Projekt "Logfile" mit der Konfiguration "Debug|Win32" werden gelöscht. 1>Kompilieren... 1>Logfile.cpp 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(26) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(45) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(87) : error C2761: 'Textout': Die erneute Deklaration der Memberfunktion ist unzulässig 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(88) : error C2447: '{': Funktionsheader fehlt - Parameterliste im alten Stil? 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(129) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(133) : error C2664: 'void CLogfile::Textout(const char *)': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(147) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(151) : error C2664: 'void CLogfile::Textout(int,const char *)': Konvertierung des Parameters 2 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(165) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(169) : error C2664: 'void CLogfile::Textout(int,bool,const char *)': Konvertierung des Parameters 3 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>main.cpp 1>Code wird generiert... 1>Das Buildprotokoll wurde unter "file://c:\Users\Chrisi\Documents\Visual Studio 2008\Projects\Logfile\Debug\BuildLog.htm" gespeichert. 1>Logfile - 8 Fehler, 2 Warnung(en) ========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ========== |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Khodos« (17.08.2012, 23:56)
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 |
1>------ Neues Erstellen gestartet: Projekt: Logfile, Konfiguration: Debug Win32 ------ 1>Die Zwischen- und Ausgabedateien für das Projekt "Logfile" mit der Konfiguration "Debug|Win32" werden gelöscht. 1>Kompilieren... 1>Logfile.cpp 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(26) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(45) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(129) : warning C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(366): Siehe Deklaration von 'vsprintf' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(147) : warning C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(366): Siehe Deklaration von 'vsprintf' 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(165) : warning C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h(366): Siehe Deklaration von 'vsprintf' 1>main.cpp 1>Code wird generiert... 1>Manifest in Ressourcen wird kompiliert... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Verknüpfen... 1>Das Manifest wird eingebettet... 1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Das Buildprotokoll wurde unter "file://c:\Users\Chrisi\Documents\Visual Studio 2008\Projects\Logfile\Debug\BuildLog.htm" gespeichert. 1>Logfile - 0 Fehler, 5 Warnung(en) ========== Alles neu erstellen: 1 erfolgreich, Fehler bei 0, 0 übersprungen ========== |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
1>------ Neues Erstellen gestartet: Projekt: Logfile, Konfiguration: Debug Win32 ------ 1>Die Zwischen- und Ausgabedateien für das Projekt "Logfile" mit der Konfiguration "Debug|Win32" werden gelöscht. 1>Kompilieren... 1>Logfile.cpp 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(26) : error C2660: 'fopen_s': Funktion akzeptiert keine 2 Argumente 1>c:\users\chrisi\documents\visual studio 2008\projects\logfile\logfile.cpp(45) : error C2660: 'fopen_s': Funktion akzeptiert keine 2 Argumente 1>main.cpp 1>Code wird generiert... 1>Das Buildprotokoll wurde unter "file://c:\Users\Chrisi\Documents\Visual Studio 2008\Projects\Logfile\Debug\BuildLog.htm" gespeichert. 1>Logfile - 2 Fehler, 0 Warnung(en) ========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ========== |
Quellcode |
|
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 |
#ifndef TSINGLETON #define TSINGLETON template <class T> class TSingleton { protected: // Membervariablen static T *m_pSingleton; // Statisches Objekt public: // Memberfunktionen // Destruktor // virtual ~TSingleton() { } // Get // // Aufgabe: Wenn nötig, statisches Obejkt erzeugen und // Zeiger darauf zurückgeben // inline static T* Get() { // Existiert schon eine Instanze? if (!m_pSingleton) m_pSingleton = new T; // Nein,dann neue Instanz erzeugen // Zeiger auf die Instanz zurückgeben return (m_pSingleton); } // Get // Statisches Objekt freigeben // static void Del() { // Gab es eine Instanz? if (m_pSingleton) { delete (m_pSingleton); // Ja, dann freigeben m_pSingleton = NULL; // und Zeiger auf NULL setzen } } // Del }; // Die statische Variable erzeugen // template <class T> T* TSingleton<T>::m_pSingleton = 0; #endif |
Quellcode |
|
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 |
#ifndef __CLOGFILE #define __CLOGFILE // Includes // #include<windows.h> #include<stdio.h> #include "Singleton.hpp" // Define #define MAX_BUFFER 1024 // Maximale Größe für den Buffer #define L_FAIL false // Funktion war erfolgreich #define L_OK true // Funktion ist fehlgeschlagen #define g_pLofile CLofile::Get() // Makro zur einfachen Verwndung // Farben für den Text enum FONTCOLORS { BLACK, RED, GREEN, BLUE, PURPLE }; // Klassendeklaration // class CLogfile : public TSingleton<CLogfile> { // Memberfunktionen public: CLogfile(); ~CLogfile(); void CreateLogfile(const char *LogName); void WriteTopic(const char *Topic, int Size); void Textout(const char *Text); void Textout(int Color, const char *Text); void Textout(int Color, bool List, const char *Text); void fTextout(const char *text, ...); void fTextout(int Color, const char *Text, ...); void fTextout(int Color, bool List, const char *Text, ...); void FunctionResult(const char *Name, bool Result); // Membervariablen private: FILE *m_Logfile; }; #endif |
Quellcode |
|
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 197 198 199 200 201 202 203 204 205 206 207 208 209 |
#include "Logfile.hpp" // Konstruktor // // Aufgabe: Bisher noch keine // CLogfile::CLogfile() { } // Konstruktor // Destruktor // // Aufgabe: Gibt Ende-Meldung aus und schließt das Logfile // CLogfile::~CLogfile() { // Logfile - Ende schreiben und Datei schließen Textout("<br><br>End of logfile</font></body></html>"); fclose(m_Logfile); } // Destruktor // CreateLogfile // // Aufgabe: Logfile erstellen und Kopf schreiben // void CLogfile::CreateLogfile(const char *LogName) { // Logfile leeren und Kopf schreiben fopen_s(&m_Logfile, LogName, "W"); Textout("<html><head><title>Logfile</title></head>"); Textout("<body><font face=´courier new´>"); WriteTopic("Logfile", 3); // Aktuelle Build-Konfiguration ausgeben #ifdef _DEBUG Textout("BUILD: DEBUG<br>"); #else Textout("BUILD: RELEASE<br>"); #endif // Link für E-Mail-Adresse schrieben Textout("<ahref=´mailto:support@meineURL.de?subject=Logfil´>"); Textout("Send E-Mail to me</a><br><br>"); // Logfile schließen und mit append wieder öffnen fclose(m_Logfile); fopen_s(&m_Logfile, LogName, "a"); } // CreateLogfile // WriteTopic // // Aufgabe: Überschriff erzeugen // void CLogfile::WriteTopic(const char *Topic, int Size) { // Überschrift schreiben un flushen Textout("<table cellspacing=´0´ cellpadding=´0´ width=´100%%´"); Textout("bgcolor=´#DFDFE5´>\n<tr>\n<font face=´arial´ "); fTextout("size=´+%i´>\n", Size); Textout(Topic); Textout("</font>\n</td>\n</tr>\n</table>\n<br>"); fflush(m_Logfile); } // WriteTopic // Textout // // Aufgabe:Text in Logfile schreiben (schwarz) // void CLogfile::Textout(const char *Text) { // Text schreiben unf flushen fprintf(m_Logfile, Text); fflush(m_Logfile); } // Textout (schwarz) // Textout // // Aufgabe: Text ins Logfile schreiben (farbig) // void CLogfile::Textout(int Color, const char *Text) { Textout(Color, false, Text); } // Textout (farbig) // Textout // // Aufgabe; Text ins Logfile schreiben (farbig,Liste) // void CLogfile::Textout(int Color, bool List, const char *Text) { // Listen-Tag schreiben if (List == true) Textout("<li>"); // Farbtag schreiben switch (Color) { case BLACK: Textout("<font color=black>"); break; case RED: Textout("<font color=red>"); break; case GREEN: Textout("<font color=green>"); break; case BLUE: Textout("<font color=blue>"); break; case PURPLE: Textout("<font color=purple>"); break; }; // Texkt schreiben Textout(Text); Textout("</font>"); if (List == false) Textout("<br>"); else Textout("</li>"); } // Textout (farbig, liste) // fTextout // // Aufgabe: formatierten Text ins Logfile schreiben (schwarz) // void CLogfile::fTextout(const char *Text, ...) { char buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus Argumenten erstellen va_start(pArgList, Text); vsprintf_s(buffer, Text, pArgList); va_end(pArgList); // Erzeugten String schreiben Textout(buffer); } // fTextout (schwarz) // fTextout // // Aufgabe: Formatierten Text ins Logfile schreiben (farbig) // void CLogfile::fTextout(int Color, const char *Text, ...) { char buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus Argumente erstellen va_start(pArgList, Text); vsprintf_s(buffer, Text, pArgList); va_end(pArgList); // Erzeugten String schreiben Textout(Color, buffer); } // fTextout (farbig) // fTextout // // Aufgabe; formatierten Text ins Lofile schreiben (farbig, Liste) // void CLogfile::fTextout(int Color, bool List, const char *Text, ...) { char buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus den Argumeneten erstellen va_start(pArgList, Text); vsprintf_s(buffer, Text, pArgList); va_end(pArgList); // Erzeugten String schreiben Textout(Color, List, buffer); } // fTextout (farbig, Liste) // FunctionResult // // Aufgabe: OK oder ERROR für Funktionsaufruf ausgeben // void CLogfile::FunctionResult(const char *Name, bool Result) { if (L_OK == Result) { Textout("<table width=´100%%´ cellSpacing=´1´cellPadding=´5´"); Textout("border=´0´ bgcolor=´#C0C0C0´><tr><td bgcolor="); fTextout("´#FFFFFF´ width=´35%%´>%s</TD>", Name); Textout("<td bgcolor_´#FFFFFF´ width=´30%%´><font color ="); Textout("´green´>OK</FONT></TD><td bgcolor=´#FFFFFF´ "); Textout("width=´35%%´>-/-</TD></tr></table>"); } else { Textout("<table width=´100%%´ cellSpacing=´1´cellPadding=´5´"); Textout("border=´0´ bgcolor=´#COCOCO´><tr><td bgcolor="); fTextout("´#FFFFFF´ width=´35%%´>%s</TD>", Name); Textout("<td bgcolor=´#FFFFFF´ width=´30%%´><font color ="); Textout("´red´>ERROR</FONT></TD><td bgcolor=´#FFFFFF´ "); Textout("width=´30%%´>-/-</TD></tr></table>"); } } // FunctionResult |
Quellcode |
|
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 |
// C++ für Spielerprogrammierer // Listing 8.12 // Anwendung der Logfile-Klasse // #include <iostream> #include"Logfile.hpp" using namespace std; // Hauptprogramm // int main() { // Variablen // float Kontrolle = 123.456f; // Variable zum Testen // Neues Logfile erstellen g_pLogfile->CreateLogfile("Logfile.html"); // Überschrift erzeugen g_pLogfile->WriteTopic("Unformatierter Text", 2); // Unformatierten Text ausgeben g_pLogfile->Textout("Normaler, schwarzer Text<br>"); g_pLogfile->Textout(RED, "Farbiger Text"); g_pLogfile->Textout(BLUE, "Farbiger Text in Liste (1)"); g_pLogfile->Textout(BLUE, "Farbiger Text in Liste (2)"); g_pLogfile->Textout(BLUE, "Farbiger Text in Liste (3)"); // Überschrift erzeugen g_pLogfile->WriteTopic("Formatierter Text", 2); // Formatierten Text ausgeben g_pLogfile->fTextout("Kontrollvariable: %f<br>", Kontrolle); g_pLogfile->fTextout(RED, "Kontrollvariable: %f", Kontrolle); g_pLogfile->fTextout(GREEN, true, "Liste Kontrolle: %f", Kontrolle); g_pLogfile->fTextout(GREEN, true, "Liste Kontrolle: %f", Kontrolle*2.0f); g_pLogfile->fTextout(GREEN, true, "Liste Kontrolle: %f", Kontrolle*4.0f); // Eine erfolgreiche und eine fehlgeschlagene Funktion g_pLogfile->FunctionResult("Funktion_Eins", L_OK); g_pLogfile->FunctionResult("Funktion_Zwei", L_FAIL); // Logfile schließen g_pLogfile->Del(); return 0; } |
Quellcode |
|
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 |
1>------ Erstellen gestartet: Projekt: Listing 8.12 - 8.14, Konfiguration: Release Win32 ------ 1> Listing 8.15.cpp 1>Listing 8.15.cpp(19): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(19): error C2227: Links von "->CreateLogfile" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(19): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(22): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(22): error C2227: Links von "->WriteTopic" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(22): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(25): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(25): error C2227: Links von "->Textout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(25): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(26): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(26): error C2227: Links von "->Textout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(26): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(27): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(27): error C2227: Links von "->Textout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(27): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(28): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(28): error C2227: Links von "->Textout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(28): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(29): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(29): error C2227: Links von "->Textout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(29): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(32): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(32): error C2227: Links von "->WriteTopic" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(32): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(35): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(35): error C2227: Links von "->fTextout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(35): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(36): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(36): error C2227: Links von "->fTextout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(36): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(37): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(37): error C2227: Links von "->fTextout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(37): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(38): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(38): error C2227: Links von "->fTextout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(38): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(39): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(39): error C2227: Links von "->fTextout" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(39): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(42): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(42): error C2227: Links von "->FunctionResult" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(42): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(43): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(43): error C2227: Links von "->FunctionResult" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(43): note: Typ ist "unknown-type" 1>Listing 8.15.cpp(46): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner 1>Listing 8.15.cpp(46): error C2227: Links von "->Del" muss sich ein Zeiger auf Klassen-/Struktur-/Union-/generischen Typ befinden. 1> Listing 8.15.cpp(46): note: Typ ist "unknown-type" ========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ========== |
dieser Fehler sagt dir das g_pLogfile nicht deklariert wurde, also nirgens steht etwas in der artZitat
1>Listing 8.15.cpp(19): error C2065: "g_pLogfile": nichtdeklarierter Bezeichner
C-/C++-Quelltext |
|
1 |
CLogfile g_pLogfile; |
C-/C++-Quelltext |
|
1 |
#define g_pLofile CLofile::Get() // Makro zur einfachen Verwndung |
Werbeanzeige