class CDumpContext

The CDumpContext class supports stream-oriented diagnostic output in the form of human-readable text. You can use afxDump, a predeclared CDumpContext object, for most of your dumping. The afxDump object is available only in the Debug version of the Microsoft Foundation Class Library.

Several of the memory diagnostic functions use afxDump for their output.

Preconditions

Before you create your own CDumpContext object, you must create a CFile object that serves as the dump destination.

Comments

The predefined afxDump object, conceptually similar to the cerr stream, is connected to stderr under MS-DOS. Under the Windows environment, the output is routed to the debugger via the Windows function OutputDebugString.

The CDumpContext class has an overloaded insertion (<<) operator for CObject pointers that dumps the object's data in hexadecimal form. If you need a custom dump format for a derived object, override CObject::Dump. Most Microsoft Foundation classes have a Dump member function defined.

Classes that are not derived from CObject, such as CString, CTime, and CTimeSpan, have their own overloaded CDumpContext insertion operators, as do often-used structures such as CFileStatus, CPoint, and CRect.

If you use the IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL macros in the implementation of your class, then CObject::Dump will print the name of your CObject-derived class. Otherwise, it will print CObject.

The CDumpContext class is available with both the Debug and Release versions of the library, but the class Dump functions are defined only in the Debug version. Use #ifdef _DEBUG / #endif statements to bracket your diagnostic code, including your custom Dump member functions.

#define _DEBUG

#include <afx.h>

See Also

CFile, CObject