home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 17.ddi / MFC / INCLUDE / AFX.H_ / AFX.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  36.9 KB  |  1,243 lines

  1. // Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992 Microsoft Corporation,
  3. // All rights reserved.
  4.  
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp and/or WinHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFX_H__
  12. #define __AFX_H__
  13.  
  14. #ifndef __cplusplus
  15. #error Microsoft Foundation Classes require C++ compilation (use a .cpp suffix)
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19.  
  20. #include "afxver_.h"        // Target version control
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // Classes declared in this file
  24. //   in addition to standard primitive data types and various helper macros
  25.  
  26. struct CRuntimeClass;          // object type information
  27.  
  28. class CObject;                        // the root of all objects classes
  29.  
  30.     class CException;                 // the root of all exceptions
  31.         class CMemoryException;       // out-of-memory exception
  32.         class CNotSupportedException; // feature not supported exception
  33.         class CArchiveException;// archive exception
  34.         class CFileException;         // file exception
  35.  
  36.     class CFile;                      // raw binary file
  37.         class CStdioFile;             // buffered stdio text/binary file
  38.         class CMemFile;               // memory based file
  39.  
  40. // Non CObject classes
  41. class CString;                        // growable string type
  42. class CTimeSpan;                      // time/date difference
  43. class CTime;                          // absolute time/date
  44. struct CFileStatus;                   // file status information
  45. struct CMemoryState;                  // diagnostic memory support
  46.  
  47. class CArchive;                       // object persistence tool
  48. class CDumpContext;                   // object diagnostic dumping
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Other includes from standard "C" runtimes
  52.  
  53. #ifndef NOSTRICT
  54. #define STRICT      // default is to use STRICT interfaces
  55. #endif
  56.  
  57. #include <string.h>
  58. #include <stdio.h>
  59. #include <stdlib.h>
  60. #include <time.h>
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // Basic types (from Windows)
  64.  
  65. typedef unsigned char  BYTE;   // 8-bit unsigned entity
  66. typedef unsigned short WORD;   // 16-bit unsigned number
  67. typedef unsigned int   UINT;   // machine sized unsigned number (preferred)
  68. typedef long           LONG;   // 32-bit signed number
  69. typedef unsigned long  DWORD;  // 32-bit unsigned number
  70. typedef int            BOOL;   // BOOLean (0 or !=0)
  71. typedef char FAR*      LPSTR;  // far pointer to a string
  72. typedef const char FAR* LPCSTR; // far pointer to a read-only string
  73.  
  74. typedef void*      POSITION;   // abstract iteration position
  75.  
  76. // Standard constants
  77. #undef FALSE
  78. #undef TRUE
  79. #undef NULL
  80.  
  81. #define FALSE   0
  82. #define TRUE    1
  83. #define NULL    0
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // Diagnostic support
  87. #ifdef _DEBUG
  88. extern "C"
  89. {
  90. void CDECL AfxTrace(LPCSTR pszFormat, ...);
  91. void AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine);
  92. void AFXAPI AfxAssertValidObject(const CObject* pOb,
  93.                 LPCSTR lpszFileName, int nLine);
  94. void AFXAPI AfxDump(const CObject* pOb); // Dump an object from CodeView
  95. }
  96. #define TRACE              ::AfxTrace
  97. #define THIS_FILE          __FILE__
  98. #define ASSERT(f)          ((f) ? (void)0 : \
  99.                                 ::AfxAssertFailedLine(THIS_FILE, __LINE__))
  100. #define VERIFY(f)          ASSERT(f)
  101. #define ASSERT_VALID(pOb)  (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
  102.  
  103. // The following trace macros put the trace string in a code segment
  104. // so that it will not impact DGROUP
  105. #define TRACE0(sz) \
  106.                 do { \
  107.                     static char BASED_DEBUG _sz[] = sz; \
  108.                     ::AfxTrace(_sz); \
  109.                 } while (0)
  110. #define TRACE1(sz, p1) \
  111.                 do { \
  112.                     static char BASED_DEBUG _sz[] = sz; \
  113.                     ::AfxTrace(_sz, p1); \
  114.                 } while (0)
  115. #define TRACE2(sz, p1, p2) \
  116.                 do { \
  117.                     static char BASED_DEBUG _sz[] = sz; \
  118.                     ::AfxTrace(_sz, p1, p2); \
  119.                 } while (0)
  120. #define TRACE3(sz, p1, p2, p3) \
  121.                 do { \
  122.                     static char BASED_DEBUG _sz[] = sz; \
  123.                     ::AfxTrace(_sz, p1, p2, p3); \
  124.                 } while (0)
  125. // Use this in Dump to put the string literals in a code segment and
  126. // out of DGROUP.
  127. #define AFX_DUMP0(dc, sz) \
  128.                 do { \
  129.                     static char BASED_DEBUG _sz[] = sz; \
  130.                     dc << _sz; \
  131.                 } while (0)
  132. #define AFX_DUMP1(dc, sz, p1) \
  133.                 do { \
  134.                     static char BASED_DEBUG _sz[] = sz; \
  135.                     dc << _sz << p1; \
  136.                 } while (0)
  137. #else
  138. #define ASSERT(f)          ((void)0)
  139. #define VERIFY(f)          ((void)(f))
  140. #define ASSERT_VALID(pOb)  ((void)0)
  141. inline void CDECL AfxTrace(LPCSTR /* pszFormat */, ...) { }
  142. #define TRACE              1 ? (void)0 : ::AfxTrace
  143. #define TRACE0             1 ? (void)0 : ::AfxTrace
  144. #define TRACE1             1 ? (void)0 : ::AfxTrace
  145. #define TRACE2             1 ? (void)0 : ::AfxTrace
  146. #define TRACE3             1 ? (void)0 : ::AfxTrace
  147. #endif // _DEBUG
  148.  
  149. /////////////////////////////////////////////////////////////////////////////
  150. // Turn off warnings for /W4
  151. // To resume any of these warning: #pragma warning(default: 4xxx)
  152. // which should be placed after the AFX include files
  153. #ifndef ALL_WARNINGS
  154. #pragma warning(disable: 4001)  // nameless unions are part of C++
  155. #pragma warning(disable: 4061)  // allow enums in switch with default
  156. #pragma warning(disable: 4127)  // constant expression for TRACE/ASSERT
  157. #pragma warning(disable: 4134)  // message map member fxn casts
  158. #pragma warning(disable: 4505)  // optimize away locals
  159. #pragma warning(disable: 4510)  // default constructors are bad to have
  160. #pragma warning(disable: 4511)  // private copy constructors are good to have
  161. #pragma warning(disable: 4512)  // private operator= are good to have
  162. #ifdef STRICT
  163. #pragma warning(disable: 4305)  // STRICT handles are near*, integer truncation
  164. #endif
  165. #if (_MSC_VER >= 800)
  166. // turn off code generator warnings for information lost in normal optimizations
  167. #pragma warning(disable: 4705)  // TRACE turned into statement with no effect
  168. #pragma warning(disable: 4710)  // private constructors are disallowed
  169. #pragma warning(disable: 4791)  // loss of debugging info in retail version
  170. #endif
  171. #endif //ALL_WARNINGS
  172.  
  173. /////////////////////////////////////////////////////////////////////////////
  174. // Other implementation helpers
  175.  
  176. #define BEFORE_START_POSITION ((void*)(void NEAR*)-1)
  177. #define _AFX_FP_OFF(thing) (*((UINT*)&(thing)))
  178. #define _AFX_FP_SEG(lp) (*((UINT*)&(lp)+1))
  179.  
  180. /////////////////////////////////////////////////////////////////////////////
  181. // Explicit extern for version API/Windows 3.0 loader problem
  182. #ifdef _WINDOWS
  183. extern "C" int AFXAPI _export _afx_version();
  184. #else
  185. extern "C" int AFXAPI _afx_version();
  186. #endif
  187.  
  188. /////////////////////////////////////////////////////////////////////////////
  189. // Basic object model
  190.  
  191. struct CRuntimeClass
  192. {
  193. // Attributes
  194.     LPCSTR m_lpszClassName;
  195.     int m_nObjectSize;
  196.     UINT m_wSchema; // schema number of the loaded class
  197.     void (PASCAL* m_pfnConstruct)(void* p); // NULL => abstract class
  198.     CRuntimeClass* m_pBaseClass;
  199.  
  200. // Operations
  201.     CObject* CreateObject();
  202.  
  203. // Implementation
  204.     BOOL ConstructObject(void* pThis);
  205.     void Store(CArchive& ar);
  206.     static CRuntimeClass* PASCAL Load(CArchive& ar, UINT* pwSchemaNum);
  207.  
  208.     // CRuntimeClass objects linked together in simple list
  209.     static CRuntimeClass* AFXAPI_DATA pFirstClass; // start of class list
  210.     CRuntimeClass* m_pNextClass;       // linked list of registered classes
  211. };
  212.  
  213.  
  214. /////////////////////////////////////////////////////////////////////////////
  215. // class CObject is the root of all compliant objects
  216.  
  217. #if defined(_M_I86MM) && !defined(_PORTABLE)
  218. // force vtables to be in far code segments for medium model
  219. class FAR CObjectRoot
  220. {
  221. protected:
  222.     virtual CRuntimeClass* GetRuntimeClass() NEAR const = 0;
  223. };
  224.  
  225. #pragma warning(disable: 4149)  // don't warn for medium model change
  226. class NEAR CObject : public CObjectRoot
  227. #else
  228. class CObject
  229. #endif
  230. {
  231. public:
  232.  
  233. // Object model (types, destruction, allocation)
  234.     virtual CRuntimeClass* GetRuntimeClass() const;
  235.     virtual ~CObject();  // virtual destructors are necessary
  236.  
  237.     // Diagnostic allocations
  238.     void* operator new(size_t, void* p);
  239.     void* operator new(size_t nSize);
  240.     void operator delete(void* p);
  241.  
  242. #ifdef _DEBUG
  243.     // for file name/line number tracking using DEBUG_NEW
  244.     void* operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
  245. #endif
  246.  
  247.     // Disable the copy constructor and assignment by default so you will get
  248.     //   compiler errors instead of unexpected behaviour if you pass objects
  249.     //   by value or assign objects.
  250. protected:
  251.     CObject();
  252. private:
  253.     CObject(const CObject& objectSrc);              // no implementation
  254.     void operator=(const CObject& objectSrc);       // no implementation
  255.  
  256. // Attributes
  257. public:
  258.     BOOL IsSerializable() const;
  259.     BOOL IsKindOf(const CRuntimeClass* pClass) const;
  260.  
  261. // Overridables
  262.     virtual void Serialize(CArchive& ar);
  263.  
  264.     // Diagnostic Support
  265.     virtual void AssertValid() const;
  266.     virtual void Dump(CDumpContext& dc) const;
  267.  
  268. // Implementation
  269. public:
  270.     static CRuntimeClass AFXAPI_DATA classCObject;
  271. };
  272.  
  273. #if defined(_M_I86MM)
  274. #pragma warning(default: 4149)  // base class now ambient
  275. #endif
  276.  
  277.  
  278. // Helper macros
  279. #define RUNTIME_CLASS(class_name) \
  280.     (&class_name::class##class_name)
  281.  
  282. //////////////////////////////////////////////////////////////////////////////
  283. // Helper macros for declaring compliant classes
  284.  
  285. // AFXAPP_DATA will be NEAR for app classes but AFXAPI_DATA for library classes
  286. #define AFXAPP_DATA     AFXAPI_DATA
  287.  
  288. #define DECLARE_DYNAMIC(class_name) \
  289. public: \
  290.     static CRuntimeClass AFXAPP_DATA class##class_name; \
  291.     virtual CRuntimeClass* GetRuntimeClass() const;
  292.  
  293. // not serializable, but dynamically constructable
  294. #define DECLARE_DYNCREATE(class_name) \
  295.     DECLARE_DYNAMIC(class_name) \
  296.     static void PASCAL Construct(void* p);
  297.  
  298. #define DECLARE_SERIAL(class_name) \
  299.     DECLARE_DYNCREATE(class_name) \
  300.     friend CArchive& AFXAPI operator>>(CArchive& ar, class_name* &pOb);
  301.  
  302. // generate static object constructor for class registration
  303. #ifdef AFX_CLASS_MODEL
  304. struct NEAR AFX_CLASSINIT
  305. #else
  306. struct AFX_CLASSINIT
  307. #endif
  308.     { AFX_CLASSINIT(CRuntimeClass* pNewClass); };
  309.  
  310. #define _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, pfnNew) \
  311.     static char BASED_CODE _lpsz##class_name[] = #class_name; \
  312.     CRuntimeClass AFXAPP_DATA class_name::class##class_name = { \
  313.         _lpsz##class_name, sizeof(class_name), wSchema, pfnNew, \
  314.             RUNTIME_CLASS(base_class_name), NULL }; \
  315.     static AFX_CLASSINIT _init_##class_name(&class_name::class##class_name); \
  316.     CRuntimeClass* class_name::GetRuntimeClass() const \
  317.         { return &class_name::class##class_name; } \
  318. // end of _IMPLEMENT_RUNTIMECLASS
  319.  
  320. #define IMPLEMENT_DYNAMIC(class_name, base_class_name) \
  321.     _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, NULL)
  322.  
  323. #define IMPLEMENT_DYNCREATE(class_name, base_class_name) \
  324.     void PASCAL class_name::Construct(void* p) \
  325.         { new(p) class_name; } \
  326.     _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, 0xFFFF, \
  327.         class_name::Construct)
  328.  
  329. #define IMPLEMENT_SERIAL(class_name, base_class_name, wSchema) \
  330.     void PASCAL class_name::Construct(void* p) \
  331.         { new(p) class_name; } \
  332.     _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, \
  333.         class_name::Construct) \
  334.     CArchive& AFXAPI operator>>(CArchive& ar, class_name* &pOb) \
  335.         { pOb = (class_name*) ar.ReadObject(RUNTIME_CLASS(class_name)); \
  336.             return ar; } \
  337. // end of IMPLEMENT_SERIAL
  338.  
  339. /////////////////////////////////////////////////////////////////////////////
  340. // other helpers
  341.  
  342. // zero fill everything after the VTable pointer
  343. #define AFX_ZERO_INIT_OBJECT(base_class) \
  344.     memset(((base_class*)this)+1, 0, sizeof(*this) - sizeof(base_class));
  345.  
  346. // Windows compatible setjmp for C++
  347. #ifndef _AFX_JBLEN
  348. // use default Window C++ calling convention
  349. #define _AFX_JBLEN  9
  350. extern "C" int FAR PASCAL Catch(int FAR*);
  351. #endif
  352.  
  353. /////////////////////////////////////////////////////////////////////////////
  354. // Exceptions
  355.  
  356. class CException : public CObject
  357. {
  358.     // abstract class for dynamic type checking
  359.     DECLARE_DYNAMIC(CException)
  360. };
  361.  
  362. // Placed on frame for EXCEPTION linkage
  363. struct AFX_STACK_DATA AFX_EXCEPTION_LINK
  364. {
  365.     AFX_EXCEPTION_LINK* m_pLinkPrev;// previous top, next in handler chain
  366.  
  367.     UINT m_nType;       // 0 for setjmp, !=0 for user extension
  368.     union
  369.     {
  370.         int m_jumpBuf[_AFX_JBLEN]; // arg for Catch/Throw (nType = 0)
  371.         struct
  372.         {
  373.             void (PASCAL* pfnCleanup)(AFX_EXCEPTION_LINK* pLink);
  374.             void* pvData;       // extra data follows
  375.         } m_callback;       // callback for cleanup (nType != 0)
  376.     };
  377.  
  378.     AFX_EXCEPTION_LINK();       // for initialization and linking
  379.     ~AFX_EXCEPTION_LINK();      // for cleanup and unlinking
  380. };
  381.  
  382. // Exception global state - never access directly
  383. struct AFX_EXCEPTION_CONTEXT
  384. {
  385.     CException* m_pCurrent;
  386.     BOOL m_bDeleteWhenDone;
  387.     AFX_EXCEPTION_LINK* m_pLinkTop;
  388.  
  389.     void Throw(CException* pNewException);
  390.     void Throw(CException* pNewException, BOOL bShared);
  391.     void ThrowLast();
  392.  
  393.     void Cleanup(); // call to free up exception
  394. };
  395.  
  396. #ifndef _AFXDLL
  397. extern AFX_EXCEPTION_CONTEXT NEAR afxExceptionContext;
  398. #endif
  399.  
  400. void AFXAPI AfxAbort();
  401.  
  402. // Obsolete and non-portable: setting terminate handler
  403. //  use CWinApp::ProcessWndProcException for Windows apps instead
  404. void AFXAPI AfxTerminate();
  405. #ifndef _AFXDLL
  406. typedef void (AFXAPI* AFX_TERM_PROC)();
  407. AFX_TERM_PROC AFXAPI AfxSetTerminate(AFX_TERM_PROC);
  408. #endif //!_AFXDLL
  409.  
  410. /////////////////////////////////////////////////////////////////////////////
  411. // Exception helper macros
  412.  
  413. // out-of-line routines for smaller code
  414. BOOL AFXAPI AfxCatchProc(CRuntimeClass* pClass);
  415. void AFXAPI AfxEndCatchProc();
  416.  
  417. #define TRY \
  418.     { \
  419.     AFX_EXCEPTION_LINK _afxExLink; \
  420.     if (::Catch(_afxExLink.m_jumpBuf) == 0)
  421.  
  422. #define CATCH(class, e) \
  423.     else { if (AfxCatchProc(RUNTIME_CLASS(class))) \
  424.     { class* e = (class*) afxExceptionContext.m_pCurrent;
  425.  
  426. #define AND_CATCH(class, e) \
  427.     } else if (AfxCatchProc(RUNTIME_CLASS(class))) \
  428.     { class* e = (class*) afxExceptionContext.m_pCurrent;
  429.  
  430. #define END_CATCH \
  431.     } else { AfxEndCatchProc(); } } }
  432.  
  433. #define THROW(e) \
  434.     afxExceptionContext.Throw(e);
  435. #define THROW_LAST() \
  436.     afxExceptionContext.ThrowLast();
  437.  
  438. // Advanced macros for smaller code : {
  439. #define CATCH_ALL(e) else { { CException* e = afxExceptionContext.m_pCurrent;
  440. #define AND_CATCH_ALL(e) }else { CException* e = afxExceptionContext.m_pCurrent;
  441. #define END_CATCH_ALL } } }
  442.  
  443. /////////////////////////////////////////////////////////////////////////////
  444. // Standard Exception classes
  445.  
  446. class CMemoryException : public CException
  447. {
  448.     DECLARE_DYNAMIC(CMemoryException)
  449. public:
  450.     CMemoryException();
  451. };
  452.  
  453. class CNotSupportedException : public CException
  454. {
  455.     DECLARE_DYNAMIC(CNotSupportedException)
  456. public:
  457.     CNotSupportedException();
  458. };
  459.  
  460. class CArchiveException : public CException
  461. {
  462.     DECLARE_DYNAMIC(CArchiveException)
  463. public:
  464.     enum {
  465.         none,
  466.         generic,
  467.         readOnly,
  468.         endOfFile,
  469.         writeOnly,
  470.         badIndex,
  471.         badClass,
  472.         badSchema
  473.     };
  474.  
  475. // Constructor
  476.     CArchiveException(int cause = CArchiveException::none);
  477.  
  478. // Attributes
  479.     int m_cause;
  480.  
  481. #ifdef _DEBUG
  482.     virtual void Dump(CDumpContext& dc) const;
  483. #endif
  484. };
  485.  
  486. class CFileException : public CException
  487. {
  488.     DECLARE_DYNAMIC(CFileException)
  489.  
  490. public:
  491.     enum {
  492.         none,
  493.         generic,
  494.         fileNotFound,
  495.         badPath,
  496.         tooManyOpenFiles,
  497.         accessDenied,
  498.         invalidFile,
  499.         removeCurrentDir,
  500.         directoryFull,
  501.         badSeek,
  502.         hardIO,
  503.         sharingViolation,
  504.         lockViolation,
  505.         diskFull,
  506.         endOfFile
  507.     };
  508.  
  509. // Constructors
  510.  
  511.     CFileException(int cause = CFileException::none, LONG lOsError = -1);
  512.  
  513. // Attributes
  514.     int m_cause;
  515.     LONG m_lOsError;
  516.  
  517. // Operations
  518.  
  519.     // convert a OS dependent error code to a Cause
  520.     static int PASCAL OsErrorToException(LONG lOsError);
  521.     static int PASCAL ErrnoToException(int nErrno);
  522.  
  523.     // helper functions to throw exception after converting to a Cause
  524.     static void PASCAL ThrowOsError(LONG lOsError);
  525.     static void PASCAL ThrowErrno(int nErrno);
  526.  
  527. #ifdef _DEBUG
  528.     virtual void Dump(CDumpContext&) const;
  529. #endif
  530. };
  531.  
  532. /////////////////////////////////////////////////////////////////////////////
  533. // Standard exception throws
  534.  
  535. void AFXAPI AfxThrowMemoryException();
  536. void AFXAPI AfxThrowNotSupportedException();
  537. void AFXAPI AfxThrowArchiveException(int cause);
  538. void AFXAPI AfxThrowFileException(int cause, LONG lOsError = -1);
  539.  
  540.  
  541. /////////////////////////////////////////////////////////////////////////////
  542. // File - raw unbuffered disk file I/O
  543.  
  544. class CFile : public CObject
  545. {
  546.     DECLARE_DYNAMIC(CFile)
  547.  
  548. public:
  549. // Flag values
  550.     enum OpenFlags {
  551.         modeRead =          0x0000,
  552.         modeWrite =         0x0001,
  553.         modeReadWrite =     0x0002,
  554.         shareCompat =       0x0000,
  555.         shareExclusive =    0x0010,
  556.         shareDenyWrite =    0x0020,
  557.         shareDenyRead =     0x0030,
  558.         shareDenyNone =     0x0040,
  559.         modeNoInherit =     0x0080,
  560.         modeCreate =        0x1000,
  561.         typeText =          0x4000, // typeText and typeBinary are used in
  562.         typeBinary =   (int)0x8000 // derived classes only
  563.         };
  564.  
  565.     enum Attribute {
  566.         normal =    0x00,
  567.         readOnly =  0x01,
  568.         hidden =    0x02,
  569.         system =    0x04,
  570.         volume =    0x08,
  571.         directory = 0x10,
  572.         archive =   0x20
  573.         };
  574.  
  575.     enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
  576.  
  577.     enum {hFileNull = -1};
  578.  
  579. // Constructors
  580.     CFile();
  581.     CFile(int hFile);
  582.     CFile(const char* pszFileName, UINT nOpenFlags);
  583.  
  584. // Attributes
  585.     UINT m_hFile;
  586.  
  587.     virtual DWORD GetPosition() const;
  588.     BOOL GetStatus(CFileStatus& rStatus) const;
  589.  
  590. // Operations
  591.     virtual BOOL Open(const char* pszFileName, UINT nOpenFlags,
  592.         CFileException* pError = NULL);
  593.  
  594.     static void PASCAL Rename(const char* pszOldName,
  595.                 const char* pszNewName);
  596.     static void PASCAL Remove(const char* pszFileName);
  597.     static BOOL PASCAL GetStatus(const char* pszFileName,
  598.                 CFileStatus& rStatus);
  599.     static void PASCAL SetStatus(const char* pszFileName,
  600.                 const CFileStatus& status);
  601.  
  602.     DWORD SeekToEnd();
  603.     void SeekToBegin();
  604.  
  605.     // Helpers for > 32K read/write operations. Use for any CFile derived class.
  606.     DWORD ReadHuge(void FAR* lpBuffer, DWORD dwCount);
  607.     void WriteHuge(const void FAR* lpBuffer, DWORD dwCount);
  608.  
  609. // Overridables
  610.     virtual CFile* Duplicate() const;
  611.  
  612.     virtual LONG Seek(LONG lOff, UINT nFrom);
  613.     virtual void SetLength(DWORD dwNewLen);
  614.     virtual DWORD GetLength() const;
  615.  
  616.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  617.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  618.  
  619.     virtual void LockRange(DWORD dwPos, DWORD dwCount);
  620.     virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  621.  
  622.     virtual void Abort();
  623.     virtual void Flush();
  624.     virtual void Close();
  625.  
  626. // Implementation
  627. public:
  628.     virtual ~CFile();
  629. #ifdef _DEBUG
  630.     virtual void AssertValid() const;
  631.     virtual void Dump(CDumpContext& dc) const;
  632. #endif
  633.  
  634. protected:
  635.     BOOL m_bCloseOnDelete;
  636. };
  637.  
  638. /////////////////////////////////////////////////////////////////////////////
  639. // STDIO file implementation
  640.  
  641. class CStdioFile : public CFile
  642. {
  643.     DECLARE_DYNAMIC(CStdioFile)
  644.  
  645. public:
  646. // Constructors
  647.     CStdioFile();
  648.     CStdioFile(FILE* pOpenStream);
  649.     CStdioFile(const char* pszFileName, UINT nOpenFlags);
  650.  
  651. // Attributes
  652.     FILE* m_pStream;    // stdio FILE
  653.                         // m_hFile from base class is _fileno(m_pStream)
  654.  
  655. // Operations
  656.     virtual void WriteString(LPCSTR lpsz);
  657.         // write a string, like "C" fputs
  658.     virtual LPSTR ReadString(LPSTR lpsz, UINT nMax);
  659.         // like "C" fgets
  660.  
  661. // Implementation
  662. public:
  663.     virtual ~CStdioFile();
  664. #ifdef _DEBUG
  665.     void Dump(CDumpContext& dc) const;
  666. #endif
  667.     virtual DWORD GetPosition() const;
  668.     virtual BOOL Open(const char* pszFileName, UINT nOpenFlags,
  669.         CFileException* pError = NULL);
  670.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  671.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  672.     virtual LONG Seek(LONG lOff, UINT nFrom);
  673.     virtual void Abort();
  674.     virtual void Flush();
  675.     virtual void Close();
  676.  
  677.     // Unsupported APIs
  678.     virtual CFile* Duplicate() const;
  679.     virtual void LockRange(DWORD dwPos, DWORD dwCount);
  680.     virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  681. };
  682.  
  683. ////////////////////////////////////////////////////////////////////////////
  684. // Memory based file implementation
  685.  
  686. class CMemFile : public CFile
  687. {
  688.     DECLARE_DYNAMIC(CMemFile)
  689.  
  690. public:
  691. // Constructors
  692.     CMemFile(UINT nGrowBytes = 1024);
  693.  
  694. // Advanced Overridables
  695. protected:
  696.     virtual BYTE FAR* Alloc(UINT nBytes);
  697.     virtual BYTE FAR* Realloc(BYTE FAR* lpMem, UINT nBytes);
  698.     virtual BYTE FAR* Memcpy(BYTE FAR* lpMemTarget, const BYTE FAR* lpMemSource, UINT nBytes);
  699.     virtual void Free(BYTE FAR* lpMem);
  700.     virtual void GrowFile(DWORD dwNewLen);
  701.  
  702. // Implementation
  703. protected:
  704.     UINT m_nGrowBytes;
  705.     UINT m_nPosition;
  706.     UINT m_nBufferSize;
  707.     UINT m_nFileSize;
  708.     BYTE FAR* m_lpBuffer;
  709. public:
  710.     virtual ~CMemFile();
  711. #ifdef _DEBUG
  712.     virtual void Dump(CDumpContext& dc) const;
  713.     virtual void AssertValid() const;
  714. #endif
  715.     virtual DWORD GetPosition() const;
  716.     BOOL GetStatus(CFileStatus& rStatus) const;
  717.     virtual LONG Seek(LONG lOff, UINT nFrom);
  718.     virtual void SetLength(DWORD dwNewLen);
  719.     virtual UINT Read(void FAR* lpBuf, UINT nCount);
  720.     virtual void Write(const void FAR* lpBuf, UINT nCount);
  721.     virtual void Abort();
  722.     virtual void Flush();
  723.     virtual void Close();
  724.  
  725.     // Unsupported APIs
  726.     virtual CFile* Duplicate() const;
  727.     virtual void LockRange(DWORD dwPos, DWORD dwCount);
  728.     virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
  729. };
  730.  
  731. /////////////////////////////////////////////////////////////////////////////
  732. // Strings
  733.  
  734. class CString
  735. {
  736. public:
  737.  
  738. // Constructors
  739.     CString();
  740.     CString(const CString& stringSrc);
  741.     CString(char ch, int nRepeat = 1);
  742.     CString(const char* psz);
  743.     CString(const char* pch, int nLength);
  744. #ifdef _NEARDATA
  745.     // Additional versions for far string data
  746.     CString(LPCSTR lpsz);
  747.     CString(LPCSTR lpch, int nLength);
  748. #endif
  749.     ~CString();
  750.  
  751. // Attributes & Operations
  752.  
  753.     // as an array of characters
  754.     int GetLength() const;
  755.     BOOL IsEmpty() const;
  756.     void Empty();                       // free up the data
  757.  
  758.     char GetAt(int nIndex) const;       // 0 based
  759.     char operator[](int nIndex) const;  // same as GetAt
  760.     void SetAt(int nIndex, char ch);
  761.     operator const char*() const;       // as a C string
  762.  
  763.     // overloaded assignment
  764.     const CString& operator=(const CString& stringSrc);
  765.     const CString& operator=(char ch);
  766.     const CString& operator=(const char* psz);
  767.  
  768.     // string concatenation
  769.     const CString& operator+=(const CString& string);
  770.     const CString& operator+=(char ch);
  771.     const CString& operator+=(const char* psz);
  772.  
  773.     friend CString AFXAPI operator+(const CString& string1,
  774.             const CString& string2);
  775.     friend CString AFXAPI operator+(const CString& string, char ch);
  776.     friend CString AFXAPI operator+(char ch, const CString& string);
  777.     friend CString AFXAPI operator+(const CString& string, const char* psz);
  778.     friend CString AFXAPI operator+(const char* psz, const CString& string);
  779.  
  780.     // string comparison
  781.     int Compare(const char* psz) const;         // straight character
  782.     int CompareNoCase(const char* psz) const;   // ignore case
  783.     int Collate(const char* psz) const;         // NLS aware
  784.  
  785.     // simple sub-string extraction
  786.     CString Mid(int nFirst, int nCount) const;
  787.     CString Mid(int nFirst) const;
  788.     CString Left(int nCount) const;
  789.     CString Right(int nCount) const;
  790.  
  791.     CString SpanIncluding(const char* pszCharSet) const;
  792.     CString SpanExcluding(const char* pszCharSet) const;
  793.  
  794.     // upper/lower/reverse conversion
  795.     void MakeUpper();
  796.     void MakeLower();
  797.     void MakeReverse();
  798.  
  799.     // searching (return starting index, or -1 if not found)
  800.     // look for a single character match
  801.     int Find(char ch) const;                    // like "C" strchr
  802.     int ReverseFind(char ch) const;
  803.     int FindOneOf(const char* pszCharSet) const;
  804.  
  805.     // look for a specific sub-string
  806.     int Find(const char* pszSub) const;         // like "C" strstr
  807.  
  808.     // input and output
  809. #ifdef _DEBUG
  810.     friend CDumpContext& AFXAPI operator<<(CDumpContext& dc,
  811.                 const CString& string);
  812. #endif
  813.     friend CArchive& AFXAPI operator<<(CArchive& ar, const CString& string);
  814.     friend CArchive& AFXAPI operator>>(CArchive& ar, CString& string);
  815.  
  816.     // Windows support
  817. #ifdef _WINDOWS
  818.     BOOL LoadString(UINT nID);          // load from string resource
  819.                                         // 255 chars max
  820.     // ANSI<->OEM support (convert string in place)
  821.     void AnsiToOem();
  822.     void OemToAnsi();
  823. #endif //_WINDOWS
  824.  
  825.     // Access to string implementation buffer as "C" character array
  826.     char* GetBuffer(int nMinBufLength);
  827.     void ReleaseBuffer(int nNewLength = -1);
  828.     char* GetBufferSetLength(int nNewLength);
  829.  
  830. // Implementation
  831. protected:
  832.     // lengths/sizes in characters
  833.     //  (note: an extra character is always allocated)
  834.     char* m_pchData;            // actual string (zero terminated)
  835.     int m_nDataLength;          // does not include terminating 0
  836.     int m_nAllocLength;         // does not include terminating 0
  837.  
  838.     // implementation helpers
  839.     void Init();
  840.     void AllocCopy(CString& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const;
  841.     void AllocBuffer(int nLen);
  842.     void AssignCopy(int nSrcLen, const char* pszSrcData);
  843.     void ConcatCopy(int nSrc1Len, const char* pszSrc1Data, int nSrc2Len, const char* pszSrc2Data);
  844.     void ConcatInPlace(int nSrcLen, const char* pszSrcData);
  845. };
  846.  
  847.  
  848. // Compare helpers
  849. BOOL AFXAPI operator==(const CString& s1, const CString& s2);
  850. BOOL AFXAPI operator==(const CString& s1, const char* s2);
  851. BOOL AFXAPI operator==(const char* s1, const CString& s2);
  852. BOOL AFXAPI operator!=(const CString& s1, const CString& s2);
  853. BOOL AFXAPI operator!=(const CString& s1, const char* s2);
  854. BOOL AFXAPI operator!=(const char* s1, const CString& s2);
  855. BOOL AFXAPI operator<(const CString& s1, const CString& s2);
  856. BOOL AFXAPI operator<(const CString& s1, const char* s2);
  857. BOOL AFXAPI operator<(const char* s1, const CString& s2);
  858. BOOL AFXAPI operator>(const CString& s1, const CString& s2);
  859. BOOL AFXAPI operator>(const CString& s1, const char* s2);
  860. BOOL AFXAPI operator>(const char* s1, const CString& s2);
  861. BOOL AFXAPI operator<=(const CString& s1, const CString& s2);
  862. BOOL AFXAPI operator<=(const CString& s1, const char* s2);
  863. BOOL AFXAPI operator<=(const char* s1, const CString& s2);
  864. BOOL AFXAPI operator>=(const CString& s1, const CString& s2);
  865. BOOL AFXAPI operator>=(const CString& s1, const char* s2);
  866. BOOL AFXAPI operator>=(const char* s1, const CString& s2);
  867.  
  868. /////////////////////////////////////////////////////////////////////////////
  869. // CTimeSpan and CTime
  870.  
  871. class CTimeSpan
  872. {
  873. public:
  874.  
  875. // Constructors
  876.     CTimeSpan();
  877.     CTimeSpan(time_t time);
  878.     CTimeSpan(LONG lDays, int nHours, int nMins, int nSecs);
  879.  
  880.     CTimeSpan(const CTimeSpan& timeSpanSrc);
  881.     const CTimeSpan& operator=(const CTimeSpan& timeSpanSrc);
  882.  
  883. // Attributes
  884.     // extract parts
  885.     LONG GetDays() const;   // total # of days
  886.     LONG GetTotalHours() const;
  887.     int GetHours() const;
  888.     LONG GetTotalMinutes() const;
  889.     int GetMinutes() const;
  890.     LONG GetTotalSeconds() const;
  891.     int GetSeconds() const;
  892.  
  893. // Operations
  894.     // time math
  895.     CTimeSpan operator-(CTimeSpan timeSpan) const;
  896.     CTimeSpan operator+(CTimeSpan timeSpan) const;
  897.     const CTimeSpan& operator+=(CTimeSpan timeSpan);
  898.     const CTimeSpan& operator-=(CTimeSpan timeSpan);
  899.     BOOL operator==(CTimeSpan timeSpan) const;
  900.     BOOL operator!=(CTimeSpan timeSpan) const;
  901.     BOOL operator<(CTimeSpan timeSpan) const;
  902.     BOOL operator>(CTimeSpan timeSpan) const;
  903.     BOOL operator<=(CTimeSpan timeSpan) const;
  904.     BOOL operator>=(CTimeSpan timeSpan) const;
  905.  
  906. #if !defined(_AFXDLL) && !defined(_USRDLL)
  907.     CString Format(const char* pFormat) const;
  908. #endif //! DLL variant
  909.  
  910.     // serialization
  911. #ifdef _DEBUG
  912.     friend CDumpContext& AFXAPI operator<<(CDumpContext& dc,CTimeSpan timeSpan);
  913. #endif
  914.     friend CArchive& AFXAPI operator<<(CArchive& ar, CTimeSpan timeSpan);
  915.     friend CArchive& AFXAPI operator>>(CArchive& ar, CTimeSpan& rtimeSpan);
  916.  
  917. private:
  918.     time_t m_timeSpan;
  919.     friend class CTime;
  920. };
  921.  
  922. class CTime
  923. {
  924. public:
  925.  
  926. // Constructors
  927.     static CTime PASCAL GetCurrentTime();
  928.  
  929.     CTime();
  930.     CTime(time_t time);
  931.     CTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec);
  932.     CTime(WORD wDosDate, WORD wDosTime);
  933.     CTime(const CTime& timeSrc);
  934.  
  935.     const CTime& operator=(const CTime& timeSrc);
  936.     const CTime& operator=(time_t t);
  937.  
  938. // Attributes
  939.     struct tm* GetGmtTm(struct tm* ptm = NULL) const;
  940.     struct tm* GetLocalTm(struct tm* ptm = NULL) const;
  941.  
  942.     time_t GetTime() const;
  943.     int GetYear() const;
  944.     int GetMonth() const;       // month of year (1 = Jan)
  945.     int GetDay() const;         // day of month
  946.     int GetHour() const;
  947.     int GetMinute() const;
  948.     int GetSecond() const;
  949.     int GetDayOfWeek() const;   // 1=Sun, 2=Mon, ..., 7=Sat
  950.  
  951. // Operations
  952.     // time math
  953.     CTimeSpan operator-(CTime time) const;
  954.     CTime operator-(CTimeSpan timeSpan) const;
  955.     CTime operator+(CTimeSpan timeSpan) const;
  956.     const CTime& operator+=(CTimeSpan timeSpan);
  957.     const CTime& operator-=(CTimeSpan timeSpan);
  958.     BOOL operator==(CTime time) const;
  959.     BOOL operator!=(CTime time) const;
  960.     BOOL operator<(CTime time) const;
  961.     BOOL operator>(CTime time) const;
  962.     BOOL operator<=(CTime time) const;
  963.     BOOL operator>=(CTime time) const;
  964.  
  965.     // formatting using "C" strftime
  966. #if !defined(_AFXDLL) && !defined(_USRDLL)
  967.     CString Format(const char* pFormat) const;
  968.     CString FormatGmt(const char* pFormat) const;
  969. #endif //! DLL variant
  970.  
  971.     // serialization
  972. #ifdef _DEBUG
  973.     friend CDumpContext& AFXAPI operator<<(CDumpContext& dc, CTime time);
  974. #endif
  975.     friend CArchive& AFXAPI operator<<(CArchive& ar, CTime time);
  976.     friend CArchive& AFXAPI operator>>(CArchive& ar, CTime& rtime);
  977.  
  978. private:
  979.     time_t m_time;
  980. };
  981.  
  982. /////////////////////////////////////////////////////////////////////////////
  983. // File status
  984.  
  985. struct CFileStatus
  986. {
  987.     CTime m_ctime;          // creation date/time of file
  988.     CTime m_mtime;          // last modification date/time of file
  989.     CTime m_atime;          // last access date/time of file
  990.     LONG m_size;            // logical size of file in bytes
  991.     BYTE m_attribute;       // logical OR of CFile::Attribute enum values
  992.     BYTE _m_padding;        // pad the structure to a WORD
  993.     char m_szFullName[_MAX_PATH]; // absolute path name
  994.  
  995. #ifdef _DEBUG
  996.     void Dump(CDumpContext& dc) const;
  997. #endif
  998. };
  999.  
  1000.  
  1001. /////////////////////////////////////////////////////////////////////////////
  1002. // Diagnostic memory management routines
  1003.  
  1004. // Low level sanity checks for memory blocks
  1005. extern "C" BOOL AFXAPI AfxIsValidAddress(const void FAR* lp,
  1006.             UINT nBytes, BOOL bReadWrite = TRUE);
  1007. #ifdef _NEARDATA
  1008. BOOL AFXAPI AfxIsValidAddress(const void NEAR* np, UINT nBytes, 
  1009.             BOOL bReadWrite = TRUE);
  1010. #endif
  1011. extern "C" BOOL AFXAPI AfxIsValidString(LPCSTR lpsz, int nLength = -1);
  1012.  
  1013. #ifdef _DEBUG
  1014.  
  1015. // Memory tracking allocation
  1016. void* operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
  1017. #define DEBUG_NEW new(THIS_FILE, __LINE__)
  1018.  
  1019. // Return TRUE if valid memory block of nBytes
  1020. BOOL AFXAPI AfxIsMemoryBlock(const void* p, UINT nBytes,
  1021.             LONG* plRequestNumber = NULL);
  1022.  
  1023. // Return TRUE if memory is sane or print out what is wrong
  1024. BOOL AFXAPI AfxCheckMemory();
  1025.  
  1026. // Options for tuning the allocation diagnostics
  1027. extern "C" { extern int NEAR afxMemDF; }
  1028.  
  1029. enum AfxMemDF // memory debug/diagnostic flags
  1030. {
  1031.     allocMemDF          = 0x01,         // turn on debugging allocator
  1032.     delayFreeMemDF      = 0x02,         // delay freeing memory
  1033.     checkAlwaysMemDF    = 0x04          // AfxCheckMemory on every alloc/free
  1034. };
  1035.  
  1036. // Advanced initialization: for overriding default diagnostics
  1037. extern "C" BOOL AFXAPI AfxDiagnosticInit(void);
  1038.  
  1039. // turn on/off tracking for a short while
  1040. BOOL AFXAPI AfxEnableMemoryTracking(BOOL bTrack);
  1041.  
  1042. // Memory allocator failure simulation and control (_DEBUG only)
  1043.  
  1044. // A failure hook returns whether to permit allocation
  1045. typedef BOOL (AFXAPI* AFX_ALLOC_HOOK)(size_t nSize, BOOL bObject, LONG lRequestNumber);
  1046.  
  1047. // Set new hook, return old (never NULL)
  1048. AFX_ALLOC_HOOK AFXAPI AfxSetAllocHook(AFX_ALLOC_HOOK pfnAllocHook);
  1049.  
  1050. #ifndef _PORTABLE
  1051. // Debugger hook on specified allocation request - Obsolete
  1052. void AFXAPI AfxSetAllocStop(LONG lRequestNumber);
  1053. #endif
  1054.  
  1055. // Memory state for snapshots/leak detection
  1056. struct CMemoryState
  1057. {
  1058. // Attributes
  1059.     enum blockUsage
  1060.     {
  1061.         freeBlock,    // memory not used
  1062.         objectBlock,  // contains a CObject derived class object
  1063.         bitBlock,     // contains ::operator new data
  1064.         nBlockUseMax  // total number of usages
  1065.     };
  1066.  
  1067.     struct CBlockHeader* m_pBlockHeader;
  1068.     LONG m_lCounts[nBlockUseMax];
  1069.     LONG m_lSizes[nBlockUseMax];
  1070.     LONG m_lHighWaterCount;
  1071.     LONG m_lTotalCount;
  1072.  
  1073.     CMemoryState();
  1074.  
  1075. // Operations
  1076.     void Checkpoint();  // fill with current state
  1077.     BOOL Difference(const CMemoryState& oldState,
  1078.                     const CMemoryState& newState);  // fill with difference
  1079.  
  1080.     // Output to afxDump
  1081.     void DumpStatistics() const;
  1082.     void DumpAllObjectsSince() const;
  1083. };
  1084.  
  1085. // Enumerate allocated objects or runtime classes
  1086. void AFXAPI AfxDoForAllObjects(void (*pfn)(CObject* pObject,
  1087.             void* pContext), void* pContext);
  1088. void AFXAPI AfxDoForAllClasses(void (*pfn)(const CRuntimeClass* pClass,
  1089.             void* pContext), void* pContext);
  1090.  
  1091. #else
  1092.  
  1093. // NonDebug version that assume everything is OK
  1094. #define DEBUG_NEW new
  1095. #define AfxCheckMemory() TRUE
  1096. #define AfxIsMemoryBlock(p, nBytes) TRUE
  1097.  
  1098. #endif // _DEBUG
  1099.  
  1100. /////////////////////////////////////////////////////////////////////////////
  1101. // Archives for serializing CObject data
  1102.  
  1103. // needed for implementation
  1104. class CPtrArray;
  1105. class CMapPtrToWord;
  1106.  
  1107. class CArchive
  1108. {
  1109. public:
  1110. // Flag values
  1111.     enum Mode { store = 0, load = 1, bNoFlushOnDelete = 2 };
  1112.  
  1113.     CArchive(CFile* pFile, UINT nMode, int nBufSize = 512, void FAR* lpBuf = NULL);
  1114.     ~CArchive();
  1115.  
  1116. // Attributes
  1117.     BOOL IsLoading() const;
  1118.     BOOL IsStoring() const;
  1119.     CFile* GetFile() const;
  1120.  
  1121. // Operations
  1122.     UINT Read(void FAR* lpBuf, UINT nMax);
  1123.     void Write(const void FAR* lpBuf, UINT nMax);
  1124.     void Flush();
  1125.     void Close();
  1126.  
  1127. public:
  1128.     // Object I/O is pointer based to avoid added construction overhead.
  1129.     // Use the Serialize member function directly for embedded objects.
  1130.     friend CArchive& AFXAPI operator<<(CArchive& ar, const CObject* pOb);
  1131.  
  1132.     friend CArchive& AFXAPI operator>>(CArchive& ar, CObject*& pOb);
  1133.     friend CArchive& AFXAPI operator>>(CArchive& ar, const CObject*& pOb);
  1134.  
  1135.     // insertion operations
  1136.     // NOTE: operators available only for fixed size types for portability
  1137.     CArchive& operator<<(BYTE by);
  1138.     CArchive& operator<<(WORD w);
  1139.     CArchive& operator<<(LONG l);
  1140.     CArchive& operator<<(DWORD dw);
  1141.     CArchive& operator<<(float f);
  1142.     CArchive& operator<<(double d);
  1143.  
  1144.     // extraction operations
  1145.     // NOTE: operators available only for fixed size types for portability
  1146.     CArchive& operator>>(BYTE& by);
  1147.     CArchive& operator>>(WORD& w);
  1148.     CArchive& operator>>(DWORD& dw);
  1149.     CArchive& operator>>(LONG& l);
  1150.     CArchive& operator>>(float& f);
  1151.     CArchive& operator>>(double& d);
  1152.  
  1153.     CObject* ReadObject(const CRuntimeClass* pClass);
  1154.     void WriteObject(const CObject* pOb);
  1155.  
  1156. // Implementation
  1157.     void FillBuffer(UINT nBytesNeeded);
  1158. protected:
  1159.     // archive objects cannot be copied or assigned
  1160.     CArchive(const CArchive& arSrc);
  1161.     void operator=(const CArchive& arSrc);
  1162.  
  1163.     BOOL m_nMode;
  1164.     BOOL m_bUserBuf;
  1165.     int m_nBufSize;
  1166.     CFile* m_pFile;
  1167.     BYTE FAR* m_lpBufCur;
  1168.     BYTE FAR* m_lpBufMax;
  1169.     BYTE FAR* m_lpBufStart;
  1170.  
  1171.     UINT m_nMapCount;   // count and map used when storing
  1172.     union
  1173.     {
  1174.         CPtrArray* m_pLoadArray;
  1175.         CMapPtrToWord* m_pStoreMap;
  1176.     };
  1177. };
  1178.  
  1179.  
  1180. /////////////////////////////////////////////////////////////////////////////
  1181. // Diagnostic dumping
  1182.  
  1183. class CDumpContext
  1184. {
  1185. public:
  1186.     CDumpContext(CFile* pFile);
  1187.  
  1188. // Attributes
  1189.     int GetDepth() const;      // 0 => this object, 1 => children objects
  1190.     void SetDepth(int nNewDepth);
  1191.  
  1192. // Operations
  1193.     CDumpContext& operator<<(LPCSTR lpsz);
  1194.     CDumpContext& operator<<(const void FAR* lp);
  1195. #ifdef _NEARDATA
  1196.     CDumpContext& operator<<(const void NEAR* np);
  1197. #endif
  1198.     CDumpContext& operator<<(const CObject* pOb);
  1199.     CDumpContext& operator<<(const CObject& ob);
  1200.     CDumpContext& operator<<(BYTE by);
  1201.     CDumpContext& operator<<(WORD w);
  1202.     CDumpContext& operator<<(UINT u);
  1203.     CDumpContext& operator<<(LONG l);
  1204.     CDumpContext& operator<<(DWORD dw);
  1205.     CDumpContext& operator<<(float f);
  1206.     CDumpContext& operator<<(double d);
  1207.     CDumpContext& operator<<(int n);
  1208.     void HexDump(const char* pszLine, BYTE* pby, int nBytes, int nWidth);
  1209.     void Flush();
  1210.  
  1211. // Implementation
  1212. protected:
  1213.     // dump context objects cannot be copied or assigned
  1214.     CDumpContext(const CDumpContext& dcSrc);
  1215.     void operator=(const CDumpContext& dcSrc);
  1216.     void OutputString(LPCSTR lpsz);
  1217.  
  1218.     int m_nDepth;
  1219.  
  1220. public:
  1221.     CFile* m_pFile;
  1222. };
  1223.  
  1224. #ifdef _DEBUG
  1225. extern CDumpContext& NEAR afxDump;
  1226. extern "C" { extern BOOL NEAR afxTraceEnabled; }
  1227. #endif
  1228.  
  1229. /////////////////////////////////////////////////////////////////////////////
  1230. // Inline function declarations
  1231.  
  1232. void* PASCAL _AfxGetPtrFromFarPtr(void FAR* lp);
  1233.  
  1234. #ifdef _AFX_ENABLE_INLINES
  1235. #define _AFX_INLINE inline
  1236. #include "afx.inl"
  1237. #endif
  1238.  
  1239. #undef AFXAPP_DATA
  1240. #define AFXAPP_DATA     NEAR
  1241.  
  1242. #endif // __AFX_H__
  1243.