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