parserintf.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * $Id: parserintf.h,v 1.15 2001/03/19 19:27:41 root Exp $
00004  *
00005  * Copyright (C) 1997-2008 by Dimitri van Heesch.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and its
00008  * documentation under the terms of the GNU General Public License is hereby 
00009  * granted. No representations are made about the suitability of this software 
00010  * for any purpose. It is provided "as is" without express or implied warranty.
00011  * See the GNU General Public License for more details.
00012  *
00013  * Documents produced by Doxygen are derivative works derived from the
00014  * input used in their production; they are not affected by this license.
00015  *
00016  */
00017 
00018 #ifndef PARSERINTF_H
00019 #define PARSERINTF_H
00020 
00021 #include <qdict.h>
00022 
00023 class Entry;
00024 class FileDef;
00025 class CodeOutputInterface;
00026 class MemberDef;
00027 
00034 class ParserInterface
00035 {
00036   public:
00037     virtual ~ParserInterface() {}
00044     virtual void parseInput(const char *fileName,
00045                             const char *fileBuf,
00046                             Entry *root) = 0;
00047 
00053     virtual bool needsPreprocessing(const QCString &extension) = 0;
00054     
00072     virtual void parseCode(CodeOutputInterface &codeOutIntf,
00073                            const char *scopeName,
00074                            const QCString &input,
00075                            bool isExampleBlock,
00076                            const char *exampleName=0,
00077                            FileDef *fileDef=0,
00078                            int startLine=-1,
00079                            int endLine=-1,
00080                            bool inlineFragment=FALSE,
00081                            MemberDef *memberDef=0
00082                           ) = 0;
00083 
00089     virtual void resetCodeParserState() = 0;
00090 
00097     virtual void parsePrototype(const char *text) = 0;
00098 
00099 };
00100 
00101 //-----------------------------------------------------------------------------
00102 
00108 class ParserManager
00109 {
00110   public:
00116     ParserManager(ParserInterface *defaultParser)
00117       : m_defaultParser(defaultParser) { m_parsers.setAutoDelete(TRUE); }
00118 
00125     void registerParser(const char *extension,ParserInterface *parser)
00126     {
00127       m_parsers.insert(extension,parser);
00128     }
00129 
00134     ParserInterface *getParser(const char *extension)
00135     {
00136       if (extension==0) return m_defaultParser;
00137       QCString ext = QCString(extension).lower();
00138       ParserInterface *intf = m_parsers.find(ext);
00139       if (intf==0 && ext.length()>4)
00140       {
00141         intf = m_parsers.find(ext.left(4));
00142       }
00143       return intf ? intf : m_defaultParser;
00144     }
00145 
00146   private:
00147     QDict<ParserInterface> m_parsers;
00148     ParserInterface *m_defaultParser;
00149 };
00150 
00151 #endif



Generated on Mon Mar 31 10:58:41 2008 by  doxygen 1.5.1