home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / DOCJET.ZIP / data.z / StoredObjectSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-20  |  2.4 KB  |  110 lines

  1. #ifndef GenLib_Store_h
  2. #define GenLib_Store_h
  3.  
  4. struct Subtype;
  5.  
  6. class StoredObjectSet {
  7.       public:
  8.     class Object {
  9.         char *storage;
  10.           public:
  11.         Object( const char *p_sourceFile,
  12.             unsigned int p_commentStartLine,
  13.             unsigned int p_declStartLine,
  14.             const char *p_objectName,
  15.             const Subtype &p_subtype,
  16.             const char *p_superclass,
  17.             const char *p_declaration,
  18.             const char *p_comment,
  19.             const char *p_body,
  20.             char const **p_extras );
  21.         ~Object();
  22.  
  23.         char *sourceFile;
  24.         int commentStartLine;
  25.         int declStartLine;
  26.         char *objectName;
  27.         const Subtype *subtype;
  28.         char *superclass;
  29.         char *declaration;
  30.         char *comment;
  31.         char *body;
  32.         char **extras;
  33.     };
  34.  
  35.     class Iterator {
  36.         const StoredObjectSet *collection;
  37.         struct {
  38.             unsigned long block:24;
  39.             unsigned long index:8;
  40.         };
  41.  
  42.           private: friend class StoredObjectSet;
  43.         Iterator( const StoredObjectSet *p_collection,
  44.               unsigned int p_block, unsigned int p_index );
  45.  
  46.           public:
  47.         Iterator( const StoredObjectSet &p_collection );
  48.  
  49.         Object *peek() const;
  50.         void advance();
  51.         bool anymore();
  52.  
  53.         inline Object *operator->() const { return peek(); }
  54.         inline Object &operator*() const { return *peek(); }
  55.         inline void operator++() { advance(); }
  56.         inline void operator++(int) { advance(); }
  57.         inline operator bool() const { return ((Iterator *)this)->anymore(); }
  58.     };
  59.     friend class Iterator;
  60.  
  61.       private:
  62. #define SOS_BLOCKSIZE 256
  63.     struct Block {
  64.         int numItems;
  65.         Object *items[SOS_BLOCKSIZE];
  66.     };
  67.     unsigned int numBlocks;
  68.     unsigned int maxBlocks;
  69.     Block **blocks;
  70.  
  71.       public:
  72.     StoredObjectSet();
  73.     void Add( Object *o );
  74.     Iterator GetIterator() const;
  75.     void Destroy( const Iterator &i );
  76.  
  77.     void Pass( const Iterator &i, HookReportFunction f );
  78.     void PassAll( HookReportFunction f );
  79.  
  80.     ~StoredObjectSet();
  81. };
  82.  
  83. class ExtrasSet {
  84.     char **settings;
  85.     bool IOwnSettings;
  86.     char *privateSpace;
  87.     int usedSpace;
  88.     int totalSpace;
  89.  
  90.     void Setup( char **extras );
  91.     char *AddToPrivateSpace( const char *str );
  92.     void GrabSettings();
  93.  
  94.       public:
  95.     ExtrasSet();
  96.     ExtrasSet( char const ** extras );
  97.     ExtrasSet( char ** extras );
  98.     ExtrasSet( const StoredObjectSet::Object &obj );
  99.     ExtrasSet( const ExtrasSet © );
  100.  
  101.     void Set( const char *var, const char *val );
  102.     void SetVolatileValue( const char *var, const char *val );
  103.     const char *Get( const char *var ) const;
  104.  
  105.     operator char const **() const;
  106.     ~ExtrasSet();
  107. };
  108.  
  109. #endif
  110.