home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / utils / HelpGen / src / docripper.h < prev    next >
C/C++ Source or Header  |  1999-09-13  |  4KB  |  157 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name:        No names yet.
  3. // Purpose:     Contrib. demo
  4. // Author:      Aleksandras Gluchovas
  5. // Modified by:
  6. // Created:     22/09/98
  7. // RCS-ID:      $Id: docripper.h,v 1.1 1999/09/13 14:29:40 JS Exp $
  8. // Copyright:   (c) Aleskandars Gluchovas
  9. // Licence:       wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef __DOCRIPPER_G__
  13. #define __DOCRIPPER_G__
  14.  
  15. #include "scriptbinder.h"
  16. #include "srcparser.h"
  17. #include "sourcepainter.h"
  18.  
  19. #if defined( wxUSE_TEMPLATE_STL )
  20.         
  21.     #include <vector>
  22.  
  23.     typedef vector<ScriptTemplate*> STemplateListT;
  24.  
  25. #else
  26.  
  27.     #include "wxstlvec.h"
  28.  
  29.     typedef ScriptTemplate* ScriptTemplatePtrT; 
  30.     typedef WXSTL_VECTOR_SHALLOW_COPY(ScriptTemplatePtrT) STemplateListT;
  31.  
  32. #endif
  33.  
  34.  
  35. // specific DocGenerator class for "Ripper", 
  36. // also acts as source code visitor
  37.  
  38. class RipperDocGen : public DocGeneratorBase, public spVisitor
  39. {
  40. protected:
  41.     // templates for various sections
  42.     ScriptTemplate mTopTempl;
  43.     ScriptTemplate mContentIdxTempl;
  44.     ScriptTemplate mSuperContentTempl;
  45.     ScriptTemplate mSubContentTempl;
  46.     ScriptTemplate mOutLineTempl;
  47.     ScriptTemplate mOutLine1Templ;
  48.  
  49.     // template used for corss-references
  50.     ScriptTemplate mRefTempl;
  51.  
  52.     // template used to show not-existing sections
  53.     ScriptTemplate mDeadRefTempl;
  54.  
  55.     // template collection for generation of class-tree
  56.     STemplateListT mTreeTemplates;
  57.  
  58.     // pointers to all major index sections
  59.     ScriptSection* mpTopIdx;
  60.     ScriptSection* mpClassIdx;
  61.     ScriptSection* mpEnumIdx;
  62.     ScriptSection* mpTypeDefIdx;
  63.     ScriptSection* mpMacroIdx;
  64.     ScriptSection* mpGlobalVarsIdx;
  65.     ScriptSection* mpGlobalFuncIdx;
  66.     ScriptSection* mpConstIdx;
  67.  
  68.     // parser set up from user-code for sepcific language
  69.     SourceParserBase* mpParser;
  70.  
  71.     // class section, which is currently being
  72.     // assembled
  73.     ScriptSection*    mpCurClassSect;
  74.     
  75.     // source syntax heighlighter object
  76.     SourcePainter  mSrcPainter;
  77.  
  78.     // context, to which all file contexts
  79.     // are assembled
  80.     spContext*     mpFileBinderCtx;
  81.  
  82.     // script tags set up from usesr code
  83.     MarkupTagsT    mTags;
  84.  
  85. protected:
  86.     // helpers
  87.     void AppendComments( spContext& fromContext, string& str );
  88.  
  89.     void AppendMulitilineStr( string& st, string& mlStr );
  90.  
  91.     void AppendHighlightedSource( string& st, string source );
  92.  
  93.     // returns TRUE, if no comments found in the context,
  94.     // plus, creates dummy(empty) section, and puts a 
  95.     // reference woth "dead-link" template to it in the 
  96.     // given index-section "toSect"
  97.  
  98.     bool CheckIfUncommented( spContext& ctx, ScriptSection& toSect );
  99.  
  100.     // checks if context has any comments, then returns
  101.     // template of normal reference, otherwise of dead reference
  102.  
  103.     ScriptTemplate* GetRefTemplFor( spContext& ctx );
  104.  
  105.     // adds "someClass::" perfix to the context name,
  106.     // if it's not in the file scope (i.e. if it's not global)
  107.  
  108.     string GetScopedName( spContext& ofCtx );
  109.  
  110.     // adds section to currently assembled class section
  111.     // and places references to it from "public", "protected"
  112.     // or "private" indexing-subsections of the class, depending
  113.     // on the visibility of the context
  114.  
  115.     void AddToCurrentClass( ScriptSection* pSection, spContext& ctx, 
  116.                             const char* subSectionName );
  117.  
  118.     // called, after all files are processed, to
  119.     // resolve possible super/derived class relations,
  120.     // and put cross references to them - where resolution was
  121.     // successful
  122.     void LinkSuperClassRefs();
  123.  
  124.     // implementations of "visiting procedures", declared in spVisitor
  125.  
  126.     virtual void VisitClass( spClass& cl );
  127.     virtual void VisitEnumeration( spEnumeration& en );
  128.     virtual void VisitTypeDef( spTypeDef& td );
  129.     virtual void VisitPreprocessorLine( spPreprocessorLine& pd );
  130.     virtual void VisitAttribute( spAttribute& attr );
  131.     virtual void VisitOperation( spOperation& op );
  132.  
  133.     // overriden member of DocGernatorBase
  134.  
  135.     virtual bool OnSaveDocument( ScriptStream& stm );
  136.  
  137.     virtual ScriptSection* GetTopSection() 
  138.         { return mpTopIdx; }
  139.  
  140. public:
  141.     RipperDocGen();
  142.     ~RipperDocGen();
  143.  
  144.     // should be called onece to set user-code provided,
  145.     // parser for specific source code language
  146.     // (NOTE:: it's the user-code's responsibility to
  147.     //  relseas memory of pParser)
  148.  
  149.     void Init( SourceParserBase* pParser );
  150.     
  151.     // should be called on each file
  152.     
  153.     void ProcessFile( const char* sourceFile );
  154. };
  155.  
  156.  
  157. #endif