Annotation of mstools/mfc/include/afx.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.