home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tvision / resource.h < prev    next >
C/C++ Source or Header  |  1998-01-19  |  6KB  |  260 lines

  1. /*
  2.  * resource.h
  3.  *
  4.  * Turbo Vision - Version 2.0
  5.  *
  6.  * Copyright (c) 1994 by Borland International
  7.  * All Rights Reserved.
  8.  *
  9.  * Modified by Sergio Sigala <ssigala@globalnet.it>
  10.  */
  11.  
  12. #if defined( Uses_TStringCollection ) && !defined( __TStringCollection )
  13. #define __TStringCollection
  14.  
  15. class TStringCollection : public TSortedCollection
  16. {
  17.  
  18. public:
  19.  
  20.     TStringCollection( short aLimit, short aDelta );
  21.  
  22. private:
  23.  
  24.     virtual int compare( void *key1, void *key2 );
  25.     virtual void freeItem( void *item );
  26.  
  27.     virtual const char *streamableName() const
  28.         { return name; }
  29.     virtual void *readItem( ipstream& );
  30.     virtual void writeItem( void *, opstream& );
  31.  
  32. protected:
  33.  
  34.     TStringCollection( StreamableInit ) : TSortedCollection ( streamableInit ) {};
  35.  
  36. public:
  37.  
  38.     static const char * const name;
  39.     static TStreamable *build();
  40.  
  41. };
  42.  
  43. inline ipstream& operator >> ( ipstream& is, TStringCollection& cl )
  44.     { return is >> (TStreamable&)cl; }
  45. inline ipstream& operator >> ( ipstream& is, TStringCollection*& cl )
  46.     { return is >> (void *&)cl; }
  47.  
  48. inline opstream& operator << ( opstream& os, TStringCollection& cl )
  49.     { return os << (TStreamable&)cl; }
  50. inline opstream& operator << ( opstream& os, TStringCollection* cl )
  51.     { return os << (TStreamable *)cl; }
  52.  
  53. #endif  // Uses_TStringCollection
  54.  
  55. #if defined( Uses_TResourceItem ) && !defined( __TResourceItem )
  56. #define __TResourceItem
  57.  
  58. struct TResourceItem
  59. {
  60.  
  61.     long pos;
  62.     long size;
  63.     char *key;
  64. };
  65.  
  66. #endif  // Uses_TResourceItem
  67.  
  68. #if defined( Uses_TResourceCollection ) && !defined( __TResourceCollection )
  69. #define __TResourceCollection
  70.  
  71. class TResourceCollection: public TStringCollection
  72. {
  73.  
  74. public:
  75.  
  76.     TResourceCollection( StreamableInit) : TStringCollection( streamableInit ) {};
  77.     TResourceCollection( short aLimit, short aDelta );
  78.  
  79.     virtual void *keyOf( void *item );
  80.  
  81. private:
  82.  
  83.     virtual void freeItem( void *item );
  84.  
  85.     virtual const char *streamableName() const
  86.         { return name; }
  87.     virtual void *readItem( ipstream& );
  88.     virtual void writeItem( void *, opstream& );
  89.  
  90. public:
  91.  
  92.     static const char * const name;
  93.     static TStreamable *build();
  94.  
  95. };
  96.  
  97. inline ipstream& operator >> ( ipstream& is, TResourceCollection& cl )
  98.     { return is >> (TStreamable&)cl; }
  99. inline ipstream& operator >> ( ipstream& is, TResourceCollection*& cl )
  100.     { return is >> (void *&)cl; }
  101.  
  102. inline opstream& operator << ( opstream& os, TResourceCollection& cl )
  103.     { return os << (TStreamable&)cl; }
  104. inline opstream& operator << ( opstream& os, TResourceCollection* cl )
  105.     { return os << (TStreamable *)cl; }
  106.  
  107. #endif  // Uses_TResourceCollection
  108.  
  109. #if defined( Uses_TResourceFile ) && !defined( __TResourceFile )
  110. #define __TResourceFile
  111.  
  112. class TResourceCollection;
  113. class fpstream;
  114.  
  115. class TResourceFile: public TObject
  116. {
  117.  
  118. public:
  119.  
  120.     TResourceFile( fpstream *aStream );
  121.     ~TResourceFile();
  122.     short count();
  123.     void remove( const char *key );
  124.     void flush();
  125.     void *get( const char *key );
  126.     const char *keyAt( short i );
  127.     void put( TStreamable *item, const char *key );
  128.     fpstream *switchTo( fpstream *aStream, Boolean pack );
  129.  
  130. protected:
  131.  
  132.     fpstream *stream;
  133.     Boolean modified;
  134.     long basePos;
  135.     long indexPos;
  136.     TResourceCollection *index;
  137. };
  138.  
  139. #endif  // Uses_TResourceFile
  140.  
  141. #if defined( Uses_TStrIndexRec ) && !defined( __TStrIndexRec )
  142. #define __TStrIndexRec
  143.  
  144. class TStrIndexRec
  145. {
  146.  
  147. public:
  148.  
  149.     TStrIndexRec();
  150.  
  151.     ushort key;
  152.     ushort count;
  153.     ushort offset;
  154.  
  155. };
  156.  
  157. #endif  // Uses_TStrIndexRec
  158.  
  159. #if defined( Uses_TStringList ) && !defined( __TStringList )
  160. #define __TStringList
  161.  
  162. class TStrIndexRec;
  163.  
  164. class TStringList : public TObject, public TStreamable
  165. {
  166.  
  167. public:
  168.  
  169.     ~TStringList();
  170.  
  171.     void get( char *dest, ushort key );
  172.  
  173. private:
  174.  
  175.     ipstream *ip;
  176.     long basePos;
  177.     short indexSize;
  178.     TStrIndexRec *index;
  179.  
  180.     virtual const char *streamableName() const
  181.         { return name; }
  182.  
  183. protected:
  184.  
  185.     TStringList( StreamableInit );
  186.     virtual void write( opstream& ) {}
  187.     virtual void *read( ipstream& );
  188.  
  189. public:
  190.  
  191.     static const char * const name;
  192.     static TStreamable *build();
  193.  
  194. };
  195.  
  196. inline ipstream& operator >> ( ipstream& is, TStringList& cl )
  197.     { return is >> (TStreamable&)cl; }
  198. inline ipstream& operator >> ( ipstream& is, TStringList*& cl )
  199.     { return is >> (void *&)cl; }
  200.  
  201. inline opstream& operator << ( opstream& os, TStringList& cl )
  202.     { return os << (TStreamable&)cl; }
  203. inline opstream& operator << ( opstream& os, TStringList* cl )
  204.     { return os << (TStreamable *)cl; }
  205.  
  206. #endif  // Uses_TStringList
  207.  
  208.  
  209. #if defined( Uses_TStrListMaker ) && !defined( __TStrListMaker )
  210. #define __TStrListMaker
  211.  
  212. class TStrListMaker : public TObject, public TStreamable
  213. {
  214.  
  215. public:
  216.  
  217.     TStrListMaker( ushort aStrSize, ushort aIndexSize );
  218.     ~TStrListMaker();
  219.  
  220.     void put( ushort key, char *str );
  221.  
  222. private:
  223.  
  224.     ushort strPos;
  225.     ushort strSize;
  226.     char *strings;
  227.     ushort indexPos;
  228.     ushort indexSize;
  229.     TStrIndexRec *index;
  230.     TStrIndexRec cur;
  231.     void closeCurrent();
  232.  
  233.     virtual const char *streamableName() const
  234.         { return TStringList::name; }
  235.  
  236. protected:
  237.  
  238.     TStrListMaker( StreamableInit );
  239.     virtual void write( opstream& );
  240.     virtual void *read( ipstream& ) { return 0; }
  241.  
  242. public:
  243.  
  244.     static TStreamable *build();
  245.  
  246. };
  247.  
  248. inline ipstream& operator >> ( ipstream& is, TStrListMaker& cl )
  249.     { return is >> (TStreamable&)cl; }
  250. inline ipstream& operator >> ( ipstream& is, TStrListMaker*& cl )
  251.     { return is >> (void *&)cl; }
  252.  
  253. inline opstream& operator << ( opstream& os, TStrListMaker& cl )
  254.     { return os << (TStreamable&)cl; }
  255. inline opstream& operator << ( opstream& os, TStrListMaker* cl )
  256.     { return os << (TStreamable *)cl; }
  257.  
  258.  
  259. #endif  // Uses_TStrListMaker
  260.