home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / Vcl / SYSCLASS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  11.7 KB  |  498 lines

  1. // SYSCLASS.H: Definitions of Pascal types
  2. // Copyright (c) 1997, 1998 Borland International
  3.  
  4. #if !defined(SYSCLASS_H)
  5. #define SYSCLASS_H
  6.  
  7. #if !defined(SystemHPP)
  8. #error Do not include this file directly.  Include 'system.hpp'.
  9. #endif
  10.  
  11. #if !defined(SYSMAC_H)
  12. #include <sysmac.h>
  13. #endif
  14.  
  15. // VCL_IOSTREAM: This macro enables the i/ostream insertion/extraction operators of VCL
  16. //               classes. The operators are otherwise hidden to cut down on the amount
  17. //               of lines (i.e. symbols) that must be compiled. (The redefinition of
  18. //               i/ostream as templates in the Standard Library made these headers
  19. //               fairly significant).
  20. //
  21. // If <iostream.h> has already been included, then expose the VCL insertion/extraction operators.
  22. //
  23. #if defined(__STD_IOSTREAM__)
  24. #define VCL_IOSTREAM
  25. using namespace std;
  26. #elif defined(VCL_IOSTREAM) && !defined(__STD_IOSTREAM__)
  27. #include <iostream.h>
  28. #endif
  29.  
  30. #if !defined(DSTRING_H)
  31. #include <dstring.h>
  32. #endif
  33. #if !defined(WSTRING_H)
  34. #include <wstring.h>
  35. #endif
  36.  
  37. #if !defined(SYSTOBJ_H)
  38. #include <systobj.h>
  39. #endif
  40.  
  41. #if !defined(SYSTDATE_H)
  42. #include <systdate.h>
  43. #endif
  44.  
  45. #if !defined(SYSCURR_H)
  46. #include <syscurr.h>
  47. #endif
  48.  
  49. #if !defined(SYSCOMP_H)
  50. #include <syscomp.h>
  51. #endif
  52.  
  53. #if !defined(SYSSET_H)
  54. #include <sysset.h>
  55. #endif
  56.  
  57. #if !defined(SYSMAC_H)
  58. #include <sysmac.h>
  59. #endif
  60.  
  61. #if !defined(SYSTVAR_H)
  62. #include <systvar.h>
  63. #endif
  64.  
  65. #if !defined(SYSDYN_H)
  66. #include <sysdyn.h>
  67. #endif
  68.  
  69. #if !defined(SYSOPEN_H)
  70. #include <sysopen.h>
  71. #endif
  72.  
  73. #if !defined(SYSTOBJ_H)
  74. #include <systobj.h>
  75. #endif
  76.  
  77. #if !defined(SYSVARI_H)
  78. #include <sysvari.h>
  79. #endif
  80.  
  81. #pragma option push -w-inl -w-lvc
  82.  
  83. namespace System
  84. {
  85.   class PACKAGE TVarArrayBound
  86.   {
  87.   public:
  88.     Integer ElementCount;
  89.     Integer LowBound;
  90.   };
  91.  
  92.   class PACKAGE TVarArray
  93.   {
  94.   public:
  95.     Word DimCount;
  96.     Word Flags;
  97.     Integer ElementSize;
  98.     Integer LockCount;
  99.     Pointer Data;
  100.     TVarArrayBound Bounds[256] /* [0..255] */;
  101.   };
  102.  
  103.   typedef class TMemoryManager *PMemoryManager;
  104.  
  105.   class PACKAGE TMemoryManager
  106.   {
  107.   public:
  108.     Pointer __fastcall (*GetMem)(Integer Size);
  109.     Integer __fastcall (*FreeMem)(Pointer P);
  110.     Pointer __fastcall (*ReallocMem)(Pointer P, Integer Size);
  111.   } ;
  112.  
  113.   class PACKAGE THeapStatus
  114.   {
  115.   public:
  116.     Cardinal TotalAddrSpace;
  117.     Cardinal TotalUncommitted;
  118.     Cardinal TotalCommitted;
  119.     Cardinal TotalAllocated;
  120.     Cardinal TotalFree;
  121.     Cardinal FreeSmall;
  122.     Cardinal FreeBig;
  123.     Cardinal Unused;
  124.     Cardinal Overhead;
  125.     Cardinal HeapErrorCode;
  126.   } ;
  127.  
  128.     typedef Integer __fastcall (*TThreadFunc)(Pointer Parameter);
  129.  
  130.     // Inspector Query
  131.     struct THeapBlock
  132.     {
  133.         void         *Start;
  134.         unsigned int Size;
  135.     };
  136.     // Inspector Query
  137.  
  138. #ifdef BCBVER1
  139.   #define USEDATAMODULE(FileName, DataModuleName)  \
  140.     class DELPHICLASS T##DataModuleName;       \
  141.     extern T##DataModuleName *DataModuleName;
  142. #else
  143.   #define USEDATAMODULE(FileName, DataModuleName)  \
  144.     class DELPHICLASS T##DataModuleName;       \
  145.     extern PACKAGE T##DataModuleName *DataModuleName;
  146. #endif
  147.  
  148. #ifdef BCBVER1
  149.   #define USEDATAMODULENS(FileName, UnitName, DataModuleName)  \
  150.     namespace UnitName {         \
  151.     class DELPHICLASS T##DataModuleName;       \
  152.     extern T##DataModuleName *DataModuleName;              \
  153.    };               \
  154.    using namespace UnitName
  155. #else
  156.   #define USEDATAMODULENS(FileName, UnitName, DataModuleName)  \
  157.     namespace UnitName {         \
  158.     class DELPHICLASS T##DataModuleName;       \
  159.     extern PACKAGE T##DataModuleName *DataModuleName;              \
  160.     };               \
  161.     using namespace UnitName
  162. #endif
  163.  
  164. #ifdef BCBVER1
  165.   #define USEFORM(FileName, FormName) \
  166.     class DELPHICLASS T##FormName;       \
  167.     extern T##FormName *FormName;
  168. #else
  169.   #define USEFORM(FileName, FormName) \
  170.     class DELPHICLASS T##FormName;       \
  171.     extern PACKAGE T##FormName *FormName;
  172. #endif
  173.  
  174. #define USEFORMRES(FileName, FormName, AncestorName) \
  175.    extern PACKAGE DummyThatIsNeverReferenced
  176.  
  177. #ifdef BCBVER1
  178.   #define USEFORMNS(FileName, UnitName, FormName) \
  179.     namespace UnitName {         \
  180.     class DELPHICLASS T##FormName;       \
  181.     extern T##FormName *FormName;          \
  182.     };               \
  183.     using namespace UnitName
  184. #else
  185.   #define USEFORMNS(FileName, UnitName, FormName) \
  186.     namespace UnitName {         \
  187.     class DELPHICLASS T##FormName;       \
  188.     extern PACKAGE T##FormName *FormName;          \
  189.     };               \
  190.     using namespace UnitName
  191. #endif
  192.  
  193. #define USEUNIT(ModName) \
  194.    extern PACKAGE DummyThatIsNeverReferenced
  195.  
  196. #define USEOBJ(FileName) \
  197.    extern PACKAGE DummyThatIsNeverReferenced
  198.  
  199. #define USERC(FileName) \
  200.    extern PACKAGE DummyThatIsNeverReferenced
  201.  
  202. #define USEASM(FileName) \
  203.    extern PACKAGE DummyThatIsNeverReferenced
  204.  
  205. #define USEDEF(FileName) \
  206.    extern PACKAGE DummyThatIsNeverReferenced
  207.  
  208. #define USERES(FileName) \
  209.    extern PACKAGE DummyThatIsNeverReferenced
  210.  
  211. #define USETLB(FileName) \
  212.    extern PACKAGE DummyThatIsNeverReferenced
  213.  
  214. #define USELIB(FileName) \
  215.    extern PACKAGE DummyThatIsNeverReferenced
  216.  
  217. #define USEFILE(FileName) \
  218.    extern PACKAGE DummyThatIsNeverReferenced
  219.  
  220. #define USEPACKAGE(FileName) \
  221.    extern PACKAGE DummyThatIsNeverReferenced
  222.  
  223. #define USEIDL(FileName) \
  224.    extern PACKAGE DummyThatIsNeverReferenced
  225.  
  226.   struct PACKAGE ResourceString
  227.   {
  228.     HINSTANCE       *hinstance;
  229.     unsigned long   id;                     // resource string id
  230.   };
  231.  
  232.   struct PACKAGE TModuleUnloadRec
  233.   {
  234.     TModuleUnloadRec    *next;
  235.     TModuleUnloadProc   *proc;
  236.   };
  237.   typedef TModuleUnloadRec *PModuleUnloadRec;
  238.  
  239.   struct PACKAGE TLibModule
  240.   {
  241.     TLibModule  *next;
  242.     long        instance;
  243.     long        resinstance;
  244.     long        reserved;
  245.   };
  246.  
  247.   struct PACKAGE TResStringRec
  248.   {
  249.     long        *module;
  250.     long        ident;
  251.   };
  252.   typedef TResStringRec *PResStringRec;
  253.  
  254.   // always get statically from vcle$(__DPKVER).lib
  255.   extern AnsiString __fastcall LoadResourceString(ResourceString const * const rsrc);
  256.  
  257.   // always get statically from vcle$(__DPKVER).lib
  258.   extern void __fastcall CheckSafecallResult(HRESULT hr);
  259.  
  260.   // always get statically from vcle$(__DPKVER).lib
  261.   extern void * __fastcall FindDynaInst(void * vmt, int ID);
  262.  
  263. } // namespace System
  264. using namespace System;
  265.  
  266. #if 0
  267. namespace Typinfo
  268. {
  269.   struct  TTypeInfo;
  270.   typedef TTypeInfo *PTypeInfo;
  271. }
  272.  
  273. namespace Controls
  274. {
  275.   typedef System::TDateTime TDate;
  276.   typedef System::TDateTime TTime;
  277. }
  278. #endif
  279.  
  280. // Define VCL_IOSTREAM operators
  281. //
  282. #if defined(VCL_IOSTREAM)
  283.  
  284. namespace System
  285. {
  286.   inline void read_to_delim(istream& strm, char delim, AnsiString& str)
  287.   {
  288.     char ch;
  289.     int nchars = 0;
  290.     char array[4096];
  291.     int capacity = sizeof array;
  292.  
  293.     while ( 1 )
  294.     {
  295.  
  296.       // Read as many characters as we can, up to the delimiter:
  297.       strm.get( array+nchars, capacity-nchars+1, delim );
  298.  
  299.       // This is the new string length:
  300.       nchars += strlen( array+nchars );
  301.  
  302.       // What stopped us?  An EOF?
  303.       if ( !strm.good() )
  304.         break;      // EOF encountered (or worse!)
  305.  
  306.       // Nope.  Was it the delimiter?
  307.       strm.get(ch);
  308.       if (ch==delim)
  309.         break;  // Yup. We're done.  Don't put it back on the stream.
  310.       else
  311.         strm.putback(ch); // Nope, Put it back and keep going.
  312.  
  313.     }
  314.     str = array;
  315.   }
  316.  
  317.   inline istream& operator >> (istream& is, AnsiString& arg)
  318.   {
  319.     read_to_delim(is, 0, arg);
  320.     return is;
  321.   }
  322.  
  323.   inline ostream& operator << (ostream& os, const AnsiString& arg)
  324.   {
  325.     return os << arg.c_str();
  326.   }
  327.  
  328.   template <unsigned char sz>
  329.   inline ostream& operator << (ostream& os, const SmallString<sz>& arg)
  330.   {
  331.     os << AnsiString(arg).c_str();
  332.     return os;
  333.   }
  334.  
  335.   template <unsigned char sz>
  336.   inline istream& operator >> (istream& is, SmallString<sz>& arg)
  337.   {
  338.     AnsiString s;
  339.     is >> s;
  340.     arg = s;
  341.     return is;
  342.   }
  343.  
  344.  
  345.   // Currency IOStream operators
  346.   //
  347.   inline ostream& operator << (ostream& os, const Currency& arg)
  348.   {
  349.     os << AnsiString(arg);
  350.     return os;
  351.   }
  352.  
  353.   inline istream& operator >> (istream& is, Currency& arg)
  354.   {
  355.     AnsiString s;
  356.     is >> s;
  357.     arg = s;
  358.     return is;
  359.   }
  360.  
  361.  
  362.   // TDateTime IOStream operators
  363.   //
  364.   inline ostream& operator << (ostream& os, const TDateTime& arg)
  365.   {
  366.     os << AnsiString(arg);
  367.     return os;
  368.   }
  369.  
  370.   inline istream& operator >> (istream& is, TDateTime& arg)
  371.   {
  372.     AnsiString s;
  373.     is >> s;
  374.     arg = s;
  375.     return is;
  376.   }
  377.  
  378.  
  379.   // Variant IOStream operators
  380.   //
  381.   inline ostream& operator <<(ostream& os, const Variant& arg)
  382.   {
  383.     switch (arg.VType)
  384.     {
  385.     case varEmpty:
  386.       os << "varEmpty";
  387.       break;
  388.     case varNull:
  389.       os << "varNull";
  390.       break;
  391.     case varSmallint:
  392.       os << "varSmallint: " << arg.VSmallint;
  393.       break;
  394.     case varInteger:
  395.       os << "varInteger: " << arg.VInteger;
  396.       break;
  397.     case varSingle:
  398.       os << "varSingle: " << arg.VSingle;
  399.       break;
  400.     case varDouble:
  401.       os << "varDouble: " << arg.VDouble;
  402.       break;
  403.     case varCurrency:
  404.       os << "varCurrency: " << arg.VCurrency;
  405.       break;
  406.     case varDate:
  407.       os << "varDate: " << arg.VDate;
  408.       break;
  409.     case varOleStr:
  410.       os << "varOleStr: " << AnsiString(arg.VOleStr);
  411.       break;
  412.     case varDispatch:
  413.       os << "varDispatch: " << static_cast<void*>(arg.VDispatch);
  414.       break;
  415.     case varError:
  416.       os << "varError: " << arg.VError;
  417.       break;
  418.     case varBoolean:
  419.       os << "varBoolean: " << arg.operator bool();
  420.       break;
  421.     case varUnknown:
  422.       os << "varUnknown: " << static_cast<void*>(arg.VUnknown);
  423.       break;
  424.     case varByte:
  425.       os << "varByte: " << arg.VByte;
  426.       break;
  427.     case varString:
  428.       os << "varString: " << arg.operator AnsiString();
  429.       break;
  430.     case varArray:
  431.       os << "varArray: " << static_cast<void*>(arg.VArray);
  432.       break;
  433.     case varSmallint | varByRef:
  434.       os << "varSmallint | varByRef: " << arg.VPointer;
  435.       break;
  436.     case varInteger | varByRef:
  437.       os << "varInteger | varByRef: " << arg.VPointer;
  438.       break;
  439.     case varSingle | varByRef:
  440.       os << "varSingle | varByRef: " << arg.VPointer;
  441.       break;
  442.     case varDouble | varByRef:
  443.       os << "varDouble | varByRef: " << arg.VPointer;
  444.       break;
  445.     case varCurrency | varByRef:
  446.       os << "varCurrency | varByRef: " << arg.VPointer;
  447.       break;
  448.     case varDate | varByRef:
  449.       os << "varDate | varByRef: " << arg.VPointer;
  450.       break;
  451.     case varOleStr | varByRef:
  452.       os << "varOleStr | varByRef: " << arg.VPointer;
  453.       break;
  454.     case varDispatch | varByRef:
  455.       os << "varDispatch | varByRef: " << arg.VPointer;
  456.       break;
  457.     case varError | varByRef:
  458.       os << "varError | varByRef: " << arg.VPointer;
  459.       break;
  460.     case varBoolean | varByRef:
  461.       os << "varBoolean | varByRef: " << arg.VPointer;
  462.       break;
  463.     case varUnknown | varByRef:
  464.       os << "varUnknown | varByRef: " << arg.VPointer;
  465.       break;
  466.     case varByte | varByRef:
  467.       os << "varByte | varByRef: " << arg.VPointer;
  468.       break;
  469.     case varString | varByRef:
  470.       os << "varString | varByRef: " << arg.VPointer;
  471.       break;
  472.     case varArray | varByRef:
  473.       os << "varArray | varByRef: " << arg.VPointer;
  474.       break;
  475.     }
  476.     return os;
  477.   }
  478. }       // namespace System
  479. #endif  // VCL_IOSTREAM
  480.  
  481.  
  482. #pragma option pop
  483.  
  484. // Undo the MACROs which mapped the Automation related types to their tagStruct.
  485. //
  486. #if defined(CURRENCY)
  487. #undef CURRENCY
  488. #endif
  489. #if defined(SAFEARRAY)
  490. #undef SAFEARRAY
  491. #endif
  492. #if defined(VARIANT)
  493. #undef  VARIANT
  494. #endif
  495.  
  496. #endif
  497.  
  498.