La classe debug stream

Description

Une classe assez simple, semblable au flux stl, qui redirige ses sorties vers une fentre console. Il s'agit d'un simple "Wrapper" autour de la fonction win32 ::OutputDebugString.

Source / Exemple :


// Interface de la classe

#ifndef BKDBG_DEBUGSTREAM_H
#  define BKDBG_DEBUGSTREAM_H

/*******************************************************************************

This is a part of the BKLib library.
Copyright (c) Adel_dz
All rights reserved.
Adel_dz@hotmail.fr

Class Ver 1R3

Output debug messages using ::OutputDebugString.
The msg is also written to a console.

SPEC:
	- TyDebugStream flush the output string when:
		. Object is  destructed
		. The buffer is full
		. Calling Flush()

                                                                                                                                                                • /
#ifndef BKDBG_DEFS_H # include "Defs.h" #endif namespace bklib { class BKDBG_decl TyDebugStream { public: TyDebugStream() throw(); ~TyDebugStream() throw(); void Flush() throw(); TyDebugStream& operator << (const void* Ptr) throw(); TyDebugStream& operator << (const char* CString) throw(); TyDebugStream& operator << (const wchar_t* WCString) throw(); TyDebugStream& operator << (bool b) throw(); //Print true/false. TyDebugStream& operator << (char Char) throw(); TyDebugStream& operator << (wchar_t Char) throw(); TyDebugStream& operator << (signed char Integer) throw(); TyDebugStream& operator << (unsigned char Integer) throw(); TyDebugStream& operator << (short Integer) throw(); TyDebugStream& operator << (unsigned short Integer) throw(); TyDebugStream& operator << (int Integer) throw(); TyDebugStream& operator << (unsigned Integer) throw(); TyDebugStream& operator << (long Integer) throw(); TyDebugStream& operator << (unsigned long Integer) throw(); TyDebugStream& operator << (__int64 Integer) throw(); TyDebugStream& operator << (unsigned __int64 Integer) throw(); TyDebugStream& operator << (float Real) throw(); TyDebugStream& operator << (const double& Real) throw(); TyDebugStream& operator << (const long double& Real) throw(); protected: private: enum { buffer_len = 256 }; char dbg_buffer[buffer_len]; void CopyString(const wchar_t* String) throw(); void CopyString(const char* String) throw(); void WriteText(const char* Text) throw(); static BOOL WINAPI ConsoleHandler(unsigned CtrlType); }; //********************************************************************************** }//namespace #endif

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.