diff options
Diffstat (limited to 'src/outputgen.h')
-rw-r--r-- | src/outputgen.h | 171 |
1 files changed, 85 insertions, 86 deletions
diff --git a/src/outputgen.h b/src/outputgen.h index 576e950..0d64833 100644 --- a/src/outputgen.h +++ b/src/outputgen.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -18,7 +18,10 @@ #ifndef OUTPUTGEN_H #define OUTPUTGEN_H -#include <qstack.h> +#include <memory> +#include <stack> + +#include <qfile.h> #include "index.h" #include "section.h" @@ -33,9 +36,7 @@ class DotGfxHierarchyTable; class DotGroupCollaboration; class DocNode; class MemberDef; -class GroupDef; class Definition; -class QFile; struct DocLinkInfo { @@ -54,15 +55,18 @@ struct SourceLinkInfo QCString anchor; }; -/** Output interface for code parser. +/** Output interface for code parser. */ class CodeOutputInterface { public: virtual ~CodeOutputInterface() {} - /*! Writes an code fragment to the output. This function should keep - * spaces visible, should break lines at a newline and should convert + /** Identifier for the output file */ + virtual int id() const { return 0; } + + /*! Writes an code fragment to the output. This function should keep + * spaces visible, should break lines at a newline and should convert * tabs to the right number of spaces. */ virtual void codify(const char *s) = 0; @@ -71,8 +75,8 @@ class CodeOutputInterface * \param ref If this is non-zero, the object is to be found in * an external documentation file. * \param file The file in which the object is located. - * \param anchor The anchor uniquely identifying the object within - * the file. + * \param anchor The anchor uniquely identifying the object within + * the file. * \param name The text to display as a placeholder for the link. * \param tooltip The tooltip to display when the mouse is on the link. */ @@ -89,7 +93,7 @@ class CodeOutputInterface virtual void writeLineNumber(const char *ref,const char *file, const char *anchor,int lineNumber) = 0; - /*! Writes a tool tip definition + /*! Writes a tool tip definition * \param id unique identifier for the tooltip * \param docInfo Info about the symbol's documentation. * \param decl full declaration of the symbol (for functions) @@ -97,14 +101,14 @@ class CodeOutputInterface * \param defInfo Info about the symbol's definition in the source code * \param declInfo Info about the symbol's declaration in the source code */ - virtual void writeTooltip(const char *id, + virtual void writeTooltip(const char *id, const DocLinkInfo &docInfo, const char *decl, const char *desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo ) = 0; - + virtual void startCodeLine(bool hasLineNumbers) = 0; /*! Ends a line of code started with startCodeLine() */ @@ -126,6 +130,16 @@ class CodeOutputInterface virtual void setCurrentDoc(const Definition *context,const char *anchor,bool isSourceFile) = 0; virtual void addWord(const char *word,bool hiPriority) = 0; + + /*! Starts a source code fragment. The fragment will be + * fed to the code parser (see code.h) for syntax highlighting + * and cross-referencing. The fragment ends by a call to + * endCodeFragment() + * @param style The kind of code fragment. + */ + virtual void startCodeFragment(const char *style) = 0; + /*! Ends a block of code */ + virtual void endCodeFragment(const char *style) = 0; }; /** Base Interface used for generating output outside of the @@ -141,29 +155,29 @@ class BaseOutputDocInterface : public CodeOutputInterface public: virtual ~BaseOutputDocInterface() {} enum ParamListTypes { Param, RetVal, Exception }; - enum SectionTypes { /*See, Return, Author, Version, + enum SectionTypes { /*See, Return, Author, Version, Since, Date, Bug, Note, - Warning, Par, Deprecated, Pre, - Post, Invar, Remark, Attention, + Warning, Par, Deprecated, Pre, + Post, Invar, Remark, Attention, Todo, Test, RCS, */ - EnumValues, - Examples + EnumValues, + Examples }; - virtual void parseText(const QCString &s) {} - + virtual void parseText(const QCString &) {} + /*! Start of a bullet list: e.g. \c \<ul\> in html. startItemListItem() is * Used for the bullet items. */ virtual void startItemList() = 0; - /*! Writes a list item for a bullet or enumerated - * list: e.g. \c \<li\> in html + /*! Writes a list item for a bullet or enumerated + * list: e.g. \c \<li\> in html */ virtual void startItemListItem() = 0; - /*! Writes a list item for a bullet or enumerated - * list: e.g. \c \</li\> in html + /*! Writes a list item for a bullet or enumerated + * list: e.g. \c \</li\> in html */ virtual void endItemListItem() = 0; @@ -171,7 +185,7 @@ class BaseOutputDocInterface : public CodeOutputInterface virtual void endItemList() = 0; /*! Writes an ASCII string to the output. Converts characters that have - * A special meaning, like \c & in html. + * A special meaning, like \c & in html. */ virtual void docify(const char *s) = 0; @@ -180,8 +194,8 @@ class BaseOutputDocInterface : public CodeOutputInterface */ virtual void writeChar(char c) = 0; - /*! Writes an ASCII string to the output, \e without converting - * special characters. + /*! Writes an ASCII string to the output, \e without converting + * special characters. */ virtual void writeString(const char *text) = 0; @@ -197,8 +211,8 @@ class BaseOutputDocInterface : public CodeOutputInterface * \param ref If this is non-zero, the object is to be found in * an external documentation file. * \param file The file in which the object is located. - * \param anchor The anchor uniquely identifying the object within - * the file. + * \param anchor The anchor uniquely identifying the object within + * the file. * \param name The text to display as a placeholder for the link. */ virtual void writeObjectLink(const char *ref,const char *file, @@ -214,7 +228,7 @@ class BaseOutputDocInterface : public CodeOutputInterface */ virtual void endHtmlLink() = 0; - + /*! Changes the text font to bold face. The bold section ends with * endBold() */ @@ -239,24 +253,10 @@ class BaseOutputDocInterface : public CodeOutputInterface /*! Ends a section of text displayed in italic. */ virtual void endEmphasis() = 0; - /*! Starts a source code fragment. The fragment will be - * fed to the code parser (see code.h) for syntax highlighting - * and cross-referencing. The fragment ends by a call to - * endCodeFragment() - */ - virtual void startCodeFragment() = 0; - - /*! Ends a source code fragment - */ - virtual void endCodeFragment() = 0; - - - - /*! Writes a horizontal ruler to the output */ virtual void writeRuler() = 0; - - /*! Starts a description list: e.g. \c \<dl\> in HTML + + /*! Starts a description list: e.g. \c \<dl\> in HTML * Items are surrounded by startDescItem() and endDescItem() */ virtual void startDescription() = 0; @@ -270,8 +270,8 @@ class BaseOutputDocInterface : public CodeOutputInterface virtual void startDescForItem() = 0; virtual void endDescForItem() = 0; - /*! Ends an item of a description list and starts the - * description itself: e.g. \c \</dt\> in HTML. + /*! Ends an item of a description list and starts the + * description itself: e.g. \c \</dt\> in HTML. */ virtual void endDescItem() = 0; @@ -290,8 +290,8 @@ class BaseOutputDocInterface : public CodeOutputInterface virtual void endTitle() = 0; virtual void writeAnchor(const char *fileName,const char *name) = 0; - virtual void startSection(const char *,const char *,SectionInfo::SectionType) = 0; - virtual void endSection(const char *,SectionInfo::SectionType) = 0; + virtual void startSection(const char *,const char *,SectionType) = 0; + virtual void endSection(const char *,SectionType) = 0; virtual void lineBreak(const char *style) = 0; virtual void addIndexItem(const char *s1,const char *s2) = 0; @@ -324,19 +324,27 @@ class OutputGenerator : public BaseOutputDocInterface public: enum OutputType { Html, Latex, Man, RTF, XML, DEF, Perl , Docbook}; - OutputGenerator(); + OutputGenerator(const char *dir); + OutputGenerator(const OutputGenerator &o); + OutputGenerator &operator=(const OutputGenerator &o); virtual ~OutputGenerator(); + virtual OutputType type() const = 0; + virtual std::unique_ptr<OutputGenerator> clone() const = 0; + /////////////////////////////////////////////////////////////// // generic generator methods /////////////////////////////////////////////////////////////// - virtual void enable() = 0; - virtual void disable() = 0; - virtual void enableIf(OutputType o) = 0; - virtual void disableIf(OutputType o) = 0; - virtual void disableIfNot(OutputType o) = 0; - virtual bool isEnabled(OutputType o) = 0; - virtual OutputGenerator *get(OutputType o) = 0; + void enable(); + void disable(); + void enableIf(OutputType o); + void disableIf(OutputType o); + void disableIfNot(OutputType o); + bool isEnabled(OutputType o); + OutputGenerator *get(OutputType o); + QCString dir() const; + QCString fileName() const; + void startPlainFile(const char *name); void endPlainFile(); //QCString getContents() const; @@ -346,13 +354,13 @@ class OutputGenerator : public BaseOutputDocInterface //void setEncoding(const QCString &enc) { encoding = enc; } //virtual void postProcess(QByteArray &) { } - virtual void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md) = 0; + virtual void writeDoc(DocNode *,const Definition *ctx,const MemberDef *md,int id) = 0; /////////////////////////////////////////////////////////////// // structural output interface /////////////////////////////////////////////////////////////// virtual void startFile(const char *name,const char *manName, - const char *title) = 0; + const char *title,int id=0) = 0; virtual void writeSearchInfo() = 0; virtual void writeFooter(const char *navPath) = 0; virtual void endFile() = 0; @@ -447,8 +455,8 @@ class OutputGenerator : public BaseOutputDocInterface virtual void writeSummaryLink(const char *file,const char *anchor,const char *title,bool first) = 0; virtual void startContents() = 0; virtual void endContents() = 0; - virtual void startPageDoc(const char *pageTitle) {}; - virtual void endPageDoc() {}; + virtual void startPageDoc(const char *) {} + virtual void endPageDoc() {} virtual void startTextBlock(bool) = 0; virtual void endTextBlock(bool) = 0; virtual void lastIndexPage() = 0; @@ -489,21 +497,18 @@ class OutputGenerator : public BaseOutputDocInterface protected: FTextStream t; - QFile *m_file; - QCString m_fileName; - QCString m_dir; - bool m_active; - QStack<bool> *m_genStack; - private: - OutputGenerator(const OutputGenerator &o); - OutputGenerator &operator=(const OutputGenerator &o); + QCString m_dir; + QCString m_fileName; + QFile m_file; + bool m_active = true; + std::stack<bool> m_genStack; }; /** Interface used for generating documentation. * * This abstract class is used by several functions - * to generate the output for a specific format. + * to generate the output for a specific format. * This interface contains some state saving and changing * functions for dealing with format specific output. */ @@ -512,18 +517,13 @@ class OutputDocInterface : public BaseOutputDocInterface public: virtual ~OutputDocInterface() {} - /*! Create a new output generator. This can later by appended - * to the current one using append(). - */ - //virtual OutputDocInterface *clone() = 0; - - /*! Disables all output formats except format \a o - * (useful for OutputList only) + /*! Disables all output formats except format \a o + * (useful for OutputList only) */ virtual void disableAllBut(OutputGenerator::OutputType o) = 0; /*! Enables all output formats as far as they have been enabled in - * the config file. (useful for OutputList only) + * the config file. (useful for OutputList only) */ virtual void enableAll() = 0; @@ -536,27 +536,26 @@ class OutputDocInterface : public BaseOutputDocInterface /*! Enables a specific output format (useful for OutputList only) */ virtual void enable(OutputGenerator::OutputType o) = 0; - /*! Check whether a specific output format is currently enabled - * (useful for OutputList only) + /*! Check whether a specific output format is currently enabled + * (useful for OutputList only) */ virtual bool isEnabled(OutputGenerator::OutputType o) = 0; /*! Appends the output generated by generator \a g to this * generator. - */ + */ //virtual void append(const OutputDocInterface *g) = 0; - /*! Pushes the state of the current generator (or list of + /*! Pushes the state of the current generator (or list of * generators) on a stack. */ virtual void pushGeneratorState() = 0; - /*! Pops the state of the current generator (or list of + /*! Pops the state of the current generator (or list of * generators) on a stack. Should be preceded by a call * the pushGeneratorState(). */ virtual void popGeneratorState() = 0; }; - #endif |