diff options
Diffstat (limited to 'trunk/addon')
66 files changed, 13843 insertions, 0 deletions
diff --git a/trunk/addon/doxmlparser/Doxyfile b/trunk/addon/doxmlparser/Doxyfile new file mode 100644 index 0000000..faf4bee --- /dev/null +++ b/trunk/addon/doxmlparser/Doxyfile @@ -0,0 +1,177 @@ +# Doxyfile 1.2.12-20011209 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = doxmlparser +PROJECT_NUMBER = +OUTPUT_DIRECTORY = doc +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +ALIASES = +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = include +FILE_PATTERNS = *.h +RECURSIVE = NO +EXCLUDE = +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = +MAN_EXTENSION = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = ../../qtools_docs/qtools.tag=../../../../qtools_docs/html +GENERATE_TAGFILE = +ALLEXTERNALS = NO +PERL_PATH = +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1280 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = +EXT_DOC_PATHS = diff --git a/trunk/addon/doxmlparser/Doxyfile.impl b/trunk/addon/doxmlparser/Doxyfile.impl new file mode 100644 index 0000000..a954db3 --- /dev/null +++ b/trunk/addon/doxmlparser/Doxyfile.impl @@ -0,0 +1,179 @@ +# Doxyfile 1.2.13.1 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = doxmlparser +PROJECT_NUMBER = +OUTPUT_DIRECTORY = doc_impl +OUTPUT_LANGUAGE = English +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +SHORT_NAMES = NO +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +ALIASES = +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +OPTIMIZE_OUTPUT_FOR_C = NO +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = src +FILE_PATTERNS = +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = +MAN_EXTENSION = +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = DEFINE_CLS_IMPL +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = ../../qtools_docs/qtools.tag=../../../../qtools_docs/html +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +HIDE_UNDOC_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1280 +MAX_DOT_GRAPH_HEIGHT = 1024 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = +EXT_DOC_PATHS = diff --git a/trunk/addon/doxmlparser/examples/metrics/Makefile.in b/trunk/addon/doxmlparser/examples/metrics/Makefile.in new file mode 100644 index 0000000..83cbc28 --- /dev/null +++ b/trunk/addon/doxmlparser/examples/metrics/Makefile.in @@ -0,0 +1,13 @@ +all clean depend: Makefile.metrics + $(MAKE) -f Makefile.metrics $@ + +distclean: clean + $(RM) -rf Makefile.metrics metrics.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) metrics.pro >Makefile.metrics + +Makefile.metrics: metrics.pro + $(ENV) $(PERL) $(TMAKE) metrics.pro >Makefile.metrics + +install: diff --git a/trunk/addon/doxmlparser/examples/metrics/main.cpp b/trunk/addon/doxmlparser/examples/metrics/main.cpp new file mode 100644 index 0000000..1328abe --- /dev/null +++ b/trunk/addon/doxmlparser/examples/metrics/main.cpp @@ -0,0 +1,254 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +/*! \mainpage Metrics + * This is a small example that shows how to use doxygen's XML output and + * the doxmlparser library. The example shows some very basic code metrics. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <doxmlintf.h> + +bool isDocumented(IDocRoot *brief,IDocRoot *detailed) +{ + bool found=false; + if (brief) + { + IDocIterator *docIt = brief->contents(); + if (docIt->current()) // method has brief description + { + found=true; + } + docIt->release(); + } + if (detailed && !found) + { + IDocIterator *docIt = detailed->contents(); + if (docIt->current()) + { + found=true; + } + docIt->release(); + } + return found; +} + +int main(int argc,char **argv) +{ + if (argc!=2) + { + printf("Usage: %s xml_output_dir\n",argv[0]); + exit(1); + } + + int numClasses=0; + int numDocClasses=0; + int numStructs=0; + int numUnions=0; + int numInterfaces=0; + int numExceptions=0; + int numNamespaces=0; + int numFiles=0; + int numGroups=0; + int numPages=0; + int numPackages=0; + int numPubMethods=0; + int numProMethods=0; + int numPriMethods=0; + int numDocPubMethods=0; + int numDocProMethods=0; + int numDocPriMethods=0; + int numFunctions=0; + int numAttributes=0; + int numVariables=0; + int numDocFunctions=0; + int numDocAttributes=0; + int numDocVariables=0; + int numParams=0; + + IDoxygen *dox = createObjectModel(); + + dox->setDebugLevel(0); + + if (!dox->readXMLDir(argv[1])) + { + printf("Error reading %s/index.xml\n",argv[1]); + exit(1); + } + + ICompoundIterator *cli = dox->compounds(); + ICompound *comp; + for (cli->toFirst();(comp=cli->current());cli->toNext()) + { + printf("Processing %s...\n",comp->name()->latin1()); + bool hasDocs = isDocumented(comp->briefDescription(),comp->detailedDescription()); + switch (comp->kind()) + { + case ICompound::Class: + numClasses++; + if (hasDocs) numDocClasses++; + break; + case ICompound::Struct: numStructs++; break; + case ICompound::Union: numUnions++; break; + case ICompound::Interface: numInterfaces++; break; + case ICompound::Exception: numExceptions++; break; + case ICompound::Namespace: numNamespaces++; break; + case ICompound::File: numFiles++; break; + case ICompound::Group: numGroups++; break; + case ICompound::Page: numPages++; break; + default: break; + } + + ISectionIterator *sli = comp->sections(); + ISection *sec; + for (sli->toFirst();(sec=sli->current());sli->toNext()) + { + IMemberIterator *mli = sec->members(); + IMember *mem; + for (mli->toFirst();(mem=mli->current());mli->toNext()) + { + IParamIterator *pli = mem->parameters(); + IParam *par; + if (comp->kind()==ICompound::Class || + comp->kind()==ICompound::Struct || + comp->kind()==ICompound::Interface + ) + { + if (mem->kind()==IMember::Function || + mem->kind()==IMember::Prototype || + mem->kind()==IMember::Signal || + mem->kind()==IMember::Slot || + mem->kind()==IMember::DCOP + ) // is a "method" + { + if (mem->section()->isPublic()) + { + numPubMethods++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocPubMethods++; + } + } + else if (mem->section()->isProtected()) + { + numProMethods++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocProMethods++; + } + } + else if (mem->section()->isPrivate()) + { + numPriMethods++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocPriMethods++; + } + } + } + else if (mem->kind()==IMember::Variable || + mem->kind()==IMember::Property + ) // is an "attribute" + { + numAttributes++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocAttributes++; + } + } + } + else if (comp->kind()==ICompound::File || + comp->kind()==ICompound::Namespace + ) + { + if (mem->kind()==IMember::Function || + mem->kind()==IMember::Prototype || + mem->kind()==IMember::Signal || + mem->kind()==IMember::Slot || + mem->kind()==IMember::DCOP + ) // is a "method" + { + numFunctions++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocFunctions++; + } + } + else if (mem->kind()==IMember::Variable || + mem->kind()==IMember::Property + ) // is an "attribute" + { + numVariables++; + if (isDocumented(mem->briefDescription(),mem->detailedDescription())) + { + numDocVariables++; + } + } + } + + for (pli->toFirst();(par=pli->current());pli->toNext()) + { + numParams++; + } + const char *type = mem->typeString()->latin1(); + if (type && strcmp(type, "void")) + { + numParams++; // count non-void return types as well + } + pli->release(); + } + mli->release(); + } + sli->release(); + + comp->release(); + } + cli->release(); + + dox->release(); + + int numMethods = numPubMethods+numProMethods+numPriMethods; + int numDocMethods = numDocPubMethods+numDocProMethods+numDocPriMethods; + + printf("Metrics:\n"); + printf("-----------------------------------\n"); + if (numClasses>0) printf("Classes: %10d (%d documented)\n",numClasses,numDocClasses); + if (numStructs>0) printf("Structs: %10d\n",numStructs); + if (numUnions>0) printf("Unions: %10d\n",numUnions); + if (numInterfaces>0) printf("Interfaces: %10d\n",numInterfaces); + if (numExceptions>0) printf("Exceptions: %10d\n",numExceptions); + if (numNamespaces>0) printf("Namespaces: %10d\n",numNamespaces); + if (numFiles>0) printf("Files: %10d\n",numFiles); + if (numGroups>0) printf("Groups: %10d\n",numGroups); + if (numPages>0) printf("Pages: %10d\n",numPages); + if (numPackages>0) printf("Packages: %10d\n",numPackages); + if (numMethods>0) printf("Methods: %10d (%d documented)\n",numMethods,numDocMethods); + if (numPubMethods>0) printf(" Public: %10d (%d documented)\n",numPubMethods,numDocPubMethods); + if (numProMethods>0) printf(" Protected: %10d (%d documented)\n",numProMethods,numDocProMethods); + if (numPriMethods>0) printf(" Private: %10d (%d documented)\n",numPriMethods,numDocPriMethods); + if (numFunctions>0) printf("Functions: %10d (%d documented)\n",numFunctions,numDocFunctions); + if (numAttributes>0) printf("Attributes: %10d (%d documented)\n",numAttributes,numDocAttributes); + if (numVariables>0) printf("Variables: %10d (%d documented)\n",numVariables,numDocVariables); + if (numParams>0) printf("Params: %10d\n",numParams); + printf("-----------------------------------\n"); + if (numClasses>0) printf("Avg. #methods/compound: %10f\n",(double)numMethods/(double)numClasses); + if (numMethods>0) printf("Avg. #params/method: %10f\n",(double)numParams/(double)numMethods); + printf("-----------------------------------\n"); + + return 0; +} + diff --git a/trunk/addon/doxmlparser/examples/metrics/metrics.pro.in b/trunk/addon/doxmlparser/examples/metrics/metrics.pro.in new file mode 100644 index 0000000..6dd344f --- /dev/null +++ b/trunk/addon/doxmlparser/examples/metrics/metrics.pro.in @@ -0,0 +1,20 @@ +TEMPLATE = app.t +CONFIG = console warn_on $extraopts +HEADERS = +SOURCES = main.cpp +unix:LIBS += -L../../../../lib -L../../lib -ldoxmlparser -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../../../lib -L../../lib -ldoxmlparser -lqtools +win32-msvc:LIBS += doxmlparser.lib qtools.lib shell32.lib +win32-msvc:TMAKE_LFLAGS += /LIBPATH:..\..\..\..\lib;..\..\lib +win32-borland:LIBS += doxmlparser.lib qtools.lib shell32.lib +win32-borland:TMAKE_LFLAGS += -L..\..\..\..\lib -L..\..\lib +win32:TMAKE_CXXFLAGS += -DQT_NODLL +DESTDIR = +OBJECTS_DIR = obj +TARGET = metrics +DEPENDPATH = ../../include +INCLUDEPATH += ../../../../qtools ../../include +unix:TARGETDEPS = ../../lib/libdoxmlparser.a +win32:TARGETDEPS = ..\..\lib\doxmlparser.lib + diff --git a/trunk/addon/doxmlparser/include/doxmlintf.h b/trunk/addon/doxmlparser/include/doxmlintf.h new file mode 100644 index 0000000..88cb2e3 --- /dev/null +++ b/trunk/addon/doxmlparser/include/doxmlintf.h @@ -0,0 +1,1134 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _DOXMLINTF_H +#define _DOXMLINTF_H + +/*! \file + * \brief The interface to the object model provided by the XML parser + * library. + * + * To start using this library one calls createObjectModel() and then + * uses the returned IDoxygen interface to read doxygen generated + * XML output and navigate through the information contained in it. + * + * @see createObjectModel() + */ + +class IMember; +class IDocIterator; +class ICompound; +class ISection; +class INode; +class IDocInternal; +class IDocRoot; + +#define VIRTUAL_DESTRUCTOR(x) virtual ~x() {} + +/*! \brief Read only interface to a string. + */ +class IString +{ + public: + VIRTUAL_DESTRUCTOR(IString) + /*! Returns a latin1 character representation of the string. */ + virtual const char *latin1() const = 0; + /*! Returns a utf8 character representation of the string. */ + virtual const char *utf8() const = 0; + /*! Returns a 16-bit unicode character representation of the character at + * position \a index in the string. The first character is at index 0. + */ + virtual unsigned short unicodeCharAt(int index) const = 0; + /*! Returns true if this string is empty or false otherwise */ + virtual bool isEmpty() const = 0; + /*! Returns the number of characters in the string. */ + virtual int length() const = 0; +}; + +/*! \brief Base interface for hyperlinked text + * + * Depending on the result of kind() the interface is extended by + * ILT_Text or ILT_Ref. + */ +class ILinkedText +{ + public: + VIRTUAL_DESTRUCTOR(ILinkedText) + enum Kind { Kind_Text, Kind_Ref }; + virtual Kind kind() const = 0; +}; + +/*! \brief Plain text fragment. + */ +class ILT_Text : public ILinkedText +{ + public: + VIRTUAL_DESTRUCTOR(ILT_Text) + virtual const IString *text() const = 0; +}; + +/*! \brief Reference to an object. + */ +class ILT_Ref : public ILinkedText +{ + public: + VIRTUAL_DESTRUCTOR(ILT_Ref) + enum TargetKind { Member, Compound }; + virtual const IString *id() const = 0; + virtual TargetKind targetKind() const = 0; + virtual const IString *external() const = 0; + virtual const IString *text() const = 0; +}; + +/*! \brief Iterates over a list of ILinkedText fragments. + */ +class ILinkedTextIterator +{ + public: + VIRTUAL_DESTRUCTOR(ILinkedTextIterator) + virtual ILinkedText *toFirst() = 0; + virtual ILinkedText *toLast() = 0; + virtual ILinkedText *toNext() = 0; + virtual ILinkedText *toPrev() = 0; + virtual ILinkedText *current() const = 0; + virtual void release() = 0; +}; + +/*! \brief Representation of a parameter of a function. */ +class IParam +{ + public: + VIRTUAL_DESTRUCTOR(IParam) + virtual ILinkedTextIterator *type() const = 0; + virtual const IString * declarationName() const = 0; + virtual const IString * definitionName() const = 0; + virtual const IString * attrib() const = 0; + virtual const IString * arraySpecifier() const = 0; + virtual ILinkedTextIterator *defaultValue() const = 0; + virtual IDocRoot *briefDescription() const = 0; +}; + +class IParamIterator +{ + public: + VIRTUAL_DESTRUCTOR(IParamIterator) + virtual IParam *toFirst() = 0; + virtual IParam *toLast() = 0; + virtual IParam *toNext() = 0; + virtual IParam *toPrev() = 0; + virtual IParam *current() const = 0; + virtual void release() = 0; +}; + +class IMemberReference +{ + public: + VIRTUAL_DESTRUCTOR(IMemberReference) + virtual IMember *member() const = 0; + virtual const IString * name() const = 0; + virtual const IString * scope() const = 0; + virtual const IString * protection() const = 0; + virtual const IString * virtualness() const = 0; + virtual const IString * ambiguityScope() const = 0; +}; + +class IMemberReferenceIterator +{ + public: + VIRTUAL_DESTRUCTOR(IMemberReferenceIterator) + virtual IMemberReference *toFirst() = 0; + virtual IMemberReference *toLast() = 0; + virtual IMemberReference *toNext() = 0; + virtual IMemberReference *toPrev() = 0; + virtual IMemberReference *current() const = 0; + virtual void release() = 0; +}; + +class IDoc +{ + public: + VIRTUAL_DESTRUCTOR(IDoc) + enum Kind + { + Invalid = 0, // 0 + Para, // 1 -> IDocPara + Text, // 2 -> IDocText + MarkupModifier, // 3 -> IDocMarkupModifier + ItemizedList, // 4 -> IDocItemizedList + OrderedList, // 5 -> IDocOrderedList + ListItem, // 6 -> IDocListItem + ParameterList, // 7 -> IDocParameterList + Parameter, // 8 -> IDocParameter + SimpleSect, // 9 -> IDocSimpleSect + Title, // 10 -> IDocTitle + Ref, // 11 -> IDocRef + VariableList, // 12 -> IDocVariableList + VariableListEntry, // 13 -> IDocVariableListEntry + HRuler, // 14 -> IDocHRuler + LineBreak, // 15 -> IDocLineBreak + ULink, // 16 -> IDocULink + EMail, // 17 -> IDocEMail + Link, // 18 -> IDocLink + ProgramListing, // 19 -> IDocProgramListing + CodeLine, // 20 -> IDocCodeLine + Highlight, // 21 -> IDocHighlight + Formula, // 22 -> IDocFormula + Image, // 23 -> IDocImage + DotFile, // 24 -> IDocDotFile + IndexEntry, // 25 -> IDocIndexEntry + Table, // 26 -> IDocTable + Row, // 27 -> IDocRow + Entry, // 28 -> IDocEntry + Section, // 29 -> IDocSection + Verbatim, // 30 -> IDocVerbatim + Copy, // 31 -> IDocCopy + TocList, // 32 -> IDocTocList + TocItem, // 33 -> IDocTocItem + Anchor, // 34 -> IDocAnchor + Symbol, // 35 -> IDocSymbol + Internal, // 36 -> IDocInternal + Root, // 37 -> IDocRoot + ParameterItem // 38 -> IDocParameterItem + }; + virtual Kind kind() const = 0; +}; + +class IDocMarkup : public IDoc +{ + public: + enum Markup + { + Normal = 0x000, + Bold = 0x001, + Emphasis = 0x002, + ComputerOutput = 0x004, + Subscript = 0x008, + Superscript = 0x010, + SmallFont = 0x020, + Center = 0x040, + Preformatted = 0x080, + Heading = 0x100 + }; +}; + +class IDocPara : public IDoc +{ + public: + virtual IDocIterator *contents() const = 0; +}; + +class IDocText : public IDocMarkup +{ + public: + virtual const IString * text() const = 0; + virtual int markup() const = 0; + virtual int headingLevel() const = 0; +}; + +class IDocMarkupModifier : public IDoc +{ + public: + virtual bool enabled() const = 0; + virtual int markup() const = 0; + virtual int headingLevel() const = 0; +}; + +class IDocItemizedList : public IDoc +{ + public: + virtual IDocIterator *elements() const = 0; +}; + +class IDocOrderedList : public IDoc +{ + public: + virtual IDocIterator *elements() const = 0; +}; + +class IDocListItem : public IDoc +{ + public: + virtual IDocIterator *contents() const = 0; +}; + +class IDocParameterList : public IDoc +{ + public: + enum Types { Param, RetVal, Exception }; + virtual Types sectType() const = 0; + virtual IDocIterator *params() const = 0; +}; + +class IDocParameterItem : public IDoc +{ + public: + virtual IDocIterator *paramNames() const = 0; + virtual IDocPara *description() const = 0; +}; + +class IDocParameter : public IDoc +{ + public: + virtual const IString * name() const = 0; +}; + +class IDocTitle : public IDoc +{ + public: + virtual IDocIterator *title() const = 0; +}; + +class IDocSimpleSect : public IDoc +{ + public: + enum Types { Invalid = 0, + See, Return, Author, Version, + Since, Date, Bug, Note, + Warning, Par, Deprecated, Pre, + Post, Invar, Remark, Attention, + Todo, Test, RCS, EnumValues, + Examples + }; + virtual Types type() const = 0; + virtual const IString * typeString() const = 0; + virtual IDocTitle *title() const = 0; + virtual IDocPara *description() const = 0; +}; + +class IDocRef : public IDoc +{ + public: + enum TargetKind { Member, Compound }; + virtual const IString * refId() const = 0; + virtual TargetKind targetKind() const = 0; + virtual const IString * external() const = 0; + virtual const IString * text() const = 0; +}; + +class IDocVariableList : public IDoc +{ + public: + virtual IDocIterator *entries() const = 0; +}; + +class IDocVariableListEntry : public IDoc +{ + public: + virtual ILinkedTextIterator * term() const = 0; + virtual IDocPara *description() const = 0; +}; + +class IDocHRuler : public IDoc +{ +}; + +class IDocLineBreak : public IDoc +{ +}; + +class IDocULink : public IDoc +{ + public: + virtual const IString * url() const = 0; + virtual const IString * text() const = 0; +}; + +class IDocEMail : public IDoc +{ + public: + virtual const IString * address() const = 0; +}; + +class IDocLink : public IDoc +{ + public: + virtual const IString * refId() const = 0; + virtual const IString * text() const = 0; +}; + +class IDocProgramListing : public IDoc +{ + public: + virtual IDocIterator *codeLines() const = 0; +}; + +class IDocCodeLine : public IDoc +{ + public: + virtual int lineNumber() const = 0; + virtual const IString * refId() const = 0; + virtual IDocIterator *codeElements() const = 0; +}; + +class IDocHighlight : public IDoc +{ + public: + enum HighlightKind + { Invalid=0, + Comment, Keyword, + KeywordType, KeywordFlow, CharLiteral, + StringLiteral, Preprocessor + }; + virtual HighlightKind highlightKind() const = 0; + virtual IDocIterator *codeElements() const = 0; +}; + +class IDocFormula : public IDoc +{ + public: + virtual const IString * id() const = 0; + virtual const IString * text() const = 0; +}; + +class IDocImage : public IDoc +{ + public: + virtual const IString * name() const = 0; + virtual const IString * caption() const = 0; +}; + +class IDocDotFile : public IDoc +{ + public: + virtual const IString * name() const = 0; + virtual const IString * caption() const = 0; +}; + +class IDocIndexEntry : public IDoc +{ + public: + virtual const IString * primary() const = 0; + virtual const IString * secondary() const = 0; +}; + +class IDocTable : public IDoc +{ + public: + virtual IDocIterator *rows() const = 0; + virtual int numColumns() const = 0; + virtual const IString * caption() const = 0; +}; + +class IDocRow : public IDoc +{ + public: + virtual IDocIterator *entries() const = 0; +}; + +class IDocEntry : public IDoc +{ + public: + virtual IDocIterator *contents() const = 0; +}; + +class IDocSection : public IDoc +{ + public: + virtual const IString * id() const = 0; + virtual int level() const = 0; + virtual IDocTitle *title() const = 0; + virtual IDocIterator *paragraphs() const = 0; + virtual IDocIterator *subSections() const = 0; + virtual IDocInternal *internal() const = 0; +}; + +class IDocInternal : public IDoc +{ + public: + virtual IDocIterator *paragraphs() const = 0; + virtual IDocIterator *subSections() const = 0; +}; + +class IDocTocList : public IDoc +{ + public: + virtual IDocIterator *elements() const = 0; +}; + +class IDocTocItem : public IDoc +{ + public: + virtual const IString *id() const = 0; + virtual const IString *title() const = 0; +}; + +class IDocCopy : public IDoc +{ + public: + virtual IDocIterator *contents() const = 0; +}; + +class IDocVerbatim : public IDoc +{ + public: + enum Types { Invalid = 0, HtmlOnly, LatexOnly, Verbatim }; + virtual const IString *text() const = 0; + virtual Types type() const = 0; +}; + +class IDocAnchor : public IDoc +{ + public: + virtual const IString *id() const = 0; +}; + +class IDocSymbol : public IDoc +{ + public: + enum Types + { Invalid = 0, + Umlaut, Acute, Grave, Circ, Tilde, Szlig, Cedil, Ring, Nbsp, Copy + }; + virtual Types type() const = 0; + virtual const IString * typeString() const = 0; + virtual char letter() const = 0; +}; + +class IDocRoot : public IDoc +{ + public: + virtual IDocIterator *contents() const = 0; + virtual IDocInternal *internal() const = 0; +}; + +class IDocIterator +{ + public: + VIRTUAL_DESTRUCTOR(IDocIterator) + virtual IDoc *toFirst() = 0; + virtual IDoc *toLast() = 0; + virtual IDoc *toNext() = 0; + virtual IDoc *toPrev() = 0; + virtual IDoc *current() const = 0; + virtual void release() = 0; +}; + +class IEdgeLabel +{ + public: + VIRTUAL_DESTRUCTOR(IEdgeLabel) + virtual const IString * label() const = 0; +}; + +class IEdgeLabelIterator +{ + public: + VIRTUAL_DESTRUCTOR(IEdgeLabelIterator) + virtual IEdgeLabel *toFirst() = 0; + virtual IEdgeLabel *toLast() = 0; + virtual IEdgeLabel *toNext() = 0; + virtual IEdgeLabel *toPrev() = 0; + virtual IEdgeLabel *current() const = 0; + virtual void release() = 0; +}; + +class IChildNode +{ + public: + VIRTUAL_DESTRUCTOR(IChildNode) + enum NodeRelation { PublicInheritance, ProtectedInheritance, + PrivateInheritance, Usage, TemplateInstance + }; + virtual INode * node() const = 0; + virtual NodeRelation relation() const = 0; + virtual const IString * relationString() const = 0; + virtual IEdgeLabelIterator *edgeLabels() const = 0; +}; + +class IChildNodeIterator +{ + public: + VIRTUAL_DESTRUCTOR(IChildNodeIterator) + virtual IChildNode *toFirst() = 0; + virtual IChildNode *toLast() = 0; + virtual IChildNode *toNext() = 0; + virtual IChildNode *toPrev() = 0; + virtual IChildNode *current() const = 0; + virtual void release() = 0; +}; + +class INode +{ + public: + VIRTUAL_DESTRUCTOR(INode) + virtual const IString * id() const = 0; + virtual const IString * label() const = 0; + virtual const IString * linkId() const = 0; + virtual IChildNodeIterator *children() const = 0; +}; + +class INodeIterator +{ + public: + VIRTUAL_DESTRUCTOR(INodeIterator) + virtual INode *toFirst() = 0; + virtual INode *toLast() = 0; + virtual INode *toNext() = 0; + virtual INode *toPrev() = 0; + virtual INode *current() const = 0; + virtual void release() = 0; +}; + +class IGraph +{ + public: + VIRTUAL_DESTRUCTOR(IGraph) + virtual INodeIterator *nodes() const = 0; +}; + +class IMember +{ + public: + VIRTUAL_DESTRUCTOR(IMember) + enum MemberKind { Invalid=0, + Define, Property, Variable, Typedef, Enum, + Function, Signal, Prototype, Friend, DCOP, Slot, + EnumValue + }; + virtual ICompound *compound() const = 0; + virtual ISection *section() const = 0; + virtual MemberKind kind() const = 0; + virtual const IString * kindString() const = 0; + virtual const IString * id() const = 0; + virtual const IString * protection() const = 0; + virtual const IString * virtualness() const = 0; + virtual ILinkedTextIterator *type() const = 0; + virtual const IString * typeString() const = 0; + virtual const IString * name() const = 0; + virtual const IString * readAccessor() const = 0; + virtual const IString * writeAccessor() const = 0; + virtual const IString * definition() const = 0; + virtual const IString * argsstring() const = 0; + virtual bool isConst() const = 0; + virtual bool isVolatile() const = 0; + virtual bool isStatic() const = 0; + virtual bool isExplicit() const = 0; + virtual bool isInline() const = 0; + virtual bool isMutable() const = 0; + virtual bool isReadable() const = 0; + virtual bool isWritable() const = 0; + virtual IParamIterator *parameters() const = 0; + virtual IParamIterator *templateParameters() const = 0; + virtual ILinkedTextIterator *initializer() const = 0; + virtual ILinkedTextIterator *exceptions() const = 0; + virtual IMemberReferenceIterator *references() const = 0; + virtual IMemberReferenceIterator *referencedBy() const = 0; + virtual const IString *bodyFile() const = 0; + virtual int bodyStart() const = 0; + virtual int bodyEnd() const = 0; + virtual const IString * definitionFile() const = 0; + virtual int definitionLine() const = 0; + virtual IMemberReference *reimplements() const = 0; + virtual IMemberReferenceIterator *reimplementedBy() const = 0; + virtual IDocRoot *briefDescription() const = 0; + virtual IDocRoot *detailedDescription() const = 0; + virtual IDocRoot *inbodyDescription() const = 0; +}; + +class IDefine : public IMember +{ + public: +}; + +class IProperty : public IMember +{ + public: +}; + +class IVariable : public IMember +{ + public: +}; + +class ITypedef : public IMember +{ + public: +}; + +class IFunction : public IMember +{ + public: +}; + +class ISignal : public IMember +{ + public: +}; + +class IPrototype : public IMember +{ + public: +}; + +class IFriend : public IMember +{ + public: +}; + +class IDCOP : public IMember +{ + public: +}; + +class ISlot : public IMember +{ + public: +}; + +class IEnumValue : public IMember +{ + public: + virtual const IString * name() const = 0; +}; + +/*! \brief Include relation + */ +class IInclude +{ + public: + VIRTUAL_DESTRUCTOR(IInclude) + virtual const IString * name() const = 0; + virtual const IString * refId() const = 0; + virtual bool isLocal() const = 0; +}; + +class IIncludeIterator +{ + public: + VIRTUAL_DESTRUCTOR(IIncludeIterator) + virtual IInclude *toFirst() = 0; + virtual IInclude *toLast() = 0; + virtual IInclude *toNext() = 0; + virtual IInclude *toPrev() = 0; + virtual IInclude *current() const = 0; + virtual void release() = 0; +}; + +class IMemberIterator +{ + public: + VIRTUAL_DESTRUCTOR(IMemberIterator) + virtual IMember *toFirst() = 0; + virtual IMember *toLast() = 0; + virtual IMember *toNext() = 0; + virtual IMember *toPrev() = 0; + virtual IMember *current() const = 0; + virtual void release() = 0; +}; + +class IEnum : public IMember +{ + public: + virtual IMemberIterator *enumValues() const = 0; +}; + +/*! \brief The interface to a section in the object model. + * + * A compound can have a number of sections, where each + * section contains a set of members with the properties implied by + * the section kind. The kind() method returns the kind of the section. + * The members of the section can be accessed via members(). Apart + * from using kind(), some of the individual properties of the section can + * also be inspected via isStatic(), isPublic(), isProtected() and + * isPrivate(). + */ +class ISection +{ + public: + VIRTUAL_DESTRUCTOR(ISection) + /*! Possible section types */ + enum SectionKind + { Invalid=0, + UserDefined, //!< A user defined member group + PubTypes, //!< Public member typedefs + PubFuncs, //!< Public member functions + PubAttribs, //!< Public member attributes + PubSlots, //!< Public Qt Slots + Signals, //!< Qt Signals + DCOPFuncs, //!< KDE-DCOP interface functions + Properties, //!< IDL properties + Events, //!< C# events + PubStatFuncs, //!< Public static member functions + PubStatAttribs, //!< Public static attributes + ProTypes, //!< Protected member typedefs + ProFuncs, //!< Protected member functions + ProAttribs, //!< Protected member attributes + ProSlots, //!< Protected slots + ProStatFuncs, //!< Protected static member functions + ProStatAttribs, //!< Protected static member attributes + PacTypes, //!< Package member typedefs + PacFuncs, //!< Package member functions + PacAttribs, //!< Package member attributes + PacStatFuncs, //!< Package static member functions + PacStatAttribs, //!< Package static member attributes + PriTypes, //!< Private member typedefs + PriFuncs, //!< Private member functions + PriAttribs, //!< Private member attributes + PriSlots, //!< Private Qt slots + PriStatFuncs, //!< Private static member functions + PriStatAttribs, //!< Private static member attributes + Friend, //!< Friends + Related, //!< Function marked as related + Defines, //!< Preprocessor defines + Prototypes, //!< Global function prototypes + Typedefs, //!< Global typedefs + Enums, //!< Enumerations + Functions, //!< Global functions + Variables //!< Global variables + }; + + /*! Returns a string representation of the value returned by kind() */ + virtual const IString * kindString() const = 0; + + /*! Returns what kind of section this is */ + virtual SectionKind kind() const = 0; + + /*! Returns the description attached to this section (for user defined + * sections, also known as member groups). + */ + virtual IDocRoot *description() const = 0; + + /*! Returns an iterator for the members of this section */ + virtual IMemberIterator *members() const = 0; + + /*! Returns \c true if this section contains statics */ + virtual bool isStatic() const = 0; + + /*! Returns \c true if this section belongs to a + * public section of a class + */ + virtual bool isPublic() const = 0; + + /*! Returns \c true if this section belongs to a + * private section of a class + */ + virtual bool isPrivate() const = 0; + + /*! Returns \c true if this section belongs to a + * protected section of a class + * */ + virtual bool isProtected() const = 0; +}; + +class IUserDefined : public ISection +{ + public: + virtual const IString * header() const = 0; +}; + +class ISectionIterator +{ + public: + VIRTUAL_DESTRUCTOR(ISectionIterator) + virtual ISection *toFirst() = 0; + virtual ISection *toLast() = 0; + virtual ISection *toNext() = 0; + virtual ISection *toPrev() = 0; + virtual ISection *current() const = 0; + virtual void release() = 0; +}; + +/*! \brief The interface to a compound in the object model. + * + * A compound has a name which can be obtained via the name() method + * and a unique id, which is return via the id() method. + * A compound consists zero or more members which are grouped into sections. + * The sections() method can be used to access the individual sections. + * Alternatively, members can be obtained by name or id. There are + * different types of compounds. The kind() method returns what kind of + * compound this is. Depending on the return value one can dynamically + * cast an interface pointer to an more specialised interface that provides + * additional methods. + * Example: + * \code + * ICompound *comp=...; + * if (comp->kind()==ICompound::Class) + * { + * IClass *cls = dynamic_cast<IClass*>(comp); + * // use methods of IClass + * } + * \endcode + * The documentation that is provided by a compound is available via + * the briefDescription() and detailedDescription() methods. + * To avoid excessive memory usage, release() should be called (once) on each + * compound interface pointer that is no longer needed. + */ +class ICompound +{ + public: + VIRTUAL_DESTRUCTOR(ICompound) + /*! Represents the kind of compounds recognised by doxygen. */ + enum CompoundKind { Invalid=0, + Class, Struct, Union, Interface, Protocol, Category, + Exception, File, Namespace, Group, Page, Example, Dir + }; + + /*! Returns the name of this compound */ + virtual const IString * name() const = 0; + + /*! Returns the id of this compound. The id is a + * unique string representing a specific compound object. + */ + virtual const IString * id() const = 0; + + /*! Returns the kind of compound. See #CompoundKind for possible + * values. + */ + virtual CompoundKind kind() const = 0; + + /*! Returns a string representation of the compound kind. + * @see kind() + */ + virtual const IString * kindString() const = 0; + + /*! Returns an iterator for the different member sections in this + * compound. + */ + virtual ISectionIterator *sections() const = 0; + + /*! Returns a tree-structured representation of the brief + * description that is attached to this compound. + */ + virtual IDocRoot *briefDescription() const = 0; + + /*! Returns a tree-structured representation of the detailed + * description that is attached to this compound. + */ + virtual IDocRoot *detailedDescription() const = 0; + + /*! Returns an interface to a member given its id. + * @param id The member id. + */ + virtual IMember *memberById(const char * id) const = 0; + + /*! Returns a list of all members within the compound having a certain + * name. Member overloading is the reason why there can be more than + * one member. + * @param name The name of the member. + */ + virtual IMemberIterator *memberByName(const char * name) const = 0; + + /*! Decreases the reference counter for this compound. If it reaches + * zero, the memory for the compound will be released. + */ + virtual void release() = 0; +}; + +class ICompoundIterator +{ + public: + VIRTUAL_DESTRUCTOR(ICompoundIterator) + virtual void toFirst() = 0; + virtual void toLast() = 0; + virtual void toNext() = 0; + virtual void toPrev() = 0; + virtual ICompound *current() const = 0; + virtual void release() = 0; +}; + +class IRelatedCompound +{ + public: + VIRTUAL_DESTRUCTOR(IRelatedCompound) + enum Protection { Public, Protected, Private }; + enum Kind { Normal, Virtual }; + virtual ICompound *compound() const = 0; + virtual Protection protection() const = 0; + virtual Kind kind() const = 0; + virtual const IString *name() const = 0; + +}; + +class IRelatedCompoundIterator +{ + public: + VIRTUAL_DESTRUCTOR(IRelatedCompoundIterator) + virtual IRelatedCompound *toFirst() = 0; + virtual IRelatedCompound *toLast() = 0; + virtual IRelatedCompound *toNext() = 0; + virtual IRelatedCompound *toPrev() = 0; + virtual IRelatedCompound *current() const = 0; + virtual void release() = 0; +}; + +/*! \brief The interface to a class in the object model. + */ +class IClass : public ICompound +{ + public: + virtual IGraph *inheritanceGraph() const = 0; + virtual IGraph *collaborationGraph() const = 0; + virtual IRelatedCompoundIterator *baseCompounds() const = 0; + virtual IRelatedCompoundIterator *derivedCompounds() const = 0; + virtual ICompoundIterator *nestedCompounds() const = 0; + virtual IParamIterator *templateParameters() const = 0; + virtual const IString *locationFile() const = 0; + virtual int locationLine() const = 0; + virtual const IString *locationBodyFile() const = 0; + virtual int locationBodyStartLine() const = 0; + virtual int locationBodyEndLine() const = 0; + + // TODO: + // class: + // listOfAllMembers() + // protection() + // isAbstract() +}; + +/*! \brief The interface to a struct in the object model. + */ +class IStruct : public ICompound +{ + public: + virtual ICompoundIterator *nestedCompounds() const = 0; + virtual IRelatedCompoundIterator *baseCompounds() const = 0; + virtual IRelatedCompoundIterator *derivedCompounds() const = 0; + virtual const IString *locationFile() const = 0; + virtual int locationLine() const = 0; + virtual int locationBodyStartLine() const = 0; + virtual int locationBodyEndLine() const = 0; +}; + +/*! \brief The interface to a union in the object model. + */ +class IUnion : public ICompound +{ + public: + virtual ICompoundIterator *nestedCompounds() const = 0; +}; + +/*! \brief The interface to a Java/IDL interface in the object model. + */ +class IInterface : public ICompound +{ + public: + virtual IRelatedCompoundIterator *baseCompounds() const = 0; + virtual IRelatedCompoundIterator *derivedCompounds() const = 0; +}; + + +/*! \brief The interface to a Java/IDL exception in the object model. + */ +class IException : public ICompound +{ +}; + +/*! \brief The interface to a namespace in the object model. + */ +class INamespace : public ICompound +{ + public: + virtual ICompoundIterator *nestedCompounds() const = 0; +}; + +/*! \brief The interface to a file in the object model. + */ +class IFile : public ICompound +{ + public: + virtual IGraph *includeDependencyGraph() const = 0; + virtual IGraph *includedByDependencyGraph() const = 0; + virtual IDocProgramListing *source() const = 0; + virtual ICompoundIterator *nestedCompounds() const = 0; + + virtual IIncludeIterator *includes() const = 0; + virtual IIncludeIterator *includedBy() const = 0; + + // ICompound *innerNamespaces() + // ICompoundIterator *innerClasses() +}; + +/*! \brief The interface to a group in the object model. + */ +class IGroup : public ICompound +{ + public: + virtual ICompoundIterator *nestedCompounds() const = 0; + // group: + // Title() + // innerFile() + // innerPage() +}; + +/*! \brief The interface to a page in the object model. + */ +class IPage : public ICompound +{ + public: + virtual const IDocTitle *title() const = 0; +}; + +/*! Root node of the object model. */ +class IDoxygen +{ + public: + VIRTUAL_DESTRUCTOR(IDoxygen) + + /*! Returns an iterator that can be used to iterate over the list + * of compounds found in the project. + */ + virtual ICompoundIterator *compounds() const = 0; + + /*! Returns a compound given its unique \a id. If you have a + * compound id this function is much more efficient than iterating + * over the compound list. Returns 0 if the id is not valid. + */ + virtual ICompound *compoundById(const char * id) const = 0; + + /*! Returns a compound given its name (including the scope). + * Returns 0 if the name is not found in the project. + */ + virtual ICompound *compoundByName(const char * name) const = 0; + + /*! Returns an interface to a compound containing a member given it the + * member's id. Given the ICompound interface one can use the same id + * to obtain the IMember interface. + * @param id The member id. + */ + virtual ICompound *memberById(const char * id) const = 0; + + /*! Returns a list of all compounds containing at least one members + * with a certain name. Each compound can be asked to return the + * list of members with that name. + * @param name The name of the member. + */ + virtual ICompoundIterator *memberByName(const char * name) const = 0; + + /*! Releases the memory for the object hierarchy obtained by + * createdObjecModelFromXML(). First release all iterators before calling + * this function. + */ + virtual void release() = 0; + + /*! Sets the debug level. + * - 0 all debugging messages are disabled (the default). + * - 1 display important messages only + * - 2 display any messages. + */ + virtual void setDebugLevel(int level) = 0; + + /*! Reads an XML directory produced by doxygen and builds up a data + * structure representing the contents of the XML files in the directory. + */ + virtual bool readXMLDir(const char *xmlDirName) = 0; +}; + +/*! Factory method that creates an empty object model for a doxygen generated XML file. + * Use the readXMLDir() method to build the model from an XML output + * directory containing doxygen output. + */ +IDoxygen *createObjectModel(); + +#endif diff --git a/trunk/addon/doxmlparser/src/Makefile.in b/trunk/addon/doxmlparser/src/Makefile.in new file mode 100644 index 0000000..049f969 --- /dev/null +++ b/trunk/addon/doxmlparser/src/Makefile.in @@ -0,0 +1,13 @@ +all clean depend: Makefile.doxmlparser + $(MAKE) -f Makefile.doxmlparser $@ + +distclean: clean + $(RM) -rf Makefile.doxmlparser doxmlparser.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +Makefile.doxmlparser: doxmlparser.pro + $(ENV) $(PERL) $(TMAKE) doxmlparser.pro >Makefile.doxmlparser + +install: diff --git a/trunk/addon/doxmlparser/src/basehandler.cpp b/trunk/addon/doxmlparser/src/basehandler.cpp new file mode 100644 index 0000000..02d98c2 --- /dev/null +++ b/trunk/addon/doxmlparser/src/basehandler.cpp @@ -0,0 +1,3 @@ +#include "basehandler.h" + +QXmlLocator * LocatorContainer::s_theLocator=0; diff --git a/trunk/addon/doxmlparser/src/basehandler.h b/trunk/addon/doxmlparser/src/basehandler.h new file mode 100644 index 0000000..cc275a6 --- /dev/null +++ b/trunk/addon/doxmlparser/src/basehandler.h @@ -0,0 +1,325 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _BASEHANDLER_H +#define _BASEHANDLER_H + +#include <qxml.h> +#include <qdict.h> +#include <qstring.h> + +#include "debug.h" + +//----------------------------------------------------------------------------- + +class IBaseHandler +{ + public: + virtual void setDelegate(QXmlDefaultHandler *delegate) = 0; + virtual QXmlDefaultHandler *delegate() const = 0; + virtual ~IBaseHandler() {} +}; + +//----------------------------------------------------------------------------- + +class IFallBackHandler +{ + public: + virtual bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) = 0; + virtual bool handleEndElement(const QString &name) = 0; + virtual ~IFallBackHandler() {} +}; + +//----------------------------------------------------------------------------- + +template<class T> class ElementMapper +{ + class StartElementHandler + { + typedef void (T::*Handler)(const QXmlAttributes &attrib); + public: + StartElementHandler() : m_parent(0) {} + StartElementHandler(T *parent, Handler h) + : m_parent(parent), m_handler(h) {} + void operator()(const QXmlAttributes &attrib) + { if (m_parent) (m_parent->*m_handler)(attrib); } + private: + T *m_parent; + Handler m_handler; + }; + + class EndElementHandler + { + typedef void (T::*Handler)(); + public: + EndElementHandler() : m_parent(0) {} + EndElementHandler(T *parent, Handler h) + : m_parent(parent), m_handler(h) {} + void operator()() + { if (m_parent) (m_parent->*m_handler)(); } + private: + T *m_parent; + Handler m_handler; + }; + + public: + typedef StartElementHandler StartElementHandlerT; + typedef EndElementHandler EndElementHandlerT; + + ElementMapper() : m_startHandlers(67), m_endHandlers(67) + { + m_startHandlers.setAutoDelete(TRUE); + m_endHandlers.setAutoDelete(TRUE); + } + virtual ~ElementMapper() + { + } + + void addStartHandler(const char *key) + { + m_startHandlers.insert(key,new StartElementHandlerT); + } + + void addStartHandler(const char *key, T *obj, void (T::*handler)(const QXmlAttributes &)) + { + m_startHandlers.insert(key,new StartElementHandlerT(obj,handler)); + } + + void addEndHandler(const char *key) + { + m_endHandlers.insert(key,new EndElementHandlerT); + } + + void addEndHandler(const char *key, T *obj, void (T::*handler)()) + { + m_endHandlers.insert(key,new EndElementHandlerT(obj,handler)); + } + + + protected: + QDict<StartElementHandlerT> m_startHandlers; + QDict<EndElementHandlerT> m_endHandlers; +}; + +//----------------------------------------------------------------------------- + +struct LocatorContainer +{ + static QXmlLocator *s_theLocator; +}; + +//----------------------------------------------------------------------------- + +template<class T> class BaseHandler : public QXmlDefaultHandler, + public ElementMapper<T>, + public LocatorContainer, + public IBaseHandler +{ + public: + typedef typename ElementMapper<T>::StartElementHandlerT StartElementHandlerT; + typedef typename ElementMapper<T>::EndElementHandlerT EndElementHandlerT; + + BaseHandler() : m_delegateHandler(0), m_fallBackHandler(0) + { + } + + virtual ~BaseHandler() + { + ASSERT(m_delegateHandler==0); + } + + virtual bool startDocument() + { + return TRUE; + } + + virtual bool startElement( const QString & namespaceURI, + const QString & localName, + const QString & name, + const QXmlAttributes & attrib + ) + { + if (m_delegateHandler) + { + return m_delegateHandler->startElement(namespaceURI,localName,name,attrib); + } + if (!m_skipUntil.isEmpty()) // skip mode + { + if (m_skipUntil==name) m_skipCount++; + debug(1,"line %d, col %d: skipping start tag %s count=%d\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + name.data(),m_skipCount); + return TRUE; + } + + StartElementHandlerT *handler = ElementMapper<T>::m_startHandlers[name]; + if (handler) + { + (*handler)(attrib); + //printf("found start tag %s\n",name.data()); + } + else if (!m_fallBackHandler || + !m_fallBackHandler->handleStartElement(name,attrib) + ) + { + debug(1,"line %d, col %d: found unexpected tag `%s', skipping until matching end tag\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + name.data()); + m_skipUntil = name; + m_skipCount=1; + } + return TRUE; + } + + virtual bool endElement( const QString& namespaceURI, const QString& localName, const QString& name ) + { + if (m_delegateHandler) + { + return m_delegateHandler->endElement(namespaceURI,localName,name); + } + + if (name==m_skipUntil) + { + m_skipCount--; + debug(1,"line %d, col %d: skipping end tag %s count=%d\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + name.data(),m_skipCount); + if (m_skipCount==0) + { + m_skipUntil=""; + } + //printf("found end tag %s\n",name.data()); + } + else if (m_skipUntil.isEmpty()) + { + EndElementHandlerT *handler = ElementMapper<T>::m_endHandlers[name]; + if (handler) + { + (*handler)(); + //printf("found end tag %s\n",name.data()); + } + else if (m_fallBackHandler) + { + m_fallBackHandler->handleEndElement(name); + } + } + m_curString=""; + return TRUE; + } + + bool skippedEntity ( const QString &s ) + { + if (m_delegateHandler) + { + return m_delegateHandler->skippedEntity(s); + } + + debug(1,"line %d, col %d: Skipped unhandled entity %s\n", + s_theLocator->lineNumber(),s_theLocator->columnNumber(), + s.data()); + return TRUE; + } + + /*! called when a number of characters are received by the parser. + * \param ch the characters. + */ + virtual bool characters ( const QString & ch ) + { + if (m_delegateHandler) + { + return m_delegateHandler->characters(ch); + } + + //printf("Found characters \"%s\"\n",ch.data()); + m_curString+=ch; + return TRUE; + } + + void setDelegate(QXmlDefaultHandler *delegate) + { + m_delegateHandler = delegate; + } + + QXmlDefaultHandler *delegate() const + { + return m_delegateHandler; + } + + void setFallBackHandler(IFallBackHandler *h) + { + m_fallBackHandler = h; + } + + IFallBackHandler *fallBackHandler() const + { + return m_fallBackHandler; + } + + void setDocumentLocator( QXmlLocator * locator ) + { + debug(2,"setDocumentLocator(%p)\n",locator); + s_theLocator = locator; + } + + protected: + QString m_curString; + QString m_skipUntil; + int m_skipCount; + QXmlDefaultHandler *m_delegateHandler; + IFallBackHandler *m_fallBackHandler; +}; + +//----------------------------------------------------------------------------- + +template<class T> class BaseFallBackHandler : public ElementMapper<T>, + public IFallBackHandler +{ + public: + typedef typename ElementMapper<T>::StartElementHandlerT StartElementHandlerT; + typedef typename ElementMapper<T>::EndElementHandlerT EndElementHandlerT; + + BaseFallBackHandler() + { + } + virtual ~BaseFallBackHandler() + { + } + + bool handleStartElement(const QString & name, + const QXmlAttributes & attrib) + { + StartElementHandlerT *handler = ElementMapper<T>::m_startHandlers[name]; + if (handler) + { + (*handler)(attrib); + return TRUE; + } + return FALSE; + } + bool handleEndElement(const QString &name) + { + EndElementHandlerT *handler = ElementMapper<T>::m_endHandlers[name]; + if (handler) + { + (*handler)(); + return TRUE; + } + return FALSE; + } +}; + + +#endif diff --git a/trunk/addon/doxmlparser/src/baseiterator.h b/trunk/addon/doxmlparser/src/baseiterator.h new file mode 100644 index 0000000..68dbee4 --- /dev/null +++ b/trunk/addon/doxmlparser/src/baseiterator.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef BASEITERATOR_H +#define BASEITERATOR_H + +#include <qlist.h> +#include <doxmlintf.h> + +template<class Intf,class ElemIntf,class ElemImpl> class BaseIterator : + public Intf, public QListIterator<ElemImpl> +{ + public: + BaseIterator(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {} + virtual ~BaseIterator() {} + virtual ElemIntf *toFirst() { return QListIterator<ElemImpl>::toFirst(); } + virtual ElemIntf *toLast() { return QListIterator<ElemImpl>::toLast(); } + virtual ElemIntf *toNext() { return QListIterator<ElemImpl>::operator++(); } + virtual ElemIntf *toPrev() { return QListIterator<ElemImpl>::operator--(); } + virtual ElemIntf *current() const { return QListIterator<ElemImpl>::current(); } + virtual void release() { delete this; } +}; + +template<class Intf,class ElemIntf,class ElemImpl,class Intermediate> + class BaseIteratorVia : + public Intf, public QListIterator<ElemImpl> +{ + public: + BaseIteratorVia(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {} + virtual ~BaseIteratorVia() {} + virtual ElemIntf *toFirst() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toFirst()); } + virtual ElemIntf *toLast() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toLast()); } + virtual ElemIntf *toNext() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator++()); } + virtual ElemIntf *toPrev() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator--()); } + virtual ElemIntf *current() const { return static_cast<Intermediate *>(QListIterator<ElemImpl>::current()); } + virtual void release() { delete this; } +}; + +#endif diff --git a/trunk/addon/doxmlparser/src/compoundhandler.cpp b/trunk/addon/doxmlparser/src/compoundhandler.cpp new file mode 100644 index 0000000..3246e33 --- /dev/null +++ b/trunk/addon/doxmlparser/src/compoundhandler.cpp @@ -0,0 +1,650 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "mainhandler.h" +#include "compoundhandler.h" +#include "dochandler.h" +#include "debug.h" +#include "graphhandler.h" +#include "sectionhandler.h" +#include "paramhandler.h" +#include "loamhandler.h" +#include "memberhandler.h" + +//---------------------------------------------------------------------------- + +IncludeHandler::IncludeHandler(IBaseHandler *parent,const char *endtag) : + m_parent(parent) +{ + addEndHandler(endtag,this,&IncludeHandler::endInclude); +} + +IncludeHandler::~IncludeHandler() +{ +} + +void IncludeHandler::startInclude(const QXmlAttributes &attrib) +{ + m_curString = ""; + m_refId = attrib.value("refid"); + m_isLocal = attrib.value("local")=="yes"; + m_parent->setDelegate(this); +} + +void IncludeHandler::endInclude() +{ + m_name = m_curString; + m_parent->setDelegate(0); + debug(2,"Found include %s\n",m_name.data()); +} + +//---------------------------------------------------------------------------- + +class CompoundIdIterator : public ICompoundIterator, + public QListIterator<QString> +{ + public: + CompoundIdIterator(const MainHandler *m,const QList<QString> &list) : + QListIterator<QString>(list), m_mainHandler(m) {} + virtual ~CompoundIdIterator() {} + + virtual void toFirst() + { + QListIterator<QString>::toFirst(); + } + virtual void toLast() + { + QListIterator<QString>::toLast(); + } + virtual void toNext() + { + QListIterator<QString>::operator++(); + } + virtual void toPrev() + { + QListIterator<QString>::operator--(); + } + virtual ICompound *current() const + { + QString *id = QListIterator<QString>::current(); + return id ? m_mainHandler->compoundById(*id) : 0; + } + virtual void release() + { delete this; } + + private: + const MainHandler *m_mainHandler; +}; + +//---------------------------------------------------------------------------- + +ICompound *RelatedCompound::compound() const +{ + return m_parent->m_mainHandler->compoundById(m_id); +} + +//---------------------------------------------------------------------------- + +class CompoundErrorHandler : public QXmlErrorHandler +{ + public: + virtual ~CompoundErrorHandler() {} + bool warning( const QXmlParseException & ) + { + return FALSE; + } + bool error( const QXmlParseException & ) + { + return FALSE; + } + bool fatalError( const QXmlParseException &exception ) + { + debug(1,"Fatal error at line %d column %d: %s\n", + exception.lineNumber(),exception.columnNumber(), + exception.message().data()); + return FALSE; + } + QString errorString() { return ""; } + + private: + QString errorMsg; +}; + +//---------------------------------------------------------------------------- + +class CompoundTypeMap +{ + public: + CompoundTypeMap() + { + m_map.setAutoDelete(TRUE); + m_map.insert("class", new int(ICompound::Class)); + m_map.insert("struct", new int(ICompound::Struct)); + m_map.insert("union", new int(ICompound::Union)); + m_map.insert("interface",new int(ICompound::Interface)); + m_map.insert("protocol", new int(ICompound::Protocol)); + m_map.insert("category", new int(ICompound::Category)); + m_map.insert("exception",new int(ICompound::Exception)); + m_map.insert("file", new int(ICompound::File)); + m_map.insert("namespace",new int(ICompound::Namespace)); + m_map.insert("group", new int(ICompound::Group)); + m_map.insert("page", new int(ICompound::Page)); + m_map.insert("example", new int(ICompound::Example)); + m_map.insert("dir", new int(ICompound::Dir)); + } + virtual ~CompoundTypeMap() + { + } + ICompound::CompoundKind map(const QString &s) + { + int *val = m_map.find(s); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid compound type\n",s.data()); + return ICompound::Invalid; + } + else return (ICompound::CompoundKind)*val; + } + private: + QDict<int> m_map; +}; + +static CompoundTypeMap *s_typeMap; + +void compoundhandler_init() +{ + s_typeMap = new CompoundTypeMap; +} + +void compoundhandler_exit() +{ + delete s_typeMap; +} + +//---------------------------------------------------------------------------- + +CompoundHandler::CompoundHandler(const QString &xmlDir) + : m_titleHandler(0), + m_includeDependencyGraph(0), + m_includedByDependencyGraph(0), + m_templateParamList(0), + m_brief(0), + m_detailed(0), + m_inheritanceGraph(0), + m_collaborationGraph(0), + m_programListing(0), + m_members(0), + m_xmlDir(xmlDir), + m_refCount(1), + m_memberDict(257), + m_memberNameDict(257), + m_mainHandler(0) +{ + m_superClasses.setAutoDelete(TRUE); + m_subClasses.setAutoDelete(TRUE); + m_sections.setAutoDelete(TRUE); + m_memberNameDict.setAutoDelete(TRUE); + m_innerCompounds.setAutoDelete(TRUE); + m_includes.setAutoDelete(TRUE); + m_includedBy.setAutoDelete(TRUE); + + addStartHandler("doxygen"); + addEndHandler("doxygen"); + + addStartHandler("compounddef",this,&CompoundHandler::startCompound); + addEndHandler("compounddef",this,&CompoundHandler::endCompound); + + addStartHandler("compoundname"); + addEndHandler("compoundname",this,&CompoundHandler::endCompoundName); + + addStartHandler("title",this,&CompoundHandler::startTitle); + + addStartHandler("basecompoundref",this,&CompoundHandler::startSuperClass); + addEndHandler("basecompoundref",this,&CompoundHandler::endSuperClass); + + addStartHandler("derivedcompoundref",this,&CompoundHandler::startSubClass); + addEndHandler("derivedcompoundref",this,&CompoundHandler::endSubClass); + + addStartHandler("includes",this,&CompoundHandler::startIncludes); + addStartHandler("includedby",this,&CompoundHandler::startIncludedBy); + + addStartHandler("incdepgraph",this,&CompoundHandler::startIncludeDependencyGraph); + + addStartHandler("invincdepgraph",this,&CompoundHandler::startIncludedByDependencyGraph); + + addStartHandler("innerdir",this,&CompoundHandler::startInnerDir); + addEndHandler("innerdir"); + + addStartHandler("innerfile",this,&CompoundHandler::startInnerFile); + addEndHandler("innerfile"); + + addStartHandler("innerclass",this,&CompoundHandler::startInnerClass); + addEndHandler("innerclass"); + + addStartHandler("innernamespace",this,&CompoundHandler::startInnerNamespace); + addEndHandler("innernamespace"); + + addStartHandler("innerpage",this,&CompoundHandler::startInnerPage); + addEndHandler("innerpage"); + + addStartHandler("innergroup",this,&CompoundHandler::startInnerGroup); + addEndHandler("innergroup"); + + addStartHandler("templateparamlist",this,&CompoundHandler::startTemplateParamList); + + addStartHandler("sectiondef",this,&CompoundHandler::startSection); + + addStartHandler("briefdescription",this,&CompoundHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&CompoundHandler::startDetailedDesc); + + addStartHandler("inheritancegraph",this,&CompoundHandler::startInheritanceGraph); + + addStartHandler("collaborationgraph",this,&CompoundHandler::startCollaborationGraph); + + addStartHandler("programlisting",this,&CompoundHandler::startProgramListing); + + addStartHandler("location",this,&CompoundHandler::startLocation); + addEndHandler("location"); + + addStartHandler("listofallmembers",this,&CompoundHandler::startListOfAllMembers); +} + +CompoundHandler::~CompoundHandler() +{ + debug(2,"CompoundHandler::~CompoundHandler()\n"); + delete m_titleHandler; + delete m_brief; + delete m_detailed; + delete m_programListing; + delete m_inheritanceGraph; + delete m_collaborationGraph; + delete m_includeDependencyGraph; + delete m_includedByDependencyGraph; + delete m_templateParamList; + delete m_members; +} + +void CompoundHandler::startSection(const QXmlAttributes& attrib) +{ + SectionHandler *sectHandler = new SectionHandler(this); + sectHandler->startSection(attrib); + m_sections.append(sectHandler); +} + +void CompoundHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void CompoundHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} + +void CompoundHandler::startProgramListing(const QXmlAttributes& attrib) +{ + ProgramListingHandler *plHandler = new ProgramListingHandler(this); + plHandler->startProgramListing(attrib); + m_programListing = plHandler; +} + +void CompoundHandler::startIncludes(const QXmlAttributes& attrib) +{ + IncludeHandler *inc = new IncludeHandler(this,"includes"); + m_includes.append(inc); + inc->startInclude(attrib); +} + +void CompoundHandler::startIncludedBy(const QXmlAttributes& attrib) +{ + IncludeHandler *inc = new IncludeHandler(this,"includedby"); + m_includedBy.append(inc); + inc->startInclude(attrib); +} + +void CompoundHandler::startCompound(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_kindString = attrib.value("kind"); + m_kind = s_typeMap->map(m_kindString); + m_protection = attrib.value("prot"); + debug(2,"startCompound(id=`%s' type=`%s')\n",m_id.data(),m_kindString.data()); +} + +void CompoundHandler::endCompound() +{ + debug(2,"endCompound()\n"); +} + +void CompoundHandler::startLocation(const QXmlAttributes& attrib) +{ + m_defFile = attrib.value("file"); + m_defLine = attrib.value("line").toInt(); + m_defBodyFile = attrib.value("bodyfile"); + m_defBodyStart = attrib.value("bodystart").toInt(); + m_defBodyEnd = attrib.value("bodyend").toInt(); +} + +void CompoundHandler::endCompoundName() +{ + m_name = m_curString.stripWhiteSpace(); + debug(2,"Compound name `%s'\n",m_name.data()); +} + +void CompoundHandler::startInnerClass(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerNamespace(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerFile(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerGroup(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerPage(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startInnerDir(const QXmlAttributes& attrib) +{ + m_innerCompounds.append(new QString(attrib.value("refid"))); +} + +void CompoundHandler::startTemplateParamList(const QXmlAttributes& attrib) +{ + m_templateParamList = new TemplateParamListHandler(this); + m_templateParamList->startTemplateParamList(attrib); +} + +void CompoundHandler::startListOfAllMembers(const QXmlAttributes& attrib) +{ + m_members = new ListOfAllMembersHandler(this); + m_members->startListOfAllMembers(attrib); +} + +void CompoundHandler::startSuperClass(const QXmlAttributes& attrib) +{ + IRelatedCompound::Protection prot = IRelatedCompound::Public; + QString protString = attrib.value("prot"); + if (protString=="protected") + { + prot = IRelatedCompound::Protected; + } + else if (protString=="private") + { + prot = IRelatedCompound::Private; + } + IRelatedCompound::Kind kind = IRelatedCompound::Normal; + QString kindString = attrib.value("virt"); + if (kindString=="virtual") kind = IRelatedCompound::Virtual; + + RelatedCompound *sc=new RelatedCompound( + this, + attrib.value("refid"), + prot, + kind + ); + debug(2,"super class id=`%s' prot=`%s' virt=`%s'\n", + attrib.value("refid").data(), + protString.data(), + kindString.data()); + m_superClasses.append(sc); + m_curString = ""; +} + +void CompoundHandler::endSuperClass() +{ + m_superClasses.getLast()->setName(m_curString); +} + +void CompoundHandler::startSubClass(const QXmlAttributes& attrib) +{ + IRelatedCompound::Protection prot = IRelatedCompound::Public; + QString protString = attrib.value("prot"); + if (protString=="protected") prot = IRelatedCompound::Protected; + else if (protString=="private") prot = IRelatedCompound::Private; + + IRelatedCompound::Kind kind = IRelatedCompound::Normal; + QString kindString = attrib.value("virt"); + if (kindString=="virtual") kind = IRelatedCompound::Virtual; + + RelatedCompound *sc = new RelatedCompound( + this, + attrib.value("refid"), + prot, + kind + ); + debug(2,"sub class id=`%s' prot=`%s' virt=`%s'\n", + attrib.value("refid").data(), + protString.data(), + kindString.data()); + m_subClasses.append(sc); + m_curString = ""; +} + +void CompoundHandler::endSubClass() +{ + m_subClasses.getLast()->setName(m_curString); +} + +void CompoundHandler::startTitle(const QXmlAttributes& attrib) +{ + ASSERT(m_titleHandler==0); + m_titleHandler = new TitleHandler(this); + m_titleHandler->startTitle(attrib); +} + +bool CompoundHandler::parseXML(const char *compId) +{ + QFile xmlFile(m_xmlDir+"/"+compId+".xml"); + if (!xmlFile.exists()) return FALSE; + CompoundErrorHandler errorHandler; + QXmlInputSource source( xmlFile ); + QXmlSimpleReader reader; + reader.setContentHandler( this ); + reader.setErrorHandler( &errorHandler ); + reader.parse( source ); + return TRUE; +} + +void CompoundHandler::initialize(MainHandler *mh) +{ + m_mainHandler = mh; + QListIterator<SectionHandler> msi(m_sections); + SectionHandler *sec; + for (;(sec=msi.current());++msi) + { + sec->initialize(this); + } + if (m_members) + { + m_members->initialize(mh); + } +} + +void CompoundHandler::insertMember(MemberHandler *mh) +{ + m_memberDict.insert(mh->id()->latin1(),mh); + mh->initialize(m_mainHandler); + QList<MemberHandler> *mhl = m_memberNameDict.find(mh->id()->latin1()); + if (mhl==0) + { + mhl = new QList<MemberHandler>; + m_memberNameDict.insert(mh->name()->latin1(),mhl); + } + mhl->append(mh); +} + +ICompound *CompoundHandler::toICompound() const +{ + switch (m_kind) + { + case IClass::Class: return (IClass *)this; + case IStruct::Struct: return (IStruct *)this; + case IUnion::Union: return (IUnion *)this; + case IException::Exception: return (IException *)this; + case IInterface::Interface: return (IInterface *)this; + case INamespace::Namespace: return (INamespace *)this; + case IFile::File: return (IFile *)this; + case IGroup::Group: return (IGroup *)this; + case IPage::Page: return (IPage *)this; + default: return 0; + } + return 0; +} + +void CompoundHandler::release() +{ + debug(2,"CompoundHandler::release() %d->%d\n",m_refCount,m_refCount-1); + if (--m_refCount<=0) + { + m_mainHandler->unloadCompound(this); + delete this; + } +} + +ISectionIterator *CompoundHandler::sections() const +{ + return new SectionIterator(m_sections); +} + +IMemberIterator *CompoundHandler::memberByName(const char *name) const +{ + QList<MemberHandler> *ml = m_memberNameDict[name]; + if (ml==0) return 0; + return new MemberIterator(*ml); +} + +void CompoundHandler::startInheritanceGraph(const QXmlAttributes &attrib) +{ + m_inheritanceGraph = new GraphHandler(this,"inheritancegraph"); + m_inheritanceGraph->startGraph(attrib); +} + +void CompoundHandler::startCollaborationGraph(const QXmlAttributes &attrib) +{ + m_collaborationGraph = new GraphHandler(this,"collaborationgraph"); + m_collaborationGraph->startGraph(attrib); +} + +void CompoundHandler::startIncludeDependencyGraph(const QXmlAttributes &attrib) +{ + m_includeDependencyGraph = new GraphHandler(this,"incdepgraph"); + m_includeDependencyGraph->startGraph(attrib); +} + +void CompoundHandler::startIncludedByDependencyGraph(const QXmlAttributes &attrib) +{ + m_includedByDependencyGraph = new GraphHandler(this,"invincdepgraph"); + m_includedByDependencyGraph->startGraph(attrib); +} + +IDocRoot *CompoundHandler::briefDescription() const +{ + return m_brief; +} + +IDocRoot *CompoundHandler::detailedDescription() const +{ + return m_detailed; +} + +IMember *CompoundHandler::memberById(const char *id) const +{ + return (IFunction*)m_memberDict[id]; +} + +IGraph *CompoundHandler::inheritanceGraph() const +{ + return m_inheritanceGraph; +} + +IGraph *CompoundHandler::collaborationGraph() const +{ + return m_collaborationGraph; +} + +IGraph *CompoundHandler::includeDependencyGraph() const +{ + return m_includeDependencyGraph; +} + +IGraph *CompoundHandler::includedByDependencyGraph() const +{ + return m_includedByDependencyGraph; +} + +IRelatedCompoundIterator *CompoundHandler::baseCompounds() const +{ + return new RelatedCompoundIterator(m_superClasses); +} + +IRelatedCompoundIterator *CompoundHandler::derivedCompounds() const +{ + return new RelatedCompoundIterator(m_subClasses); +} + +ICompoundIterator *CompoundHandler::nestedCompounds() const +{ + return new CompoundIdIterator(m_mainHandler,m_innerCompounds); +} + +IDocProgramListing *CompoundHandler::source() const +{ + return m_programListing; +} + +IIncludeIterator *CompoundHandler::includes() const +{ + return new IncludeIterator(m_includes); +} + +IIncludeIterator *CompoundHandler::includedBy() const +{ + return new IncludeIterator(m_includedBy); +} + +IParamIterator *CompoundHandler::templateParameters() const +{ + return m_templateParamList ? m_templateParamList->templateParams() : 0; +} + +const IDocTitle *CompoundHandler::title() const +{ + return m_titleHandler; +} + +IMemberReferenceIterator *CompoundHandler::members() const +{ + return m_members ? m_members->members() : 0; +} + + diff --git a/trunk/addon/doxmlparser/src/compoundhandler.h b/trunk/addon/doxmlparser/src/compoundhandler.h new file mode 100644 index 0000000..d661dc1 --- /dev/null +++ b/trunk/addon/doxmlparser/src/compoundhandler.h @@ -0,0 +1,236 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef _COMPOUNDHANDLER_H +#define _COMPOUNDHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class MainHandler; +class DocHandler; +class ProgramListingHandler; +class GraphHandler; +class MemberHandler; +class CompoundHandler; +class SectionHandler; +class ParamHandler; +class TemplateParamListHandler; +class TitleHandler; +class ListOfAllMembersHandler; + +class IncludeHandler : public IInclude, public BaseHandler<IncludeHandler> +{ + public: + IncludeHandler(IBaseHandler *parent,const char *endtag); + virtual ~IncludeHandler(); + + void startInclude(const QXmlAttributes &attrib); + void endInclude(); + + // IInclude + virtual const IString * name() const + { return &m_name; } + virtual const IString * refId() const + { return &m_refId; } + virtual bool isLocal() const + { return &m_isLocal; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; // element's content + StringImpl m_refId; // refid + bool m_isLocal; // local +}; + +class IncludeIterator : public BaseIterator<IIncludeIterator,IInclude,IncludeHandler> +{ + public: + IncludeIterator(const QList<IncludeHandler> &list) : + BaseIterator<IIncludeIterator,IInclude,IncludeHandler>(list) {} +}; + + +class RelatedCompound : public IRelatedCompound +{ + public: + RelatedCompound(CompoundHandler *parent, + const QString &id, + Protection prot, + Kind kind + ) : + m_parent(parent), m_id(id), m_protection(prot), m_kind(kind) {} + virtual ~RelatedCompound() {} + void setName(const QString &str) { m_name = str; } + + virtual ICompound *compound() const; + virtual Protection protection() const { return m_protection; } + virtual Kind kind() const { return m_kind; } + virtual const IString *name() const { return &m_name; } + + private: + CompoundHandler *m_parent; + QString m_id; // refid + Protection m_protection; // prot + Kind m_kind; // virt + StringImpl m_name; // element's content +}; + +class RelatedCompoundIterator : public BaseIterator<IRelatedCompoundIterator,IRelatedCompound,RelatedCompound> +{ + public: + RelatedCompoundIterator(const QList<RelatedCompound> &list) : + BaseIterator<IRelatedCompoundIterator,IRelatedCompound,RelatedCompound>(list) {} +}; + + +class CompoundHandler : public IClass, + public IStruct, + public IUnion, + public IException, + public IInterface, + public INamespace, + public IFile, + public IGroup, + public IPage, + public BaseHandler<CompoundHandler> +{ + friend class RelatedCompound; + + public: + virtual void startSection(const QXmlAttributes& attrib); + virtual void startCompound(const QXmlAttributes& attrib); + virtual void startSuperClass(const QXmlAttributes& attrib); + virtual void endSuperClass(); + virtual void startSubClass(const QXmlAttributes& attrib); + virtual void endSubClass(); + virtual void endCompound(); + virtual void endCompoundName(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + virtual void startLocation(const QXmlAttributes& attrib); + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void startInheritanceGraph(const QXmlAttributes& attrib); + virtual void startCollaborationGraph(const QXmlAttributes& attrib); + virtual void startIncludeDependencyGraph(const QXmlAttributes& attrib); + virtual void startIncludedByDependencyGraph(const QXmlAttributes& attrib); + virtual void startIncludes(const QXmlAttributes& attrib); + virtual void startIncludedBy(const QXmlAttributes& attrib); + virtual void startInnerDir(const QXmlAttributes& attrib); + virtual void startInnerClass(const QXmlAttributes& attrib); + virtual void startInnerNamespace(const QXmlAttributes& attrib); + virtual void startInnerFile(const QXmlAttributes& attrib); + virtual void startInnerGroup(const QXmlAttributes& attrib); + virtual void startInnerPage(const QXmlAttributes& attrib); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startTemplateParamList(const QXmlAttributes& attrib); + virtual void startListOfAllMembers(const QXmlAttributes& attrib); + virtual void addref() { m_refCount++; } + + CompoundHandler(const QString &dirName); + virtual ~CompoundHandler(); + bool parseXML(const char *compId); + void initialize(MainHandler *mh); + void insertMember(MemberHandler *mh); + ICompound *toICompound() const; + + // ICompound implementation + const IString *name() const { return &m_name; } + const IString *id() const { return &m_id; } + CompoundKind kind() const { return m_kind; } + const IString *kindString() const { return &m_kindString; } + ISectionIterator *sections() const; + IDocRoot *briefDescription() const; + IDocRoot *detailedDescription() const; + IMember *memberById(const char *id) const; + IMemberIterator *memberByName(const char *name) const; + IParamIterator *templateParameters() const; + void release(); + + // IClass implementation + IGraph *inheritanceGraph() const; + IGraph *collaborationGraph() const; + IRelatedCompoundIterator *baseCompounds() const; + IRelatedCompoundIterator *derivedCompounds() const; + ICompoundIterator *nestedCompounds() const; + ICompoundIterator *nestedGroup() const; + const IString *locationFile() const { return &m_defFile; } + int locationLine() const { return m_defLine; } + const IString *locationBodyFile() const { return &m_defBodyFile; } + int locationBodyStartLine() const { return m_defBodyStart; } + int locationBodyEndLine() const { return m_defBodyEnd; } + IMemberReferenceIterator *members() const; + + // IFile implementation + IGraph *includeDependencyGraph() const; + IGraph *includedByDependencyGraph() const; + IDocProgramListing *source() const; + IIncludeIterator *includes() const; + IIncludeIterator *includedBy() const; + + // IPage implementation + const IDocTitle *title() const; + + private: + // XML elements: + // ------------- + StringImpl m_name; // compoundname + TitleHandler* m_titleHandler; // title + QList<RelatedCompound> m_subClasses; // basecompoundref + QList<RelatedCompound> m_superClasses; // derivedcompoundref + QList<IncludeHandler> m_includes; // includes + QList<IncludeHandler> m_includedBy; // includedBy + GraphHandler* m_includeDependencyGraph; // incdepgraph + GraphHandler* m_includedByDependencyGraph; // invincdepgraph + QList<QString> m_innerCompounds; // innerdir/innerfile/innerclass/innernamespace/innergroup + TemplateParamListHandler* m_templateParamList; // templateparamlist + QList<SectionHandler> m_sections; // sectiondef + DocHandler* m_brief; // briefdescription + DocHandler* m_detailed; // detaileddescription + GraphHandler* m_inheritanceGraph; // inheritancegraph + GraphHandler* m_collaborationGraph; // collaborationgraph + ProgramListingHandler* m_programListing; // programlisting + // location + StringImpl m_defFile; // - file + int m_defLine; // - line + StringImpl m_defBodyFile; // - bodyfile + int m_defBodyStart; // - bodystart + int m_defBodyEnd; // - bodyend + ListOfAllMembersHandler* m_members; // listofallmember + + // XML attributes: + // --------------- + StringImpl m_id; // id + CompoundKind m_kind; // kind + StringImpl m_kindString; // kind as a string + StringImpl m_protection; // prot + + // local variables + QString m_xmlDir; // directory where the info is found + int m_refCount; // object reference counter + QDict<MemberHandler> m_memberDict; // id->member lookup + QDict<QList<MemberHandler> > m_memberNameDict; // name->memberlist lookup + MainHandler* m_mainHandler; // parent object +}; + +void compoundhandler_init(); +void compoundhandler_exit(); + +#endif diff --git a/trunk/addon/doxmlparser/src/debug.cpp b/trunk/addon/doxmlparser/src/debug.cpp new file mode 100644 index 0000000..a8be32c --- /dev/null +++ b/trunk/addon/doxmlparser/src/debug.cpp @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#include "debug.h" + +static int s_debugLevel = 0; + +void debug(int level,const char *msg,...) +{ + if (level<=s_debugLevel) + { + va_list args; + va_start(args, msg); + vfprintf(stderr, msg, args); + va_end(args); + } +} + +void setDebugLevel(int level) +{ + s_debugLevel = level; +} + diff --git a/trunk/addon/doxmlparser/src/debug.h b/trunk/addon/doxmlparser/src/debug.h new file mode 100644 index 0000000..c77f7fe --- /dev/null +++ b/trunk/addon/doxmlparser/src/debug.h @@ -0,0 +1,7 @@ +#ifndef _DEBUG_H +#define _DEBUG_H + +void debug(int level,const char *msg,...); +void setDebugLevel(int level); + +#endif diff --git a/trunk/addon/doxmlparser/src/dochandler.cpp b/trunk/addon/doxmlparser/src/dochandler.cpp new file mode 100644 index 0000000..ce7cb3f --- /dev/null +++ b/trunk/addon/doxmlparser/src/dochandler.cpp @@ -0,0 +1,2240 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include <qmap.h> + +#include "dochandler.h" +#include "debug.h" +#include "linkedtexthandler.h" + + +//---------------------------------------------------------------------- + +class TypeNameMapper +{ + public: + TypeNameMapper() + { + m_map.insert("see", SimpleSectHandler::See); + m_map.insert("return", SimpleSectHandler::Return); + m_map.insert("author", SimpleSectHandler::Author); + m_map.insert("version", SimpleSectHandler::Version); + m_map.insert("since", SimpleSectHandler::Since); + m_map.insert("date", SimpleSectHandler::Date); + m_map.insert("bug", SimpleSectHandler::Bug); + m_map.insert("note", SimpleSectHandler::Note); + m_map.insert("warning", SimpleSectHandler::Warning); + m_map.insert("par", SimpleSectHandler::Par); + m_map.insert("deprecated",SimpleSectHandler::Deprecated); + m_map.insert("pre", SimpleSectHandler::Pre); + m_map.insert("post", SimpleSectHandler::Post); + m_map.insert("invariant", SimpleSectHandler::Invar); + m_map.insert("remark", SimpleSectHandler::Remark); + m_map.insert("attention", SimpleSectHandler::Attention); + m_map.insert("todo", SimpleSectHandler::Todo); + m_map.insert("test", SimpleSectHandler::Test); + m_map.insert("rcs", SimpleSectHandler::RCS); + m_map.insert("enumvalues",SimpleSectHandler::EnumValues); + m_map.insert("examples", SimpleSectHandler::Examples); + } + SimpleSectHandler::Types stringToType(const QString &typeStr) + { + return m_map[typeStr]; + } + private: + QMap<QString,SimpleSectHandler::Types> m_map; +}; + +class HighlightMapper +{ + public: + HighlightMapper() + { + m_map.insert("comment", HighlightHandler::Comment); + m_map.insert("keyword", HighlightHandler::Keyword); + m_map.insert("keywordtype", HighlightHandler::KeywordType); + m_map.insert("keywordflow", HighlightHandler::KeywordFlow); + m_map.insert("charliteral", HighlightHandler::CharLiteral); + m_map.insert("stringliteral", HighlightHandler::StringLiteral); + m_map.insert("preprocessor", HighlightHandler::Preprocessor); + } + HighlightHandler::HighlightKind stringToKind(const QString &kindStr) + { + return m_map[kindStr]; + } + private: + QMap<QString,HighlightHandler::HighlightKind> m_map; +}; + +static TypeNameMapper *s_typeMapper; +static HighlightMapper *s_highlightMapper; + +void dochandler_init() +{ + s_typeMapper = new TypeNameMapper; + s_highlightMapper = new HighlightMapper; +} + +void dochandler_exit() +{ + delete s_typeMapper; + delete s_highlightMapper; +} + +//---------------------------------------------------------------------- +// MarkupHandler +//---------------------------------------------------------------------- + +MarkupHandler::MarkupHandler(QList<DocImpl> &children,QString &curString) + : m_children(children), m_curString(curString), + m_curMarkup(IDocMarkup::Normal), m_headingLevel(0) +{ + addStartHandler("bold",this,&MarkupHandler::startBold); + addEndHandler("bold",this,&MarkupHandler::endBold); + + addStartHandler("emphasis",this,&MarkupHandler::startEmphasis); + addEndHandler("emphasis",this,&MarkupHandler::endEmphasis); + + addStartHandler("computeroutput",this,&MarkupHandler::startComputerOutput); + addEndHandler("computeroutput",this,&MarkupHandler::endComputerOutput); + + addStartHandler("center",this,&MarkupHandler::startCenter); + addEndHandler("center",this,&MarkupHandler::endCenter); + + addStartHandler("small",this,&MarkupHandler::startSmallFont); + addEndHandler("small",this,&MarkupHandler::endSmallFont); + + addStartHandler("subscript",this,&MarkupHandler::startSubscript); + addEndHandler("subscript",this,&MarkupHandler::endSubscript); + + addStartHandler("superscript",this,&MarkupHandler::startSuperscript); + addEndHandler("superscript",this,&MarkupHandler::endSuperscript); + + addStartHandler("preformatted",this,&MarkupHandler::startPreformatted); + addEndHandler("preformatted",this,&MarkupHandler::endPreformatted); + + addStartHandler("heading1",this,&MarkupHandler::startHeading1); + addEndHandler("heading1",this,&MarkupHandler::endHeading1); + + addStartHandler("heading2",this,&MarkupHandler::startHeading2); + addEndHandler("heading2",this,&MarkupHandler::endHeading2); + + addStartHandler("heading3",this,&MarkupHandler::startHeading3); + addEndHandler("heading3",this,&MarkupHandler::endHeading3); + + addStartHandler("heading4",this,&MarkupHandler::startHeading4); + addEndHandler("heading4",this,&MarkupHandler::endHeading4); + + addStartHandler("heading5",this,&MarkupHandler::startHeading5); + addEndHandler("heading5",this,&MarkupHandler::endHeading5); + + addStartHandler("heading6",this,&MarkupHandler::startHeading6); + addEndHandler("heading6",this,&MarkupHandler::endHeading6); +} + +MarkupHandler::~MarkupHandler() +{ +} + +void MarkupHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,m_curMarkup,m_headingLevel)); + debug(2,"addTextNode() text=%s markup=%x\n",m_curString.data(),m_curMarkup); + m_curString=""; + } +} + +void MarkupHandler::startBold(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Bold,TRUE)); + m_curMarkup |= IDocMarkup::Bold; +} + +void MarkupHandler::endBold() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Bold,FALSE)); + m_curMarkup &= ~IDocMarkup::Bold; +} + +void MarkupHandler::startEmphasis(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Emphasis,TRUE)); + m_curMarkup |= IDocMarkup::Emphasis; +} + +void MarkupHandler::endEmphasis() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Emphasis,FALSE)); + m_curMarkup &= ~IDocMarkup::Emphasis; +} + +void MarkupHandler::startComputerOutput(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::ComputerOutput,TRUE)); + m_curMarkup |= IDocMarkup::ComputerOutput; +} + +void MarkupHandler::endComputerOutput() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::ComputerOutput,FALSE)); + m_curMarkup &= ~IDocMarkup::ComputerOutput; +} + +void MarkupHandler::startCenter(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Center,TRUE)); + m_curMarkup |= IDocMarkup::Center; +} + +void MarkupHandler::endCenter() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Center,FALSE)); + m_curMarkup &= ~IDocMarkup::Center; +} + +void MarkupHandler::startSmallFont(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::SmallFont,TRUE)); + m_curMarkup |= IDocMarkup::SmallFont; +} + +void MarkupHandler::endSmallFont() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::SmallFont,FALSE)); + m_curMarkup &= ~IDocMarkup::SmallFont; +} + +void MarkupHandler::startSubscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Subscript,TRUE)); + m_curMarkup |= IDocMarkup::Subscript; +} + +void MarkupHandler::endSubscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Subscript,FALSE)); + m_curMarkup &= ~IDocMarkup::Subscript; +} + +void MarkupHandler::startSuperscript(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Superscript,TRUE)); + m_curMarkup |= IDocMarkup::Superscript; +} + +void MarkupHandler::endSuperscript() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Superscript,FALSE)); + m_curMarkup &= ~IDocMarkup::Superscript; +} + +void MarkupHandler::startPreformatted(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Preformatted,TRUE)); + m_curMarkup |= IDocMarkup::Preformatted; +} + +void MarkupHandler::endPreformatted() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Preformatted,FALSE)); + m_curMarkup &= ~IDocMarkup::Preformatted; +} + +void MarkupHandler::startHeading1(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,1)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=1; +} + +void MarkupHandler::endHeading1() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,1)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading2(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,2)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=2; +} + +void MarkupHandler::endHeading2() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,2)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading3(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,3)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=3; +} + +void MarkupHandler::endHeading3() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,3)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading4(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,4)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=4; +} + +void MarkupHandler::endHeading4() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,4)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading5(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,5)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=5; +} + +void MarkupHandler::endHeading5() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,5)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + +void MarkupHandler::startHeading6(const QXmlAttributes & /*attrib*/) +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,TRUE,6)); + m_curMarkup |= IDocMarkup::Heading; + m_headingLevel=6; +} + +void MarkupHandler::endHeading6() +{ + addTextNode(); + m_children.append(new MarkupModifierNode(IDocMarkup::Heading,FALSE,6)); + m_curMarkup &= ~IDocMarkup::Heading; + m_headingLevel=0; +} + + +//---------------------------------------------------------------------- +// ListItemHandler +//---------------------------------------------------------------------- + +ListItemHandler::ListItemHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("listitem",this,&ListItemHandler::endListItem); + + addStartHandler("para",this,&ListItemHandler::startParagraph); +} + +ListItemHandler::~ListItemHandler() +{ +} + +void ListItemHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start list item handler\n"); +} + +void ListItemHandler::endListItem() +{ + debug(2,"end list item handler\n"); + m_parent->setDelegate(0); +} + +void ListItemHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + +IDocIterator *ListItemHandler::contents() const +{ + return new ListItemIterator(*this); +} + +//---------------------------------------------------------------------- +// OrderedListHandler +//---------------------------------------------------------------------- + +OrderedListHandler::OrderedListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("orderedlist",this,&OrderedListHandler::endOrderedList); + addStartHandler("listitem",this,&OrderedListHandler::startOrderedListItem); +} + +OrderedListHandler::~OrderedListHandler() +{ +} + +void OrderedListHandler::startOrderedList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void OrderedListHandler::endOrderedList() +{ + m_parent->setDelegate(0); +} + +void OrderedListHandler::startOrderedListItem(const QXmlAttributes& attrib) +{ + ListItemHandler *liHandler = new ListItemHandler(this); + liHandler->startListItem(attrib); + m_children.append(liHandler); +} + +IDocIterator *OrderedListHandler::elements() const +{ + return new OrderedListIterator(*this); +} + +//---------------------------------------------------------------------- +// ItemizedListHandler +//---------------------------------------------------------------------- + +ItemizedListHandler::ItemizedListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("itemizedlist",this,&ItemizedListHandler::endItemizedList); + addStartHandler("listitem",this,&ItemizedListHandler::startItemizedListItem); +} + +ItemizedListHandler::~ItemizedListHandler() +{ +} + +void ItemizedListHandler::startItemizedList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void ItemizedListHandler::endItemizedList() +{ + m_parent->setDelegate(0); +} + +void ItemizedListHandler::startItemizedListItem(const QXmlAttributes& attrib) +{ + ListItemHandler *liHandler = new ListItemHandler(this); + liHandler->startListItem(attrib); + m_children.append(liHandler); +} + +IDocIterator *ItemizedListHandler::elements() const +{ + return new ItemizedListIterator(*this); +} + +//---------------------------------------------------------------------- +// TocListHandler +//---------------------------------------------------------------------- + +TocListHandler::TocListHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("toclist",this,&TocListHandler::endTocList); + addStartHandler("tocitem",this,&TocListHandler::startTocItem); +} + +TocListHandler::~TocListHandler() +{ +} + +void TocListHandler::startTocList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void TocListHandler::endTocList() +{ + m_parent->setDelegate(0); +} + +void TocListHandler::startTocItem(const QXmlAttributes& attrib) +{ + TocItemHandler *tiHandler = new TocItemHandler(this); + tiHandler->startTocItem(attrib); + m_children.append(tiHandler); +} + +IDocIterator *TocListHandler::elements() const +{ + return new TocListIterator(*this); +} + +//---------------------------------------------------------------------- +// TocItemHandler +//---------------------------------------------------------------------- + +TocItemHandler::TocItemHandler(IBaseHandler *parent) : m_parent(parent) +{ + addEndHandler("tocitem",this,&TocItemHandler::endTocItem); +} + +TocItemHandler::~TocItemHandler() +{ +} + +void TocItemHandler::startTocItem(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_id = attrib.value("id"); + m_curString=""; +} + +void TocItemHandler::endTocItem() +{ + m_title = m_curString; + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ParameterHandler +//---------------------------------------------------------------------- + +ParameterHandler::ParameterHandler(IBaseHandler *parent) : + m_parent(parent) +{ + addEndHandler("parametername",this,&ParameterHandler::endParameterName); +} + +ParameterHandler::~ParameterHandler() +{ +} + +void ParameterHandler::startParameterName(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void ParameterHandler::endParameterName() +{ + m_name = m_curString; + debug(2,"parameter %s\n",m_name.data()); + m_curString=""; + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ParameterListHandler +//---------------------------------------------------------------------- + +ParameterItemHandler::ParameterItemHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("parameteritem",this,&ParameterItemHandler::endParameterItem); + addStartHandler("parameternamelist"); + addEndHandler("parameternamelist"); + addStartHandler("parametername",this,&ParameterItemHandler::startParameterName); + addStartHandler("parameterdescription"); + addEndHandler("parameterdescription"); + addStartHandler("para",this,&ParameterItemHandler::startParagraph); + m_parameters.setAutoDelete(TRUE); + m_description = 0; +} + +ParameterItemHandler::~ParameterItemHandler() +{ + delete m_description; +} + +void ParameterItemHandler::startParameterItem(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void ParameterItemHandler::endParameterItem() +{ + m_parent->setDelegate(0); +} + +void ParameterItemHandler::startParameterName(const QXmlAttributes& attrib) +{ + ParameterHandler *param = new ParameterHandler(this); + m_parameters.append(param); + param->startParameterName(attrib); +} + +void ParameterItemHandler::startParagraph(const QXmlAttributes& attrib) +{ + m_description = new ParagraphHandler(this); + m_description->startParagraph(attrib); +} + +IDocIterator *ParameterItemHandler::paramNames() const +{ + return new ParameterItemIterator(*this); +} + +//---------------------------------------------------------------------- +// ParameterListHandler +//---------------------------------------------------------------------- + +ParameterListHandler::ParameterListHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("parameterlist",this,&ParameterListHandler::endParameterList); + addStartHandler("parameteritem",this,&ParameterListHandler::startParameterItem); + m_paramItems.setAutoDelete(TRUE); +} + +ParameterListHandler::~ParameterListHandler() +{ +} + +void ParameterListHandler::startParameterList(const QXmlAttributes& attrib) +{ + QString kind = attrib.value("kind"); + if (kind=="retval") m_type=RetVal; + else if (kind=="exception") m_type=Exception; + else if (kind=="param") m_type=Param; + else + { + debug(1,"Error: invalid parameterlist type: %s\n",kind.data()); + } + debug(2,"parameterlist kind=%s\n",kind.data()); + m_parent->setDelegate(this); +} + +void ParameterListHandler::endParameterList() +{ + m_parent->setDelegate(0); +} + +void ParameterListHandler::startParameterItem(const QXmlAttributes& attrib) +{ + ParameterItemHandler *paramItem = new ParameterItemHandler(this); + m_paramItems.append(paramItem); + paramItem->startParameterItem(attrib); +} + +IDocIterator *ParameterListHandler::params() const +{ + return new ParameterListIterator(*this); +} + +//---------------------------------------------------------------------- +// LinkHandler +//---------------------------------------------------------------------- + +LinkHandler::LinkHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("link",this,&LinkHandler::endLink); +} + +LinkHandler::~LinkHandler() +{ +} + +void LinkHandler::startLink(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start link\n"); + m_ref = attrib.value("linkend"); + m_curString=""; +} + +void LinkHandler::endLink() +{ + m_text = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End link\n"); +} + +//---------------------------------------------------------------------- +// EMailHandler +//---------------------------------------------------------------------- + +EMailHandler::EMailHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("email",this,&EMailHandler::endEMail); +} + +EMailHandler::~EMailHandler() +{ +} + +void EMailHandler::startEMail(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start email\n"); + m_curString=""; +} + +void EMailHandler::endEMail() +{ + m_address = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End email\n"); +} + +//---------------------------------------------------------------------- +// ULinkHandler +//---------------------------------------------------------------------- + +ULinkHandler::ULinkHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("ulink",this,&ULinkHandler::endULink); +} + +ULinkHandler::~ULinkHandler() +{ +} + +void ULinkHandler::startULink(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start ulink\n"); + m_url = attrib.value("url"); + m_curString=""; +} + +void ULinkHandler::endULink() +{ + m_text = m_curString; + m_curString=""; + m_parent->setDelegate(0); + debug(2,"End ulink\n"); +} + +//---------------------------------------------------------------------- +// LineBreakHandler +//---------------------------------------------------------------------- + +LineBreakHandler::LineBreakHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("linebreak",this,&LineBreakHandler::endLineBreak); +} + +LineBreakHandler::~LineBreakHandler() +{ +} + +void LineBreakHandler::startLineBreak(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start linebreak\n"); +} + +void LineBreakHandler::endLineBreak() +{ + m_parent->setDelegate(0); + debug(2,"End linebreak\n"); +} + +//---------------------------------------------------------------------- +// HRulerHandler +//---------------------------------------------------------------------- + +HRulerHandler::HRulerHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("hruler",this,&HRulerHandler::endHRuler); +} + +HRulerHandler::~HRulerHandler() +{ +} + +void HRulerHandler::startHRuler(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start hruler\n"); +} + +void HRulerHandler::endHRuler() +{ + m_parent->setDelegate(0); + debug(2,"End hruler\n"); +} + +//---------------------------------------------------------------------- +// RefHandler +//---------------------------------------------------------------------- + +RefHandler::RefHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("ref",this,&RefHandler::endRef); +} + +RefHandler::~RefHandler() +{ +} + +void RefHandler::startRef(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_refId = attrib.value("refid"); + m_extId = attrib.value("external"); + ASSERT(attrib.value("kindref")=="compound" || + attrib.value("kindref")=="member"); + m_targetKind = attrib.value("kindref")=="compound" ? Compound : Member; + debug(2,"Start ref refId=%s\n",m_refId.data()); + m_curString=""; +} + +void RefHandler::endRef() +{ + m_linkText = m_curString; + m_parent->setDelegate(0); + debug(2,"End ref: text=`%s'\n",m_linkText.data()); +} + + +//---------------------------------------------------------------------- +// TitleHandler +//---------------------------------------------------------------------- + +TitleHandler::TitleHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + m_markupHandler = new MarkupHandler(m_children,m_curString); + setFallBackHandler(m_markupHandler); + addStartHandler("ref",this,&TitleHandler::startRef); + addEndHandler("title",this,&TitleHandler::endTitle); +} + +TitleHandler::~TitleHandler() +{ + delete m_markupHandler; +} + +void TitleHandler::startTitle(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"Start title\n"); + m_curString=""; +} + +void TitleHandler::endTitle() +{ + addTextNode(); + m_parent->setDelegate(0); + debug(2,"End title\n"); +} + +void TitleHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append( + new TextNode( + m_curString, + m_markupHandler->markup(), + m_markupHandler->headingLevel() + ) + ); + debug(2,"addTextNode() text=\"%s\" markup=%x headingLevel=%d\n", + m_curString.data(),m_markupHandler->markup(),m_markupHandler->headingLevel()); + m_curString=""; + } +} + +void TitleHandler::startRef(const QXmlAttributes& attrib) +{ + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +IDocIterator *TitleHandler::title() const +{ + return new TitleIterator(*this); +} + +//---------------------------------------------------------------------- +// SimpleSectHandler +//---------------------------------------------------------------------- + +SimpleSectHandler::SimpleSectHandler(IBaseHandler *parent) + : m_parent(parent), m_paragraph(0), m_title(0) +{ + addStartHandler("title",this,&SimpleSectHandler::startTitle); + addStartHandler("para",this,&SimpleSectHandler::startParagraph); + addEndHandler("simplesect",this,&SimpleSectHandler::endSimpleSect); +} + +SimpleSectHandler::~SimpleSectHandler() +{ +} + +void SimpleSectHandler::startSimpleSect(const QXmlAttributes& attrib) +{ + m_typeString = attrib.value("kind"); + m_type = s_typeMapper->stringToType(m_typeString); + debug(2,"start simple section %s\n",m_typeString.data()); + m_parent->setDelegate(this); +} + +void SimpleSectHandler::endSimpleSect() +{ + debug(2,"end simple section\n"); + m_parent->setDelegate(0); +} + +void SimpleSectHandler::startTitle(const QXmlAttributes& attrib) +{ + ASSERT(m_title==0); + m_title = new TitleHandler(this); + m_title->startTitle(attrib); +} + +void SimpleSectHandler::startParagraph(const QXmlAttributes& attrib) +{ + ASSERT(m_paragraph==0); + m_paragraph = new ParagraphHandler(this); + m_paragraph->startParagraph(attrib); +} + +//---------------------------------------------------------------------- +// VariableListEntryHandler +//---------------------------------------------------------------------- + +VariableListEntryHandler::VariableListEntryHandler(IBaseHandler *parent) + : m_parent(parent), m_description(0), m_linkedTextHandler(0) +{ + addStartHandler("term",this,&VariableListEntryHandler::startTerm); + addEndHandler("term",this,&VariableListEntryHandler::endTerm); + addStartHandler("para",this,&VariableListEntryHandler::startParagraph); + addEndHandler("varlistentry",this,&VariableListEntryHandler::endVarListEntry); + addEndHandler("listitem",this,&VariableListEntryHandler::endListItem); +} + +VariableListEntryHandler::~VariableListEntryHandler() +{ + delete m_description; +} + +void VariableListEntryHandler::startVarListEntry(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start varlistentry\n"); +} + +void VariableListEntryHandler::endVarListEntry() +{ + m_parent->setDelegate(0); + debug(2,"end varlistentry\n"); +} + +void VariableListEntryHandler::startListItem(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start listitem\n"); +} + +void VariableListEntryHandler::endListItem() +{ + m_parent->setDelegate(0); + debug(2,"end listitem\n"); +} + +void VariableListEntryHandler::startTerm(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; + m_linkedTextHandler = new LinkedTextHandler(this,m_term); + m_linkedTextHandler->start("term"); +} + +void VariableListEntryHandler::endTerm() +{ + delete m_linkedTextHandler; +} + +void VariableListEntryHandler::startParagraph(const QXmlAttributes& attrib) +{ + ASSERT(m_description==0); + m_description = new ParagraphHandler(this); + m_description->startParagraph(attrib); +} + +ILinkedTextIterator *VariableListEntryHandler::term() const +{ + return new LinkedTextIterator(m_term); +} + + +//---------------------------------------------------------------------- +// VariableListHandler +//---------------------------------------------------------------------- + +VariableListHandler::VariableListHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_entries.setAutoDelete(TRUE); + addStartHandler("varlistentry",this,&VariableListHandler::startVarListEntry); + addStartHandler("listitem",this,&VariableListHandler::startListItem); + addEndHandler("variablelist",this,&VariableListHandler::endVariableList); +} + +VariableListHandler::~VariableListHandler() +{ +} + +void VariableListHandler::startVariableList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start variablelist\n"); +} + +void VariableListHandler::endVariableList() +{ + debug(2,"end variablelist\n"); + m_parent->setDelegate(0); +} + +void VariableListHandler::startVarListEntry(const QXmlAttributes& attrib) +{ + VariableListEntryHandler *vle = new VariableListEntryHandler(this); + vle->startVarListEntry(attrib); + m_curEntry = vle; + m_entries.append(vle); +} + +void VariableListHandler::startListItem(const QXmlAttributes& attrib) +{ + ASSERT(m_curEntry!=0); + m_curEntry->startListItem(attrib); +} + +IDocIterator *VariableListHandler::entries() const +{ + return new VariableListIterator(*this); +} + +//---------------------------------------------------------------------- +// HighlightHandler +//---------------------------------------------------------------------- + +HighlightHandler::HighlightHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("highlight",this,&HighlightHandler::endHighlight); + addStartHandler("ref",this,&HighlightHandler::startRef); + addStartHandler("sp",this,&HighlightHandler::startSpace); + m_hl = IDocHighlight::Invalid; +} + +HighlightHandler::~HighlightHandler() +{ +} + +void HighlightHandler::startHighlight(const QXmlAttributes& attrib) +{ + m_hlString = attrib.value("class"); + m_hl = s_highlightMapper->stringToKind(m_hlString); + m_curString=""; + m_parent->setDelegate(this); + debug(2,"start highlight\n"); +} + +void HighlightHandler::endHighlight() +{ + addTextNode(); + debug(2,"end highlight class=`%s'\n",m_hlString.data()); + m_parent->setDelegate(0); +} + +void HighlightHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *rh = new RefHandler(this); + m_children.append(rh); + rh->startRef(attrib); +} + +void HighlightHandler::startSpace(const QXmlAttributes&) +{ + m_curString=" "; + addTextNode(); +} + +void HighlightHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,IDocMarkup::Normal,0)); + debug(2,"addTextNode() text=\"%s\"\n", + m_curString.data()); + m_curString=""; + } +} + +IDocIterator *HighlightHandler::codeElements() const +{ + return new HighlightIterator(*this); +} + +//---------------------------------------------------------------------- +// CodeLineHandler +//---------------------------------------------------------------------- + +CodeLineHandler::CodeLineHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("codeline",this,&CodeLineHandler::endCodeLine); + addEndHandler("linenumber",this,&CodeLineHandler::endLineNumber); + addStartHandler("highlight",this,&CodeLineHandler::startHighlight); + addStartHandler("ref",this,&CodeLineHandler::startRef); + m_lineNumber = 0; +} + +CodeLineHandler::~CodeLineHandler() +{ +} + +void CodeLineHandler::startCodeLine(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start codeline\n"); +} + +void CodeLineHandler::endCodeLine() +{ + addTextNode(); + debug(2,"end codeline\n"); + m_parent->setDelegate(0); +} + +void CodeLineHandler::startLineNumber(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"start linenumber\n"); + m_lineNumber = attrib.value("line").toInt(); + m_refId = attrib.value("refid"); +} + +void CodeLineHandler::endLineNumber() +{ + m_parent->setDelegate(0); +} + +void CodeLineHandler::startHighlight(const QXmlAttributes& attrib) +{ + addTextNode(); + HighlightHandler *hlh = new HighlightHandler(this); + m_children.append(hlh); + hlh->startHighlight(attrib); +} + +void CodeLineHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *rh = new RefHandler(this); + m_children.append(rh); + rh->startRef(attrib); +} + +void CodeLineHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new TextNode(m_curString,IDocMarkup::Normal,0)); + debug(2,"addTextNode() text=\"%s\"\n", + m_curString.data()); + m_curString=""; + } +} + +IDocIterator *CodeLineHandler::codeElements() const +{ + return new CodeLineIterator(*this); +} + + +//---------------------------------------------------------------------- +// ProgramListingHandler +//---------------------------------------------------------------------- + +ProgramListingHandler::ProgramListingHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + m_hasLineNumber=FALSE; + addEndHandler("programlisting",this,&ProgramListingHandler::endProgramListing); + + addStartHandler("linenumber",this,&ProgramListingHandler::startLineNumber); + addStartHandler("codeline",this,&ProgramListingHandler::startCodeLine); +} + +ProgramListingHandler::~ProgramListingHandler() +{ +} + +void ProgramListingHandler::startProgramListing(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start programlisting\n"); +} + +void ProgramListingHandler::endProgramListing() +{ + debug(2,"end programlisting\n"); + m_parent->setDelegate(0); +} + +void ProgramListingHandler::startLineNumber(const QXmlAttributes& attrib) +{ + CodeLineHandler *clh = new CodeLineHandler(this); + m_children.append(clh); + m_hasLineNumber=TRUE; + clh->startLineNumber(attrib); +} + +void ProgramListingHandler::startCodeLine(const QXmlAttributes& attrib) +{ + CodeLineHandler *clh = 0; + if (!m_hasLineNumber) + { + clh = new CodeLineHandler(this); + m_children.append(clh); + } + else + { + clh = m_children.getLast(); + } + ASSERT(clh!=0); + clh->startCodeLine(attrib); + m_hasLineNumber=FALSE; +} + +IDocIterator *ProgramListingHandler::codeLines() const +{ + return new ProgramListingIterator(*this); +} + + + +//---------------------------------------------------------------------- +// FormulaHandler +//---------------------------------------------------------------------- + +FormulaHandler::FormulaHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("formula",this,&FormulaHandler::endFormula); +} + +FormulaHandler::~FormulaHandler() +{ +} + +void FormulaHandler::startFormula(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_curString=""; + m_parent->setDelegate(this); +} + +void FormulaHandler::endFormula() +{ + m_text = m_curString; + debug(2,"formula id=`%s' text=`%s'\n",m_id.data(),m_text.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// AnchorHandler +//---------------------------------------------------------------------- + +AnchorHandler::AnchorHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("anchor",this,&AnchorHandler::endAnchor); +} + +AnchorHandler::~AnchorHandler() +{ +} + +void AnchorHandler::startAnchor(const QXmlAttributes& attrib) +{ + m_id = attrib.value("id"); + m_parent->setDelegate(this); +} + +void AnchorHandler::endAnchor() +{ + debug(2,"anchor id=`%s'\n",m_id.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// ImageHandler +//---------------------------------------------------------------------- + +ImageHandler::ImageHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("image",this,&ImageHandler::endImage); +} + +ImageHandler::~ImageHandler() +{ +} + +void ImageHandler::startImage(const QXmlAttributes& attrib) +{ + m_name = attrib.value("name"); + m_curString=""; + m_parent->setDelegate(this); +} + +void ImageHandler::endImage() +{ + m_caption = m_curString; + debug(2,"image name=`%s' caption=`%s'\n",m_name.data(),m_caption.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// DotFileHandler +//---------------------------------------------------------------------- + +DotFileHandler::DotFileHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("dotfile",this,&DotFileHandler::endDotFile); +} + +DotFileHandler::~DotFileHandler() +{ +} + +void DotFileHandler::startDotFile(const QXmlAttributes& attrib) +{ + m_name = attrib.value("name"); + m_curString=""; + m_parent->setDelegate(this); +} + +void DotFileHandler::endDotFile() +{ + m_caption = m_curString; + debug(2,"image name=`%s' caption=`%s'\n",m_name.data(),m_caption.data()); + m_parent->setDelegate(0); +} + +//---------------------------------------------------------------------- +// IndexEntryHandler +//---------------------------------------------------------------------- + +IndexEntryHandler::IndexEntryHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("indexentry",this,&IndexEntryHandler::endIndexEntry); + addStartHandler("primaryie",this,&IndexEntryHandler::startPrimaryIE); + addEndHandler("primaryie",this,&IndexEntryHandler::endPrimaryIE); + addStartHandler("secondaryie",this,&IndexEntryHandler::startSecondaryIE); + addEndHandler("secondaryie",this,&IndexEntryHandler::endSecondaryIE); +} + +IndexEntryHandler::~IndexEntryHandler() +{ +} + +void IndexEntryHandler::startIndexEntry(const QXmlAttributes& /*attrib*/) +{ + debug(2,"start index entry\n"); + m_parent->setDelegate(this); +} + +void IndexEntryHandler::endIndexEntry() +{ + debug(2,"index entry primary=`%s' secondary=`%s'\n", + m_primary.data(),m_secondary.data()); + m_parent->setDelegate(0); +} + +void IndexEntryHandler::startPrimaryIE(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void IndexEntryHandler::endPrimaryIE() +{ + m_primary = m_curString; +} + +void IndexEntryHandler::startSecondaryIE(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void IndexEntryHandler::endSecondaryIE() +{ + m_secondary = m_curString; +} + +//---------------------------------------------------------------------- +// EntryHandler +//---------------------------------------------------------------------- + +EntryHandler::EntryHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("entry",this,&EntryHandler::endEntry); + addStartHandler("para",this,&EntryHandler::startParagraph); +} + +EntryHandler::~EntryHandler() +{ +} + +void EntryHandler::startEntry(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void EntryHandler::endEntry() +{ + m_parent->setDelegate(0); +} + +void EntryHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *ph = new ParagraphHandler(this); + ph->startParagraph(attrib); + m_children.append(ph); +} + +IDocIterator *EntryHandler::contents() const +{ + return new EntryIterator(*this); +} + +//---------------------------------------------------------------------- +// RowHandler +//---------------------------------------------------------------------- + +RowHandler::RowHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("row",this,&RowHandler::endRow); + addStartHandler("entry",this,&RowHandler::startEntry); +} + +RowHandler::~RowHandler() +{ +} + +void RowHandler::startRow(const QXmlAttributes&) +{ + m_parent->setDelegate(this); +} + +void RowHandler::endRow() +{ + m_parent->setDelegate(0); +} + +void RowHandler::startEntry(const QXmlAttributes& attrib) +{ + EntryHandler *eh = new EntryHandler(this); + eh->startEntry(attrib); + m_children.append(eh); +} + +IDocIterator *RowHandler::entries() const +{ + return new RowIterator(*this); +} + +//---------------------------------------------------------------------- +// TableHandler +//---------------------------------------------------------------------- + +TableHandler::TableHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + addEndHandler("table",this,&TableHandler::endTable); + addStartHandler("row",this,&TableHandler::startRow); + addStartHandler("caption",this,&TableHandler::startCaption); + addEndHandler("caption",this,&TableHandler::endCaption); +} + +TableHandler::~TableHandler() +{ +} + +void TableHandler::startTable(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_numColumns = attrib.value("cols").toInt(); + debug(2,"table cols=%d\n",m_numColumns); +} + +void TableHandler::endTable() +{ + m_parent->setDelegate(0); +} + +void TableHandler::startRow(const QXmlAttributes& attrib) +{ + RowHandler *rh = new RowHandler(this); + rh->startRow(attrib); + m_children.append(rh); +} + +void TableHandler::startCaption(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void TableHandler::endCaption() +{ + m_caption = m_curString; +} + +IDocIterator *TableHandler::rows() const +{ + return new TableIterator(*this); +} + +//---------------------------------------------------------------------- +// CopyHandler +//---------------------------------------------------------------------- + +CopyHandler::CopyHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("copydoc",this,&CopyHandler::endCopy); + + addStartHandler("para",this,&CopyHandler::startParagraph); +} + +CopyHandler::~CopyHandler() +{ +} + +void CopyHandler::startCopy(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start copy handler\n"); +} + +void CopyHandler::endCopy() +{ + debug(2,"end copy handler\n"); + m_parent->setDelegate(0); +} + +void CopyHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + +IDocIterator *CopyHandler::contents() const +{ + return new CopyIterator(*this); +} + +//---------------------------------------------------------------------- +// VerbatimHandler +//---------------------------------------------------------------------- + +VerbatimHandler::VerbatimHandler(IBaseHandler *parent) + : m_parent(parent), m_type(IDocVerbatim::Invalid) +{ + addEndHandler("verbatim",this,&VerbatimHandler::endVerbatim); + addEndHandler("latexonly",this,&VerbatimHandler::endVerbatim); + addEndHandler("htmlonly",this,&VerbatimHandler::endVerbatim); +} + +VerbatimHandler::~VerbatimHandler() +{ +} + +void VerbatimHandler::startVerbatim(const QXmlAttributes&,Types type) +{ + m_type = type; + m_parent->setDelegate(this); + m_curString=""; +} + +void VerbatimHandler::endVerbatim() +{ + m_text = m_curString; + m_parent->setDelegate(0); +} + + +//---------------------------------------------------------------------- +// SymbolHandler +//---------------------------------------------------------------------- + +SymbolHandler::SymbolHandler(IBaseHandler *parent,Types type) + : m_parent(parent), m_letter('\0'), m_type(type) +{ + addEndHandler("symbol"); + switch (type) + { + case IDocSymbol::Invalid: m_typeString="invalid"; break; + case IDocSymbol::Umlaut: m_typeString="umlaut"; break; + case IDocSymbol::Acute: m_typeString="acute"; break; + case IDocSymbol::Grave: m_typeString="grave"; break; + case IDocSymbol::Circ: m_typeString="circ"; break; + case IDocSymbol::Tilde: m_typeString="tilde"; break; + case IDocSymbol::Szlig: m_typeString="szlig"; break; + case IDocSymbol::Cedil: m_typeString="cedil"; break; + case IDocSymbol::Ring: m_typeString="ring"; break; + case IDocSymbol::Nbsp: m_typeString="nbsp"; break; + case IDocSymbol::Copy: m_typeString="copy"; break; + } +} + +SymbolHandler::~SymbolHandler() +{ +} + +void SymbolHandler::startSymbol(const QXmlAttributes& attrib) +{ + QString ls = attrib.value("char"); + if (!ls.isEmpty()) m_letter = ls.latin1()[0]; +} + +//---------------------------------------------------------------------- +// ParagraphHandler +//---------------------------------------------------------------------- + +ParagraphHandler::ParagraphHandler(IBaseHandler *parent) + : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + m_markupHandler = new MarkupHandler(m_children,m_curString); + + // preformatted + setFallBackHandler(m_markupHandler); + + addEndHandler("para",this,&ParagraphHandler::endParagraph); + + addStartHandler("linebreak",this,&ParagraphHandler::startLineBreak); + addStartHandler("hruler",this,&ParagraphHandler::startHRuler); + addStartHandler("programlisting",this,&ParagraphHandler::startProgramListing); + addStartHandler("verbatim",this,&ParagraphHandler::startVerbatim); + addStartHandler("indexentry",this,&ParagraphHandler::startIndexEntry); + addStartHandler("orderedlist",this,&ParagraphHandler::startOrderedList); + addStartHandler("itemizedlist",this,&ParagraphHandler::startItemizedList); + addStartHandler("simplesect",this,&ParagraphHandler::startSimpleSect); + // TODO: title + addStartHandler("variablelist",this,&ParagraphHandler::startVariableList); + addStartHandler("table",this,&ParagraphHandler::startTable); + // TODO: heading + addStartHandler("image",this,&ParagraphHandler::startImage); + addStartHandler("dotfile",this,&ParagraphHandler::startDotFile); + addStartHandler("toclist",this,&ParagraphHandler::startTocList); + // TODO: language??? + addStartHandler("parameterlist",this,&ParagraphHandler::startParameterList); + // TODO: xrefsect + addStartHandler("copydoc",this,&ParagraphHandler::startCopyDoc); + + addStartHandler("ref",this,&ParagraphHandler::startRef); + addStartHandler("ulink",this,&ParagraphHandler::startULink); + addStartHandler("email",this,&ParagraphHandler::startEMail); + addStartHandler("link",this,&ParagraphHandler::startLink); + addStartHandler("formula",this,&ParagraphHandler::startFormula); + addStartHandler("latexonly",this,&ParagraphHandler::startHtmlOnly); + addStartHandler("htmlonly",this,&ParagraphHandler::startLatexOnly); + addStartHandler("umlaut",this,&ParagraphHandler::startUmlaut); + addStartHandler("acute",this,&ParagraphHandler::startAcute); + addStartHandler("grave",this,&ParagraphHandler::startGrave); + addStartHandler("circ",this,&ParagraphHandler::startCirc); + addStartHandler("tilde",this,&ParagraphHandler::startTilde); + addStartHandler("szlig",this,&ParagraphHandler::startSzlig); + addStartHandler("cedil",this,&ParagraphHandler::startCedil); + addStartHandler("ring",this,&ParagraphHandler::startRing); + addStartHandler("nbsp",this,&ParagraphHandler::startNbsp); + addStartHandler("copy",this,&ParagraphHandler::startCopy); + addStartHandler("anchor",this,&ParagraphHandler::startAnchor); +} + +ParagraphHandler::~ParagraphHandler() +{ + delete m_markupHandler; +} + +void ParagraphHandler::startParagraph(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"para\n"); +} + +void ParagraphHandler::endParagraph() +{ + addTextNode(); + debug(2,"end para\n"); + m_parent->setDelegate(0); +} + +void ParagraphHandler::startItemizedList(const QXmlAttributes& attrib) +{ + addTextNode(); + ItemizedListHandler *listHandler = new ItemizedListHandler(this); + listHandler->startItemizedList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startOrderedList(const QXmlAttributes& attrib) +{ + addTextNode(); + OrderedListHandler *listHandler = new OrderedListHandler(this); + listHandler->startOrderedList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startParameterList(const QXmlAttributes& attrib) +{ + addTextNode(); + ParameterListHandler *listHandler = new ParameterListHandler(this); + listHandler->startParameterList(attrib); + m_children.append(listHandler); +} + +void ParagraphHandler::startSimpleSect(const QXmlAttributes& attrib) +{ + addTextNode(); + SimpleSectHandler *sectHandler = new SimpleSectHandler(this); + sectHandler->startSimpleSect(attrib); + m_children.append(sectHandler); +} + +void ParagraphHandler::startRef(const QXmlAttributes& attrib) +{ + addTextNode(); + RefHandler *ref = new RefHandler(this); + ref->startRef(attrib); + m_children.append(ref); +} + +void ParagraphHandler::startVariableList(const QXmlAttributes& attrib) +{ + addTextNode(); + VariableListHandler *vl = new VariableListHandler(this); + vl->startVariableList(attrib); + m_children.append(vl); +} + +void ParagraphHandler::startHRuler(const QXmlAttributes& attrib) +{ + addTextNode(); + HRulerHandler *hr = new HRulerHandler(this); + hr->startHRuler(attrib); + m_children.append(hr); +} + +void ParagraphHandler::startLineBreak(const QXmlAttributes& attrib) +{ + addTextNode(); + LineBreakHandler *lb = new LineBreakHandler(this); + lb->startLineBreak(attrib); + m_children.append(lb); +} + +void ParagraphHandler::startULink(const QXmlAttributes& attrib) +{ + addTextNode(); + ULinkHandler *uh = new ULinkHandler(this); + uh->startULink(attrib); + m_children.append(uh); +} + +void ParagraphHandler::startEMail(const QXmlAttributes& attrib) +{ + addTextNode(); + EMailHandler *eh = new EMailHandler(this); + eh->startEMail(attrib); + m_children.append(eh); +} + +void ParagraphHandler::startLink(const QXmlAttributes& attrib) +{ + addTextNode(); + LinkHandler *lh = new LinkHandler(this); + lh->startLink(attrib); + m_children.append(lh); +} + +void ParagraphHandler::startProgramListing(const QXmlAttributes& attrib) +{ + addTextNode(); + ProgramListingHandler *pl = new ProgramListingHandler(this); + pl->startProgramListing(attrib); + m_children.append(pl); +} + +void ParagraphHandler::startFormula(const QXmlAttributes& attrib) +{ + addTextNode(); + FormulaHandler *fh = new FormulaHandler(this); + fh->startFormula(attrib); + m_children.append(fh); +} + +void ParagraphHandler::startImage(const QXmlAttributes& attrib) +{ + addTextNode(); + ImageHandler *ih = new ImageHandler(this); + ih->startImage(attrib); + m_children.append(ih); +} + +void ParagraphHandler::startDotFile(const QXmlAttributes& attrib) +{ + addTextNode(); + DotFileHandler *df = new DotFileHandler(this); + df->startDotFile(attrib); + m_children.append(df); +} + +void ParagraphHandler::startIndexEntry(const QXmlAttributes& attrib) +{ + addTextNode(); + IndexEntryHandler *df = new IndexEntryHandler(this); + df->startIndexEntry(attrib); + m_children.append(df); +} + +void ParagraphHandler::startTable(const QXmlAttributes& attrib) +{ + addTextNode(); + TableHandler *th = new TableHandler(this); + th->startTable(attrib); + m_children.append(th); +} + +void ParagraphHandler::startVerbatim(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::Verbatim); + m_children.append(vh); +} + +void ParagraphHandler::startHtmlOnly(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::HtmlOnly); + m_children.append(vh); +} + +void ParagraphHandler::startLatexOnly(const QXmlAttributes& attrib) +{ + addTextNode(); + VerbatimHandler *vh = new VerbatimHandler(this); + vh->startVerbatim(attrib,IDocVerbatim::LatexOnly); + m_children.append(vh); +} + +void ParagraphHandler::startUmlaut(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Umlaut); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startAcute(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Acute); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startGrave(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Grave); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCirc(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Circ); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startTilde(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Tilde); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startSzlig(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Szlig); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCedil(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Cedil); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startRing(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Ring); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startNbsp(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Nbsp); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startCopy(const QXmlAttributes& attrib) +{ + addTextNode(); + SymbolHandler *sh = new SymbolHandler(this,IDocSymbol::Copy); + sh->startSymbol(attrib); + m_children.append(sh); +} + +void ParagraphHandler::startAnchor(const QXmlAttributes& attrib) +{ + addTextNode(); + AnchorHandler *ah = new AnchorHandler(this); + ah->startAnchor(attrib); + m_children.append(ah); +} + +void ParagraphHandler::startCopyDoc(const QXmlAttributes& attrib) +{ + addTextNode(); + CopyHandler *ch = new CopyHandler(this); + ch->startCopy(attrib); + m_children.append(ch); +} + +void ParagraphHandler::startTocList(const QXmlAttributes& attrib) +{ + addTextNode(); + TocListHandler *th = new TocListHandler(this); + th->startTocList(attrib); + m_children.append(th); +} + +void ParagraphHandler::addTextNode() +{ + if (!m_curString.isEmpty()) + { + m_children.append( + new TextNode( + m_curString, + m_markupHandler->markup(), + m_markupHandler->headingLevel() + ) + ); + debug(2,"addTextNode() text=\"%s\" markup=%x headingLevel=%d\n", + m_curString.data(),m_markupHandler->markup(),m_markupHandler->headingLevel()); + m_curString=""; + } +} + +IDocIterator *ParagraphHandler::contents() const +{ + return new ParagraphIterator(*this); +} + +//---------------------------------------------------------------------- +// DocSectionHandler +//---------------------------------------------------------------------- + +DocSectionHandler::DocSectionHandler(IBaseHandler *parent,int level) + : m_parent(parent), m_internal(0), m_level(level), m_title(0) +{ + QString sectionKey; + m_paragraphs.setAutoDelete(TRUE); + m_subsections.setAutoDelete(TRUE); + addStartHandler("title",this,&DocSectionHandler::startTitle); + addStartHandler("para",this,&DocSectionHandler::startParagraph); + if (level<6) + { + sectionKey.sprintf("sect%d",level+1); + addStartHandler(sectionKey,this,&DocSectionHandler::startSubSection); + } + addStartHandler("internal",this,&DocSectionHandler::startInternal); + sectionKey.sprintf("sect%d",level); + addEndHandler(sectionKey,this,&DocSectionHandler::endDocSection); +} + +DocSectionHandler::~DocSectionHandler() +{ +} + +void DocSectionHandler::startDocSection(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + debug(2,"Start docsection\n"); + m_id = attrib.value("id"); +} + +void DocSectionHandler::endDocSection() +{ + m_parent->setDelegate(0); + debug(2,"End docsection\n"); +} + +void DocSectionHandler::startSubSection(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,m_level+1); + secHandler->startDocSection(attrib); + m_subsections.append(secHandler); +} + +void DocSectionHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_paragraphs.append(parHandler); +} + +void DocSectionHandler::startInternal(const QXmlAttributes& attrib) +{ + m_internal = new DocInternalHandler(this,m_level); + m_internal->startInternal(attrib); +} + +void DocSectionHandler::startTitle(const QXmlAttributes& attrib) +{ + m_title = new TitleHandler(this); + m_title->startTitle(attrib); +} + +IDocIterator *DocSectionHandler::paragraphs() const +{ + return new DocSectionParaIterator(*this); +} + +IDocIterator *DocSectionHandler::subSections() const +{ + return new DocSectionSubIterator(*this); +} + +IDocInternal *DocSectionHandler::internal() const +{ + return m_internal; +} + +//---------------------------------------------------------------------- +// DocInternal +//---------------------------------------------------------------------- + +DocInternalHandler::DocInternalHandler(IBaseHandler *parent,int level) + : m_parent(parent), m_level(level) +{ + m_paragraphs.setAutoDelete(TRUE); + m_subsections.setAutoDelete(TRUE); + addStartHandler("para",this,&DocInternalHandler::startParagraph); + QString sectionKey; + sectionKey.sprintf("sect%d",level+1); + addStartHandler(sectionKey,this,&DocInternalHandler::startSubSection); + addEndHandler("internal",this,&DocInternalHandler::endInternal); +} + +DocInternalHandler::~DocInternalHandler() +{ +} + +void DocInternalHandler::startInternal(const QXmlAttributes&) +{ + m_parent->setDelegate(this); + debug(2,"Start internal\n"); +} + +void DocInternalHandler::endInternal() +{ + m_parent->setDelegate(0); + debug(2,"End internal\n"); +} + +void DocInternalHandler::startSubSection(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,m_level+1); + secHandler->startDocSection(attrib); + m_subsections.append(secHandler); +} + +void DocInternalHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_paragraphs.append(parHandler); +} + +IDocIterator *DocInternalHandler::paragraphs() const +{ + return new DocInternalParaIterator(*this); +} + +IDocIterator *DocInternalHandler::subSections() const +{ + return new DocInternalSubIterator(*this); +} + + +//---------------------------------------------------------------------- +// DocHandler +//---------------------------------------------------------------------- + +DocHandler::DocHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_children.setAutoDelete(TRUE); + + addEndHandler("briefdescription",this,&DocHandler::endDoc); + addEndHandler("detaileddescription",this,&DocHandler::endDoc); + addEndHandler("inbodydescription",this,&DocHandler::endDoc); + //addEndHandler("internal"); // TODO: implement this as a section + addStartHandler("internal",this,&DocHandler::startInternal); + + addStartHandler("para",this,&DocHandler::startParagraph); + addStartHandler("sect1",this,&DocHandler::startSect1); + addStartHandler("title",this,&DocHandler::startTitle); + //addStartHandler("internal"); +} + +DocHandler::~DocHandler() +{ +} + +void DocHandler::startDoc(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"start dochandler\n"); +} + +void DocHandler::endDoc() +{ + debug(2,"end dochandler\n"); + m_parent->setDelegate(0); +} + +void DocHandler::startParagraph(const QXmlAttributes& attrib) +{ + ParagraphHandler *parHandler = new ParagraphHandler(this); + parHandler->startParagraph(attrib); + m_children.append(parHandler); +} + +void DocHandler::startSect1(const QXmlAttributes& attrib) +{ + DocSectionHandler *secHandler = new DocSectionHandler(this,1); + secHandler->startDocSection(attrib); + m_children.append(secHandler); +} + +void DocHandler::startTitle(const QXmlAttributes& attrib) +{ + TitleHandler *titleHandler = new TitleHandler(this); + titleHandler->startTitle(attrib); + m_children.append(titleHandler); +} + +void DocHandler::startInternal(const QXmlAttributes& attrib) +{ + m_internal = new DocInternalHandler(this,1); + m_internal->startInternal(attrib); +} + +IDocIterator *DocHandler::contents() const +{ + return new DocIterator(*this); +} + +IDocInternal *DocHandler::internal() const +{ + return m_internal; +} + diff --git a/trunk/addon/doxmlparser/src/dochandler.h b/trunk/addon/doxmlparser/src/dochandler.h new file mode 100644 index 0000000..77fa379 --- /dev/null +++ b/trunk/addon/doxmlparser/src/dochandler.h @@ -0,0 +1,1352 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _DOCHANDLER_H +#define _DOCHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> + +#include <doxmlintf.h> +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class ParagraphHandler; +class DocInternalHandler; +class LinkedTextImpl; +class LinkedTextHandler; + +//----------------------------------------------------------------------------- + +class DocImpl : public IDoc { public: virtual ~DocImpl() {} }; + +#define DEFINE_CLS_IMPL(cls) \ + class cls##Impl : public I##cls, public DocImpl { public: virtual ~cls##Impl() {} } + +DEFINE_CLS_IMPL(DocMarkup); +DEFINE_CLS_IMPL(DocPara); +DEFINE_CLS_IMPL(DocText); +DEFINE_CLS_IMPL(DocMarkupModifier); +DEFINE_CLS_IMPL(DocItemizedList); +DEFINE_CLS_IMPL(DocOrderedList); +DEFINE_CLS_IMPL(DocListItem); +DEFINE_CLS_IMPL(DocParameterList); +DEFINE_CLS_IMPL(DocParameterItem); +DEFINE_CLS_IMPL(DocParameter); +DEFINE_CLS_IMPL(DocTitle); +DEFINE_CLS_IMPL(DocSimpleSect); +DEFINE_CLS_IMPL(DocRef); +DEFINE_CLS_IMPL(DocVariableList); +DEFINE_CLS_IMPL(DocVariableListEntry); +DEFINE_CLS_IMPL(DocHRuler); +DEFINE_CLS_IMPL(DocLineBreak); +DEFINE_CLS_IMPL(DocULink); +DEFINE_CLS_IMPL(DocEMail); +DEFINE_CLS_IMPL(DocLink); +DEFINE_CLS_IMPL(DocProgramListing); +DEFINE_CLS_IMPL(DocCodeLine); +DEFINE_CLS_IMPL(DocHighlight); +DEFINE_CLS_IMPL(DocFormula); +DEFINE_CLS_IMPL(DocImage); +DEFINE_CLS_IMPL(DocDotFile); +DEFINE_CLS_IMPL(DocIndexEntry); +DEFINE_CLS_IMPL(DocTable); +DEFINE_CLS_IMPL(DocRow); +DEFINE_CLS_IMPL(DocEntry); +DEFINE_CLS_IMPL(DocSection); +DEFINE_CLS_IMPL(DocVerbatim); +DEFINE_CLS_IMPL(DocCopy); +DEFINE_CLS_IMPL(DocTocList); +DEFINE_CLS_IMPL(DocTocItem); +DEFINE_CLS_IMPL(DocAnchor); +DEFINE_CLS_IMPL(DocSymbol); +DEFINE_CLS_IMPL(DocInternal); +DEFINE_CLS_IMPL(DocRoot); + +//----------------------------------------------------------------------------- + + +/*! \brief Node representing a piece of text. + * + */ +class TextNode : public DocTextImpl +{ + public: + TextNode(const QString &t,int markup,int level) + : m_text(t), m_markup(markup), m_headingLevel(level) {} + virtual ~TextNode() {} + + // IDocText + virtual Kind kind() const { return DocImpl::Text; } + virtual const IString *text() const { return &m_text; } + virtual int markup() const { return m_markup; } + virtual int headingLevel() const { return m_headingLevel; } + + private: + StringImpl m_text; + int m_markup; + int m_headingLevel; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a change in the markup style. + * + */ +class MarkupModifierNode : public DocMarkupModifierImpl +{ + public: + MarkupModifierNode(int markup,bool enabled,int level=0) + : m_markup(markup), m_enabled(enabled), m_headingLevel(level) {} + virtual ~MarkupModifierNode() {} + + // IDocMarkupModifier + virtual Kind kind() const { return DocImpl::MarkupModifier; } + virtual bool enabled() const { return m_enabled; } + virtual int markup() const { return m_markup; } + virtual int headingLevel() const { return m_headingLevel; } + + private: + int m_markup; + bool m_enabled; + int m_headingLevel; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Handles markup commands in the XML input. + * + */ +class MarkupHandler : public BaseFallBackHandler<MarkupHandler> +{ + public: + MarkupHandler(QList<DocImpl> &children,QString &curString); + virtual ~MarkupHandler(); + int markup() const { return m_curMarkup; } + int headingLevel() const { return m_headingLevel; } + + virtual void startBold(const QXmlAttributes &attrib); + virtual void endBold(); + virtual void startEmphasis(const QXmlAttributes &attrib); + virtual void endEmphasis(); + virtual void startComputerOutput(const QXmlAttributes &attrib); + virtual void endComputerOutput(); + virtual void startCenter(const QXmlAttributes &attrib); + virtual void endCenter(); + virtual void startSmallFont(const QXmlAttributes &attrib); + virtual void endSmallFont(); + virtual void startSubscript(const QXmlAttributes &attrib); + virtual void endSubscript(); + virtual void startSuperscript(const QXmlAttributes &attrib); + virtual void endSuperscript(); + virtual void startPreformatted(const QXmlAttributes &attrib); + virtual void endPreformatted(); + virtual void startHeading1(const QXmlAttributes &attrib); + virtual void endHeading1(); + virtual void startHeading2(const QXmlAttributes &attrib); + virtual void endHeading2(); + virtual void startHeading3(const QXmlAttributes &attrib); + virtual void endHeading3(); + virtual void startHeading4(const QXmlAttributes &attrib); + virtual void endHeading4(); + virtual void startHeading5(const QXmlAttributes &attrib); + virtual void endHeading5(); + virtual void startHeading6(const QXmlAttributes &attrib); + virtual void endHeading6(); + + + private: + void addTextNode(); + + QList<DocImpl> &m_children; + QString &m_curString; + int m_curMarkup; + int m_headingLevel; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a paragraph of text and commands. + * + */ +// children: itemizedlist, orderedlist, parameterlist, simplesect, ref, +// variablelist, hruler, linebreak, ulink, email, link +// programlisting, formula, image, dotfile, indexentry, +// table +// +// children handled by MarkupHandler: +// bold, computeroutput, emphasis, center, +// small, subscript, superscript. +// +class ParagraphHandler : public DocParaImpl, + public BaseHandler<ParagraphHandler> +{ + friend class ParagraphIterator; + + public: + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void endParagraph(); + virtual void startItemizedList(const QXmlAttributes& attrib); + virtual void startOrderedList(const QXmlAttributes& attrib); + virtual void startParameterList(const QXmlAttributes& attrib); + virtual void startSimpleSect(const QXmlAttributes& attrib); + virtual void startRef(const QXmlAttributes& attrib); + virtual void startVariableList(const QXmlAttributes& attrib); + virtual void startHRuler(const QXmlAttributes& attrib); + virtual void startLineBreak(const QXmlAttributes& attrib); + virtual void startULink(const QXmlAttributes& attrib); + virtual void startEMail(const QXmlAttributes& attrib); + virtual void startLink(const QXmlAttributes& attrib); + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void startFormula(const QXmlAttributes& attrib); + virtual void startImage(const QXmlAttributes& attrib); + virtual void startDotFile(const QXmlAttributes& attrib); + virtual void startIndexEntry(const QXmlAttributes& attrib); + virtual void startTable(const QXmlAttributes& attrib); + virtual void startVerbatim(const QXmlAttributes& attrib); + virtual void startHtmlOnly(const QXmlAttributes& attrib); + virtual void startLatexOnly(const QXmlAttributes& attrib); + virtual void startUmlaut(const QXmlAttributes& attrib); + virtual void startAcute(const QXmlAttributes& attrib); + virtual void startGrave(const QXmlAttributes& attrib); + virtual void startCirc(const QXmlAttributes& attrib); + virtual void startTilde(const QXmlAttributes& attrib); + virtual void startSzlig(const QXmlAttributes& attrib); + virtual void startCedil(const QXmlAttributes& attrib); + virtual void startRing(const QXmlAttributes& attrib); + virtual void startNbsp(const QXmlAttributes& attrib); + virtual void startCopy(const QXmlAttributes& attrib); + virtual void startAnchor(const QXmlAttributes& attrib); + virtual void startCopyDoc(const QXmlAttributes& attrib); + virtual void startTocList(const QXmlAttributes& attrib); + + ParagraphHandler(IBaseHandler *parent); + virtual ~ParagraphHandler(); + + // IDocPara + virtual Kind kind() const { return DocImpl::Para; } + virtual IDocIterator *contents() const; + + private: + void addTextNode(); + IBaseHandler *m_parent; + QList<DocImpl> m_children; + MarkupHandler *m_markupHandler; +}; + +class ParagraphIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ParagraphIterator(const ParagraphHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a list item. + * + */ +class ListItemHandler : public DocListItemImpl, public BaseHandler<ListItemHandler> +{ + friend class ListItemIterator; + public: + ListItemHandler(IBaseHandler *parent); + virtual ~ListItemHandler(); + virtual void startListItem(const QXmlAttributes& attrib); + virtual void endListItem(); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocItem + virtual Kind kind() const { return DocImpl::ListItem; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class ListItemIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ListItemIterator(const ListItemHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing list of items. + * + */ +class OrderedListHandler : public DocOrderedListImpl, public BaseHandler<OrderedListHandler> +{ + friend class OrderedListIterator; + public: + OrderedListHandler(IBaseHandler *parent); + virtual ~OrderedListHandler(); + virtual void startOrderedList(const QXmlAttributes& attrib); + virtual void endOrderedList(); + virtual void startOrderedListItem(const QXmlAttributes& attrib); + + // IDocOrderedList + virtual Kind kind() const { return DocImpl::OrderedList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class OrderedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + OrderedListIterator(const OrderedListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing table of contents list. + * + */ +class TocListHandler : public DocTocListImpl, public BaseHandler<TocListHandler> +{ + friend class TocListIterator; + public: + TocListHandler(IBaseHandler *parent); + virtual ~TocListHandler(); + virtual void startTocList(const QXmlAttributes& attrib); + virtual void endTocList(); + virtual void startTocItem(const QXmlAttributes& attrib); + + // IDocTocList + virtual Kind kind() const { return DocImpl::TocList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class TocListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + TocListIterator(const TocListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a table of contents item. + * + */ +class TocItemHandler : public DocTocItemImpl, public BaseHandler<TocItemHandler> +{ + friend class TocItemIterator; + public: + TocItemHandler(IBaseHandler *parent); + virtual ~TocItemHandler(); + virtual void startTocItem(const QXmlAttributes& attrib); + virtual void endTocItem(); + + // IDocItem + virtual Kind kind() const { return DocImpl::TocItem; } + virtual const IString *id() const { return &m_id; } + virtual const IString *title() const { return &m_title; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_title; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing list of items. + * + */ +class ItemizedListHandler : public DocItemizedListImpl, public BaseHandler<ItemizedListHandler> +{ + friend class ItemizedListIterator; + public: + ItemizedListHandler(IBaseHandler *parent); + virtual ~ItemizedListHandler(); + virtual void startItemizedList(const QXmlAttributes& attrib); + virtual void endItemizedList(); + virtual void startItemizedListItem(const QXmlAttributes& attrib); + + // IDocItemizedList + virtual Kind kind() const { return DocImpl::ItemizedList; } + virtual IDocIterator *elements() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class ItemizedListIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + ItemizedListIterator(const ItemizedListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + + +//----------------------------------------------------------------------------- +/*! \brief Node representing a parameter. + * + */ +class ParameterHandler : public DocParameterImpl, + public BaseHandler<ParameterHandler> +{ + public: + ParameterHandler(IBaseHandler *parent); + virtual ~ParameterHandler(); + virtual void startParameterName(const QXmlAttributes& attrib); + virtual void endParameterName(); + + // IDocParameter + virtual Kind kind() const { return DocImpl::Parameter; } + virtual const IString *name() const { return &m_name; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a list of param names with a single description. + * + */ +class ParameterItemHandler : public DocParameterItemImpl, + public BaseHandler<ParameterItemHandler> +{ + friend class ParameterItemIterator; + public: + ParameterItemHandler(IBaseHandler *parent); + virtual ~ParameterItemHandler(); + virtual void startParameterItem(const QXmlAttributes& attrib); + virtual void endParameterItem(); + virtual void startParameterName(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocParameterItem + virtual Kind kind() const { return DocImpl::ParameterItem; } + virtual IDocIterator *paramNames() const; + virtual IDocPara *description() const { return m_description; } + + private: + IBaseHandler *m_parent; + QList<ParameterHandler> m_parameters; + ParagraphHandler *m_description; +}; + +class ParameterItemIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl> +{ + public: + ParameterItemIterator(const ParameterItemHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,ParameterHandler,DocImpl>(handler.m_parameters) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a parameter section. + * + */ +class ParameterListHandler : public DocParameterListImpl, + public BaseHandler<ParameterListHandler> +{ + friend class ParameterListIterator; + public: + ParameterListHandler(IBaseHandler *parent); + virtual ~ParameterListHandler(); + virtual void startParameterList(const QXmlAttributes& attrib); + virtual void endParameterList(); + virtual void startParameterItem(const QXmlAttributes& attrib); + + // IDocParameterList + virtual Kind kind() const { return DocImpl::ParameterList; } + virtual Types sectType() const { return m_type; } + virtual IDocIterator *params() const; + + private: + IBaseHandler *m_parent; + QList<ParameterItemHandler> m_paramItems; + Types m_type; +}; + +class ParameterListIterator : public BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl> +{ + public: + ParameterListIterator(const ParameterListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,ParameterItemHandler,DocImpl>(handler.m_paramItems) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a horizontal ruler + * + */ +class LineBreakHandler : public DocLineBreakImpl, public BaseHandler<LineBreakHandler> +{ + public: + LineBreakHandler(IBaseHandler *parent); + virtual ~LineBreakHandler(); + + void startLineBreak(const QXmlAttributes& attrib); + void endLineBreak(); + + // IDocLineBreak + virtual Kind kind() const { return DocImpl::LineBreak; } + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to section + * + */ +class LinkHandler : public DocLinkImpl, public BaseHandler<LinkHandler> +{ + public: + LinkHandler(IBaseHandler *parent); + virtual ~LinkHandler(); + + void startLink(const QXmlAttributes& attrib); + void endLink(); + + // IDocLink + virtual Kind kind() const { return DocImpl::Link; } + virtual const IString *refId() const { return &m_ref; } + virtual const IString *text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_ref; + StringImpl m_text; +}; + + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to an email address + * + */ +class EMailHandler : public DocEMailImpl, public BaseHandler<EMailHandler> +{ + public: + EMailHandler(IBaseHandler *parent); + virtual ~EMailHandler(); + + void startEMail(const QXmlAttributes& attrib); + void endEMail(); + + // IDocEMail + virtual Kind kind() const { return DocImpl::EMail; } + virtual const IString *address() const { return &m_address; } + + private: + IBaseHandler *m_parent; + StringImpl m_address; +}; + + +//----------------------------------------------------------------------------- + +/* \brief Node representing a link to an URL + * + */ +class ULinkHandler : public DocULinkImpl, public BaseHandler<ULinkHandler> +{ + public: + ULinkHandler(IBaseHandler *parent); + virtual ~ULinkHandler(); + + void startULink(const QXmlAttributes& attrib); + void endULink(); + + // IDocULink + virtual Kind kind() const { return DocImpl::ULink; } + virtual const IString * url() const { return &m_url; } + virtual const IString * text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_url; + StringImpl m_text; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a horizontal ruler + * + */ +class HRulerHandler : public DocHRulerImpl, public BaseHandler<HRulerHandler> +{ + public: + HRulerHandler(IBaseHandler *parent); + virtual ~HRulerHandler(); + + void startHRuler(const QXmlAttributes& attrib); + void endHRuler(); + + // IDocHRuler + virtual Kind kind() const { return DocImpl::HRuler; } + + private: + IBaseHandler *m_parent; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a reference to another item + * + */ +class RefHandler : public DocRefImpl, public BaseHandler<RefHandler> +{ + public: + RefHandler(IBaseHandler *parent); + virtual ~RefHandler(); + void startRef(const QXmlAttributes& attrib); + void endRef(); + + // IDocRef + virtual Kind kind() const { return DocImpl::Ref; } + virtual const IString *refId() const { return &m_refId; } + virtual TargetKind targetKind() const { return m_targetKind; } + virtual const IString *external() const { return &m_extId; } + virtual const IString *text() const { return &m_linkText; } + + private: + IBaseHandler *m_parent; + StringImpl m_refId; + StringImpl m_extId; + StringImpl m_linkText; + TargetKind m_targetKind; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing the title of a section + * + */ +// children: text, ref +// children handled by MarkupHandler: +// bold, computeroutput, emphasis, center, +// small, subscript, superscript. +class TitleHandler : public DocTitleImpl, public BaseHandler<TitleHandler> +{ + friend class TitleIterator; + public: + TitleHandler(IBaseHandler *parent); + virtual ~TitleHandler(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void endTitle(); + virtual void startRef(const QXmlAttributes& attrib); + void addTextNode(); + + // IDocTitle + virtual Kind kind() const { return DocImpl::Title; } + virtual IDocIterator *title() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; + MarkupHandler *m_markupHandler; +}; + +class TitleIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + TitleIterator(const TitleHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing a simple section with an unnumbered header. + * + */ +// children: title, para +class SimpleSectHandler : public DocSimpleSectImpl, + public BaseHandler<SimpleSectHandler> +{ + public: + SimpleSectHandler(IBaseHandler *parent); + virtual ~SimpleSectHandler(); + virtual void startSimpleSect(const QXmlAttributes& attrib); + virtual void endSimpleSect(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocSimpleSect + virtual Kind kind() const { return DocImpl::SimpleSect; } + virtual Types type() const { return m_type; } + virtual const IString *typeString() const { return &m_typeString; } + virtual IDocTitle *title() const { return m_title; } + virtual IDocPara *description() const { return m_paragraph; } + + private: + IBaseHandler *m_parent; + ParagraphHandler *m_paragraph; + Types m_type; + StringImpl m_typeString; + TitleHandler *m_title; +}; + +//----------------------------------------------------------------------------- + +/* \brief Node representing an named item of a VariableList. + * + */ +class VariableListEntryHandler : public DocVariableListEntryImpl, + public BaseHandler<VariableListEntryHandler> +{ + public: + virtual void startVarListEntry(const QXmlAttributes& attrib); + virtual void endVarListEntry(); + virtual void startListItem(const QXmlAttributes& attrib); + virtual void endListItem(); + virtual void startTerm(const QXmlAttributes& attrib); + virtual void endTerm(); + virtual void startParagraph(const QXmlAttributes& attrib); + + VariableListEntryHandler(IBaseHandler *parent); + virtual ~VariableListEntryHandler(); + + // IDocVariableListEntry + virtual Kind kind() const { return DocImpl::VariableListEntry; } + virtual ILinkedTextIterator *term() const; + virtual IDocPara *description() const { return m_description; } + + private: + IBaseHandler* m_parent; + QList<LinkedTextImpl> m_term; + ParagraphHandler* m_description; + LinkedTextHandler* m_linkedTextHandler; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a list of named items. + * + */ +// children: varlistentry, listitem +class VariableListHandler : public DocVariableListImpl, + public BaseHandler<VariableListHandler> +{ + friend class VariableListIterator; + + public: + virtual void startVariableList(const QXmlAttributes& attrib); + virtual void endVariableList(); + virtual void startVarListEntry(const QXmlAttributes& attrib); + virtual void startListItem(const QXmlAttributes& attrib); + + VariableListHandler(IBaseHandler *parent); + virtual ~VariableListHandler(); + + // IDocVariableList + virtual Kind kind() const { return DocImpl::VariableList; } + virtual IDocIterator *entries() const; + + private: + IBaseHandler *m_parent; + QList<VariableListEntryHandler> m_entries; + VariableListEntryHandler *m_curEntry; +}; + +class VariableListIterator : public BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl> +{ + public: + VariableListIterator(const VariableListHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,VariableListEntryHandler,DocImpl>(handler.m_entries) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a highlighted text fragment. + * + */ +// children: ref +class HighlightHandler : public DocHighlightImpl, public BaseHandler<HighlightHandler> +{ + friend class HighlightIterator; + public: + HighlightHandler(IBaseHandler *parent); + virtual ~HighlightHandler(); + void startHighlight(const QXmlAttributes& attrib); + void endHighlight(); + virtual void startRef(const QXmlAttributes&); + virtual void startSpace(const QXmlAttributes&); + + // IDocHighlight + virtual Kind kind() const { return DocImpl::Highlight; } + virtual HighlightKind highlightKind() const { return m_hl; } + virtual IDocIterator *codeElements() const; + + private: + void addTextNode(); + + IBaseHandler *m_parent; + HighlightKind m_hl; + QString m_hlString; + QList<DocImpl> m_children; +}; + +class HighlightIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + HighlightIterator(const HighlightHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a line of code. + * + */ +// children: linenumber, highlight, anchor, ref +class CodeLineHandler : public DocCodeLineImpl, public BaseHandler<CodeLineHandler> +{ + friend class CodeLineIterator; + public: + + virtual void startCodeLine(const QXmlAttributes&); + virtual void endCodeLine(); + virtual void startLineNumber(const QXmlAttributes&); + virtual void endLineNumber(); + virtual void startHighlight(const QXmlAttributes&); + virtual void startRef(const QXmlAttributes&); + + CodeLineHandler(IBaseHandler *parent); + virtual ~CodeLineHandler(); + + // IDocCodeLine + virtual Kind kind() const { return DocImpl::CodeLine; } + virtual int lineNumber() const { return m_lineNumber; } + virtual const IString *refId() const { return &m_refId; } + virtual IDocIterator *codeElements() const; + + private: + void addTextNode(); + + IBaseHandler *m_parent; + int m_lineNumber; + StringImpl m_refId; + QList<DocImpl> m_children; +}; + +class CodeLineIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + CodeLineIterator(const CodeLineHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a program listing + * + */ +// children: codeline, linenumber +class ProgramListingHandler : public DocProgramListingImpl, public BaseHandler<ProgramListingHandler> +{ + friend class ProgramListingIterator; + public: + virtual void startProgramListing(const QXmlAttributes& attrib); + virtual void endProgramListing(); + virtual void startCodeLine(const QXmlAttributes&); + virtual void startLineNumber(const QXmlAttributes&); + + ProgramListingHandler(IBaseHandler *parent); + virtual ~ProgramListingHandler(); + + // IDocProgramListing + virtual Kind kind() const { return DocImpl::ProgramListing; } + virtual IDocIterator *codeLines() const; + + private: + IBaseHandler *m_parent; + QList<CodeLineHandler> m_children; + bool m_hasLineNumber; +}; + +//----------------------------------------------------------------------------- + +class ProgramListingIterator : public BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl> +{ + public: + ProgramListingIterator(const ProgramListingHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,CodeLineHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a formula. + * + */ +// children: - +class FormulaHandler : public DocFormulaImpl, public BaseHandler<FormulaHandler> +{ + public: + FormulaHandler(IBaseHandler *parent); + virtual ~FormulaHandler(); + void startFormula(const QXmlAttributes& attrib); + void endFormula(); + + // IDocFormula + virtual Kind kind() const { return DocImpl::Formula; } + virtual const IString *id() const { return &m_id; } + virtual const IString *text() const { return &m_text; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_text; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an image. + * + */ +// children: - +class ImageHandler : public DocImageImpl, public BaseHandler<ImageHandler> +{ + public: + ImageHandler(IBaseHandler *parent); + virtual ~ImageHandler(); + void startImage(const QXmlAttributes& attrib); + void endImage(); + + // IDocImage + virtual Kind kind() const { return DocImpl::Image; } + virtual const IString *name() const { return &m_name; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; + StringImpl m_caption; +}; + + +//----------------------------------------------------------------------------- +/*! \brief Node representing an anchor. + * + */ +// children: - +class AnchorHandler : public DocAnchorImpl, public BaseHandler<AnchorHandler> +{ + public: + AnchorHandler(IBaseHandler *parent); + virtual ~AnchorHandler(); + void startAnchor(const QXmlAttributes& attrib); + void endAnchor(); + + // IDocAnchor + virtual Kind kind() const { return DocImpl::Anchor; } + virtual const IString *id() const { return &m_id; } + + private: + IBaseHandler *m_parent; + StringImpl m_id; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a dot file. + * + */ +// children: - +class DotFileHandler : public DocDotFileImpl, public BaseHandler<DotFileHandler> +{ + public: + DotFileHandler(IBaseHandler *parent); + virtual ~DotFileHandler(); + void startDotFile(const QXmlAttributes& attrib); + void endDotFile(); + + // IDocDotFile + virtual Kind kind() const { return DocImpl::DotFile; } + virtual const IString *name() const { return &m_name; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + StringImpl m_name; + StringImpl m_caption; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the index. + * + */ +// children: - +class IndexEntryHandler : public DocIndexEntryImpl, public BaseHandler<IndexEntryHandler> +{ + public: + IndexEntryHandler(IBaseHandler *parent); + virtual ~IndexEntryHandler(); + void startIndexEntry(const QXmlAttributes& attrib); + void endIndexEntry(); + void startPrimaryIE(const QXmlAttributes& attrib); + void endPrimaryIE(); + void startSecondaryIE(const QXmlAttributes& attrib); + void endSecondaryIE(); + + // IDocIndexEntry + virtual Kind kind() const { return DocImpl::IndexEntry; } + virtual const IString *primary() const { return &m_primary; } + virtual const IString *secondary() const { return &m_secondary; } + + private: + IBaseHandler *m_parent; + StringImpl m_primary; + StringImpl m_secondary; +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table entry. + * + */ +// children: para +class EntryHandler : public DocEntryImpl, public BaseHandler<EntryHandler> +{ + friend class EntryIterator; + public: + EntryHandler(IBaseHandler *parent); + virtual ~EntryHandler(); + void startEntry(const QXmlAttributes& attrib); + void endEntry(); + void startParagraph(const QXmlAttributes& attrib); + + // IDocEntry + virtual Kind kind() const { return DocImpl::Entry; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class EntryIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + EntryIterator(const EntryHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table row. + * + */ +// children: entry +class RowHandler : public DocRowImpl, public BaseHandler<RowHandler> +{ + friend class RowIterator; + public: + RowHandler(IBaseHandler *parent); + virtual ~RowHandler(); + void startRow(const QXmlAttributes& attrib); + void endRow(); + void startEntry(const QXmlAttributes& attrib); + + // IDocRow + virtual Kind kind() const { return DocImpl::Row; } + virtual IDocIterator *entries() const; + + private: + IBaseHandler *m_parent; + QList<EntryHandler> m_children; +}; + +class RowIterator : public BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl> +{ + public: + RowIterator(const RowHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,EntryHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an entry in the table. + * + */ +// children: row, caption +class TableHandler : public DocTableImpl, public BaseHandler<TableHandler> +{ + friend class TableIterator; + public: + TableHandler(IBaseHandler *parent); + virtual ~TableHandler(); + void startTable(const QXmlAttributes& attrib); + void endTable(); + void startRow(const QXmlAttributes& attrib); + void startCaption(const QXmlAttributes& attrib); + void endCaption(); + + // IDocTable + virtual Kind kind() const { return DocImpl::Table; } + virtual IDocIterator *rows() const; + virtual int numColumns() const { return m_numColumns; } + virtual const IString *caption() const { return &m_caption; } + + private: + IBaseHandler *m_parent; + QList<RowHandler> m_children; + int m_numColumns; + StringImpl m_caption; +}; + +class TableIterator : public BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl> +{ + public: + TableIterator(const TableHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,RowHandler,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a copied piece of documentation. + * + */ +class CopyHandler : public DocCopyImpl, public BaseHandler<CopyHandler> +{ + friend class CopyIterator; + public: + CopyHandler(IBaseHandler *parent); + virtual ~CopyHandler(); + virtual void startCopy(const QXmlAttributes& attrib); + virtual void endCopy(); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocCopy + virtual Kind kind() const { return DocImpl::Copy; } + virtual IDocIterator *contents() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; +}; + +class CopyIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + CopyIterator(const CopyHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an preformatted section + */ +class VerbatimHandler : public DocVerbatimImpl, + public BaseHandler<VerbatimHandler> +{ + public: + VerbatimHandler(IBaseHandler *parent); + virtual ~VerbatimHandler(); + void startVerbatim(const QXmlAttributes& attrib,Types type); + void endVerbatim(); + + // IDocVerbatim + virtual Kind kind() const { return DocImpl::Verbatim; } + virtual const IString *text() const { return &m_text; } + virtual Types type() const { return m_type; } + + private: + IBaseHandler *m_parent; + StringImpl m_text; + Types m_type; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing an special symbol. + * + */ +// children: - +class SymbolHandler : public DocSymbolImpl, public BaseHandler<SymbolHandler> +{ + public: + SymbolHandler(IBaseHandler *parent,Types type); + virtual ~SymbolHandler(); + void startSymbol(const QXmlAttributes& attrib); + void endSymbol(); + + // IDocSymbol + virtual Kind kind() const { return DocImpl::Symbol; } + virtual Types type() const { return m_type; } + virtual const IString *typeString() const { return &m_typeString; } + virtual char letter() const { return m_letter; } + + private: + IBaseHandler *m_parent; + char m_letter; + Types m_type; + StringImpl m_typeString; +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a section. + * + */ +// children: title, para, sect(n+1) +class DocSectionHandler : public DocSectionImpl, public BaseHandler<DocSectionHandler> +{ + friend class DocSectionParaIterator; + friend class DocSectionSubIterator; + public: + DocSectionHandler(IBaseHandler *parent,int level); + virtual ~DocSectionHandler(); + virtual void startDocSection(const QXmlAttributes& attrib); + virtual void endDocSection(); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startSubSection(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void startInternal(const QXmlAttributes& attrib); + + // IDocSection + virtual Kind kind() const { return DocImpl::Section; } + virtual const IString *id() const { return &m_id; } + virtual int level() const { return m_level; } + virtual IDocTitle *title() const { return m_title; } + virtual IDocIterator *paragraphs() const; + virtual IDocIterator *subSections() const; + virtual IDocInternal *internal() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_paragraphs; + QList<DocImpl> m_subsections; + DocInternalHandler *m_internal; + StringImpl m_id; + int m_level; + TitleHandler *m_title; +}; + +class DocSectionParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocSectionParaIterator(const DocSectionHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {} +}; + +class DocSectionSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocSectionSubIterator(const DocSectionHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {} +}; + +//----------------------------------------------------------------------------- + +class DocInternalHandler : public DocInternalImpl, public BaseHandler<DocInternalHandler> +{ + public: + friend class DocInternalParaIterator; + friend class DocInternalSubIterator; + DocInternalHandler(IBaseHandler *parent,int level); + virtual ~DocInternalHandler(); + virtual void startInternal(const QXmlAttributes& attrib); + virtual void endInternal(); + virtual void startSubSection(const QXmlAttributes& attrib); + virtual void startParagraph(const QXmlAttributes& attrib); + + // IDocInternal + virtual Kind kind() const { return DocImpl::Internal; } + virtual IDocIterator *paragraphs() const; + virtual IDocIterator *subSections() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_paragraphs; + QList<DocImpl> m_subsections; + int m_level; +}; + +class DocInternalParaIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocInternalParaIterator(const DocInternalHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_paragraphs) {} +}; + +class DocInternalSubIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocInternalSubIterator(const DocInternalHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_subsections) {} +}; + + +//----------------------------------------------------------------------------- + +/*! \brief Node representing a documentation block. + * + */ +// children: para, title, sect1, internal +class DocHandler : public DocRootImpl, public BaseHandler<DocHandler> +{ + friend class DocIterator; + public: + virtual void startDoc(const QXmlAttributes& attrib); + virtual void endDoc(); + virtual void startParagraph(const QXmlAttributes& attrib); + virtual void startSect1(const QXmlAttributes& attrib); + virtual void startTitle(const QXmlAttributes& attrib); + virtual void startInternal(const QXmlAttributes& attrib); + + DocHandler(IBaseHandler *parent); + virtual ~DocHandler(); + + // IDocRoot + virtual Kind kind() const { return DocImpl::Root; } + virtual IDocIterator *contents() const; + virtual IDocInternal *internal() const; + + private: + IBaseHandler *m_parent; + QList<DocImpl> m_children; + DocInternalHandler *m_internal; +}; + +class DocIterator : public BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl> +{ + public: + DocIterator(const DocHandler &handler) : + BaseIteratorVia<IDocIterator,IDoc,DocImpl,DocImpl>(handler.m_children) {} +}; + +//----------------------------------------------------------------------------- + +void dochandler_init(); +void dochandler_exit(); + +#endif diff --git a/trunk/addon/doxmlparser/src/doxmlintf.h b/trunk/addon/doxmlparser/src/doxmlintf.h new file mode 120000 index 0000000..1b1e847 --- /dev/null +++ b/trunk/addon/doxmlparser/src/doxmlintf.h @@ -0,0 +1 @@ +../include/doxmlintf.h
\ No newline at end of file diff --git a/trunk/addon/doxmlparser/src/doxmlparser.pro.in b/trunk/addon/doxmlparser/src/doxmlparser.pro.in new file mode 100644 index 0000000..841a46c --- /dev/null +++ b/trunk/addon/doxmlparser/src/doxmlparser.pro.in @@ -0,0 +1,27 @@ +TEMPLATE = lib.t +CONFIG = console staticlib warn_on $extraopts +HEADERS = basehandler.h mainhandler.h \ + compoundhandler.h sectionhandler.h \ + memberhandler.h paramhandler.h \ + dochandler.h linkedtexthandler.h \ + debug.h graphhandler.h stringimpl.h \ + loamhandler.h +SOURCES = mainhandler.cpp \ + compoundhandler.cpp sectionhandler.cpp \ + memberhandler.cpp paramhandler.cpp \ + dochandler.cpp linkedtexthandler.cpp \ + basehandler.cpp debug.cpp graphhandler.cpp \ + loamhandler.cpp +unix:LIBS += -L../../../lib -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../../lib -lqtools +win32-msvc:LIBS += qtools.lib shell32.lib +win32-msvc:TMAKE_LFLAGS += /LIBPATH:....\\..\lib +win32-borland:LIBS += qtools.lib doxycfg.lib shell32.lib +win32-borland:TMAKE_LFLAGS += -L..\..\..\lib +win32:TMAKE_CXXFLAGS += -DQT_NODLL +DESTDIR = ../lib +OBJECTS_DIR = ../objects +TARGET = doxmlparser +INCLUDEPATH += ../../../qtools ../include + diff --git a/trunk/addon/doxmlparser/src/graphhandler.cpp b/trunk/addon/doxmlparser/src/graphhandler.cpp new file mode 100644 index 0000000..7816970 --- /dev/null +++ b/trunk/addon/doxmlparser/src/graphhandler.cpp @@ -0,0 +1,216 @@ +#include "graphhandler.h" + +class EdgeRelationMapper +{ + public: + EdgeRelationMapper() + { + m_map.insert("public-inheritance", IChildNode::PublicInheritance); + m_map.insert("protected-inheritance", IChildNode::ProtectedInheritance); + m_map.insert("private-inheritance", IChildNode::PrivateInheritance); + m_map.insert("usage", IChildNode::Usage); + m_map.insert("template-instance", IChildNode::TemplateInstance); + } + IChildNode::NodeRelation stringToNodeRelation(const QString &nrStr) + { + return m_map[nrStr]; + } + private: + QMap<QString,IChildNode::NodeRelation> m_map; +}; + +static EdgeRelationMapper *s_edgeRelationMapper; + +void graphhandler_init() +{ + s_edgeRelationMapper = new EdgeRelationMapper; +} + +void graphhandler_exit() +{ + delete s_edgeRelationMapper; +} + +//------------------------------------------------------------------------ + +GraphHandler::GraphHandler(IBaseHandler *parent,const char *endTag) + : m_parent(parent) +{ + addEndHandler(endTag,this,&GraphHandler::endGraph); + addStartHandler("node",this,&GraphHandler::startNode); + m_nodes.setAutoDelete(TRUE); + m_nodeDict = new QDict<NodeHandler>(1009); +} + +GraphHandler::~GraphHandler() +{ + delete m_nodeDict; +} + +void GraphHandler::startGraph(const QXmlAttributes &) +{ + debug(2,"startGraph\n"); + m_parent->setDelegate(this); +} + +void GraphHandler::endGraph() +{ + debug(2,"endGraph\n"); + m_parent->setDelegate(0); +} + +void GraphHandler::startNode(const QXmlAttributes &attrib) +{ + NodeHandler *n = new NodeHandler(this); + n->startNode(attrib); + m_nodes.append(n); + m_nodeDict->insert(attrib.value("id"),n); +} + +INodeIterator *GraphHandler::nodes() const +{ + return new NodeIterator(*this); +} + +NodeHandler *GraphHandler::getNodeById(const QString &id) const +{ + return m_nodeDict->find(id); +} + +//------------------------------------------------------------------------ + +NodeHandler::NodeHandler(GraphHandler *gh) + : m_parent(gh), m_graph(gh) +{ + addEndHandler("node",this,&NodeHandler::endNode); + addStartHandler("link",this,&NodeHandler::startLink); + addEndHandler("link",this,&NodeHandler::endLink); + addStartHandler("label",this,&NodeHandler::startLabel); + addEndHandler("label",this,&NodeHandler::endLabel); + addStartHandler("childnode",this,&NodeHandler::startChildNode); + m_children.setAutoDelete(TRUE); +} + +NodeHandler::~NodeHandler() +{ +} + +void NodeHandler::startNode(const QXmlAttributes &attrib) +{ + debug(2,"startNode\n"); + m_parent->setDelegate(this); + m_id = attrib.value("id"); +} + +void NodeHandler::endNode() +{ + debug(2,"endNode\n"); + m_parent->setDelegate(0); +} + +void NodeHandler::startLink(const QXmlAttributes &attrib) +{ + m_link = attrib.value("refid"); +} + +void NodeHandler::endLink() +{ +} + +void NodeHandler::startLabel(const QXmlAttributes &/*attrib*/) +{ + m_curString=""; +} + +void NodeHandler::endLabel() +{ + m_label = m_curString; +} + +void NodeHandler::startChildNode(const QXmlAttributes &attrib) +{ + ChildNodeHandler *cnh = new ChildNodeHandler(this,m_graph); + cnh->startChildNode(attrib); + m_children.append(cnh); +} + +IChildNodeIterator *NodeHandler::children() const +{ + return new ChildNodeIterator(*this); +} + +//------------------------------------------------------------------------ + +ChildNodeHandler::ChildNodeHandler(IBaseHandler *parent,GraphHandler *gh) + : m_parent(parent), m_graph(gh) +{ + addEndHandler("childnode",this,&ChildNodeHandler::endChildNode); + addStartHandler("edgelabel",this,&ChildNodeHandler::startEdgeLabel); + m_edgeLabels.setAutoDelete(TRUE); +} + +ChildNodeHandler::~ChildNodeHandler() +{ +} + +void ChildNodeHandler::startChildNode(const QXmlAttributes &attrib) +{ + debug(2,"startChildNode\n"); + m_id = attrib.value("refid"); + m_relationString = attrib.value("relation"); + m_relation = s_edgeRelationMapper->stringToNodeRelation(m_relationString); + m_parent->setDelegate(this); +} + +void ChildNodeHandler::endChildNode() +{ + debug(2,"endChildNode\n"); + m_parent->setDelegate(0); +} + + +void ChildNodeHandler::startEdgeLabel(const QXmlAttributes &attrib) +{ + EdgeLabelHandler *elh = new EdgeLabelHandler(this); + elh->startEdgeLabel(attrib); + m_edgeLabels.append(elh); +} + +IEdgeLabelIterator *ChildNodeHandler::edgeLabels() const +{ + return new EdgeLabelIterator(*this); +} + +INode *ChildNodeHandler::node() const +{ + return m_graph->getNodeById(m_id); +} + +//----------------------------------------------------------------------- + +EdgeLabelHandler::EdgeLabelHandler(IBaseHandler *parent) + : m_parent(parent) +{ + addEndHandler("edgelabel",this,&EdgeLabelHandler::endEdgeLabel); +} + +EdgeLabelHandler::~EdgeLabelHandler() +{ +} + +void EdgeLabelHandler::startEdgeLabel(const QXmlAttributes &) +{ + m_parent->setDelegate(this); + m_curString=""; +} + +void EdgeLabelHandler::endEdgeLabel() +{ + m_label=m_curString; + m_parent->setDelegate(0); +} + + + + + diff --git a/trunk/addon/doxmlparser/src/graphhandler.h b/trunk/addon/doxmlparser/src/graphhandler.h new file mode 100644 index 0000000..f7105ec --- /dev/null +++ b/trunk/addon/doxmlparser/src/graphhandler.h @@ -0,0 +1,154 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _GRAPHHANDLER_H +#define _GRAPHHANDLER_H + +#include "stringimpl.h" +#include "doxmlintf.h" +#include "basehandler.h" +#include "baseiterator.h" + +class NodeHandler; +class ChildNodeHandler; +class EdgeLabelHandler; + +class GraphHandler : public IGraph, public BaseHandler<GraphHandler> +{ + friend class NodeIterator; + public: + GraphHandler(IBaseHandler *parent,const char *endTag); + virtual ~GraphHandler(); + + void startGraph(const QXmlAttributes &attrib); + void endGraph(); + void startNode(const QXmlAttributes &attrib); + NodeHandler *getNodeById(const QString &id) const; + + // IGraph + virtual INodeIterator *nodes() const; + + private: + IBaseHandler *m_parent; + QList<NodeHandler> m_nodes; + QDict<NodeHandler> *m_nodeDict; +}; + +//---------------------------------------------------------------------- + +class NodeHandler : public INode, public BaseHandler<NodeHandler> +{ + friend class ChildNodeIterator; + public: + NodeHandler(GraphHandler *gh); + virtual ~NodeHandler(); + + void startNode(const QXmlAttributes &attrib); + void endNode(); + void startLabel(const QXmlAttributes &attrib); + void endLabel(); + void startLink(const QXmlAttributes &attrib); + void endLink(); + void startChildNode(const QXmlAttributes &attrib); + + // INode + virtual const IString *id() const { return &m_id; } + virtual const IString *label() const { return &m_label; } + virtual const IString *linkId() const { return &m_link; } + virtual IChildNodeIterator *children() const; + + private: + IBaseHandler *m_parent; + StringImpl m_id; + StringImpl m_label; + StringImpl m_link; + QList<ChildNodeHandler> m_children; + GraphHandler *m_graph; +}; + +class NodeIterator : public BaseIterator<INodeIterator,INode,NodeHandler> +{ + public: + NodeIterator(const GraphHandler &handler) : + BaseIterator<INodeIterator,INode,NodeHandler>(handler.m_nodes) {} +}; + +//---------------------------------------------------------------------- + +class ChildNodeHandler : public IChildNode, public BaseHandler<ChildNodeHandler> +{ + friend class EdgeLabelIterator; + public: + ChildNodeHandler(IBaseHandler *parent,GraphHandler *gh); + virtual ~ChildNodeHandler(); + + void startChildNode(const QXmlAttributes &attrib); + void endChildNode(); + void startEdgeLabel(const QXmlAttributes &attrib); + + // IChildNode + virtual INode *node() const; + virtual NodeRelation relation() const { return m_relation; } + virtual const IString * relationString() const { return &m_relationString; } + virtual IEdgeLabelIterator *edgeLabels() const; + + private: + IBaseHandler *m_parent; + QString m_id; + NodeRelation m_relation; + StringImpl m_relationString; + QList<EdgeLabelHandler> m_edgeLabels; + GraphHandler *m_graph; +}; + +class ChildNodeIterator : public BaseIterator<IChildNodeIterator,IChildNode,ChildNodeHandler> +{ + public: + ChildNodeIterator(const NodeHandler &handler) : + BaseIterator<IChildNodeIterator,IChildNode,ChildNodeHandler>(handler.m_children) {} +}; + +//---------------------------------------------------------------------- + +class EdgeLabelHandler : public IEdgeLabel, public BaseHandler<EdgeLabelHandler> +{ + friend class EdgeLabelIterator; + public: + EdgeLabelHandler(IBaseHandler *parent); + virtual ~EdgeLabelHandler(); + + void startEdgeLabel(const QXmlAttributes &attrib); + void endEdgeLabel(); + + // IEdgeLabel + virtual const IString *label() const { return &m_label; } + + private: + IBaseHandler *m_parent; + StringImpl m_label; +}; + +class EdgeLabelIterator : public BaseIterator<IEdgeLabelIterator,IEdgeLabel,EdgeLabelHandler> +{ + public: + EdgeLabelIterator(const ChildNodeHandler &handler) : + BaseIterator<IEdgeLabelIterator,IEdgeLabel,EdgeLabelHandler>(handler.m_edgeLabels) {} +}; + +void graphhandler_init(); +void graphhandler_exit(); + +#endif + diff --git a/trunk/addon/doxmlparser/src/linkedtexthandler.cpp b/trunk/addon/doxmlparser/src/linkedtexthandler.cpp new file mode 100644 index 0000000..96d1d49 --- /dev/null +++ b/trunk/addon/doxmlparser/src/linkedtexthandler.cpp @@ -0,0 +1,133 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#include "linkedtexthandler.h" +#include "debug.h" +#include <doxmlintf.h> +#include "stringimpl.h" + +class LT_Text : public LinkedTextImpl, public ILT_Text +{ + public: + LT_Text(const QString &text) : m_text(text) {} + virtual ~LT_Text() {} + + // ILT_Text + virtual const IString *text() const { return &m_text; } + virtual Kind kind() const { return LinkedTextImpl::Kind_Text; } + private: + StringImpl m_text; +}; + +class LT_Ref : public LinkedTextImpl, public ILT_Ref +{ + public: + LT_Ref() {} + virtual ~LT_Ref() {} + void setRefId(const QString &refId) { m_refId=refId; } + void setText(const QString &text) { m_text=text; } + void setExtId(const QString &extId) { m_extId=extId; } + void setTargetKind(TargetKind k) { m_targetKind=k; } + + // ILT_Ref + virtual const IString *text() const { return &m_text; } + virtual const IString * id() const { return &m_refId; } + virtual TargetKind targetKind() const { return m_targetKind; } + virtual const IString *external() const { return &m_extId; } + virtual Kind kind() const { return LinkedTextImpl::Kind_Ref; } + + private: + StringImpl m_refId; + StringImpl m_extId; + StringImpl m_text; + TargetKind m_targetKind; +}; + +LinkedTextHandler::LinkedTextHandler(IBaseHandler *parent, + QList<LinkedTextImpl> &children + ) + : m_parent(parent), m_children(children) +{ + addStartHandler("ref",this,&LinkedTextHandler::startRef); + addEndHandler("ref",this,&LinkedTextHandler::endRef); + m_children.setAutoDelete(TRUE); + m_ref=0; +} + +LinkedTextHandler::~LinkedTextHandler() +{ +} + +void LinkedTextHandler::start(const char *endTag) +{ + addEndHandler(endTag,this,&LinkedTextHandler::end); + m_parent->setDelegate(this); + m_curString=""; +} + +void LinkedTextHandler::end() +{ + if (!m_curString.isEmpty()) + { + m_children.append(new LT_Text(m_curString)); + debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data()); + m_curString=""; + } + m_parent->setDelegate(0); +} + +void LinkedTextHandler::startRef(const QXmlAttributes& attrib) +{ + if (!m_curString.isEmpty()) + { + m_children.append(new LT_Text(m_curString)); + debug(2,"LinkedTextHandler: add text `%s'\n",m_curString.data()); + m_curString=""; + } + ASSERT(m_ref==0); + m_ref = new LT_Ref; + m_ref->setRefId(attrib.value("refid")); + m_ref->setExtId(attrib.value("external")); + ASSERT(attrib.value("kindref")=="compound" || attrib.value("kindref")=="member"); + m_ref->setTargetKind(attrib.value("kindref")=="compound" ? ILT_Ref::Compound : ILT_Ref::Member); +} + +void LinkedTextHandler::endRef() +{ + m_ref->setText(m_curString); + m_children.append(m_ref); + debug(2,"LinkedTextHandler: add ref `%s'\n",m_ref->text()->latin1()); + m_ref=0; +} + +QString LinkedTextHandler::toString(const QList<LinkedTextImpl> &list) +{ + QListIterator<LinkedTextImpl> li(list); + QString result; + LinkedTextImpl *lt; + for (li.toFirst();(lt=li.current());++li) + { + switch(lt->kind()) + { + case ILinkedText::Kind_Text: + result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1(); + break; + case ILinkedText::Kind_Ref: + result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1(); + break; + } + } + return result; +} + diff --git a/trunk/addon/doxmlparser/src/linkedtexthandler.h b/trunk/addon/doxmlparser/src/linkedtexthandler.h new file mode 100644 index 0000000..464b39d --- /dev/null +++ b/trunk/addon/doxmlparser/src/linkedtexthandler.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ +#ifndef LINKEDTEXTHANDLER_H +#define LINKEDTEXTHANDLER_H + +#include "baseiterator.h" +#include "basehandler.h" + +class LT_Ref; +class LinkedTextImpl : public ILinkedText +{ + public: + virtual ~LinkedTextImpl() {} +}; + +class LinkedTextHandler : public BaseHandler<LinkedTextHandler> +{ + public: + LinkedTextHandler(IBaseHandler *parent,QList<LinkedTextImpl> &children); + virtual ~LinkedTextHandler(); + virtual void start(const char *endTag); + virtual void end(); + virtual void startRef(const QXmlAttributes& attrib); + virtual void endRef(); + static QString toString(const QList<LinkedTextImpl> &list); + + // ILinkedText + + private: + IBaseHandler *m_parent; + QList<LinkedTextImpl> &m_children; + LT_Ref *m_ref; +}; + +class LinkedTextIterator : public BaseIterator<ILinkedTextIterator,ILinkedText,LinkedTextImpl> +{ + public: + LinkedTextIterator(const QList<LinkedTextImpl> &list) : + BaseIterator<ILinkedTextIterator,ILinkedText,LinkedTextImpl>(list) {} +}; + +#endif diff --git a/trunk/addon/doxmlparser/src/loamhandler.cpp b/trunk/addon/doxmlparser/src/loamhandler.cpp new file mode 100644 index 0000000..a939b7b --- /dev/null +++ b/trunk/addon/doxmlparser/src/loamhandler.cpp @@ -0,0 +1,75 @@ +#include "loamhandler.h" +#include "memberhandler.h" + + +ListOfAllMembersHandler::ListOfAllMembersHandler(IBaseHandler *parent) : m_parent(parent) +{ + m_members.setAutoDelete(TRUE); + + addStartHandler("member",this,&ListOfAllMembersHandler::startMember); + addStartHandler("name",this,&ListOfAllMembersHandler::startName); + addEndHandler("name",this,&ListOfAllMembersHandler::endName); + addStartHandler("scope",this,&ListOfAllMembersHandler::startScope); + addEndHandler("scope",this,&ListOfAllMembersHandler::endScope); + + addEndHandler("listofallmembers",this,&ListOfAllMembersHandler::endListOfAllMembers); +} + +void ListOfAllMembersHandler::initialize(MainHandler *mh) +{ + QListIterator<MemberReference> mli(m_members); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } +} + +void ListOfAllMembersHandler::startMember(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + mr->m_virtualness = attrib.value("virt"); + mr->m_protection = attrib.value("prot"); + mr->m_ambiguityScope = attrib.value("ambiguityscope"); + m_members.append(new MemberReference); +} + +void ListOfAllMembersHandler::startName(const QXmlAttributes&) +{ + m_curString=""; +} + +void ListOfAllMembersHandler::endName() +{ + ASSERT(m_members.getLast()); + m_members.getLast()->m_name = m_curString; +} + +void ListOfAllMembersHandler::startScope(const QXmlAttributes&) +{ + m_curString=""; +} + +void ListOfAllMembersHandler::endScope() +{ + ASSERT(m_members.getLast()); + m_members.getLast()->m_scope = m_curString; +} + +void ListOfAllMembersHandler::startListOfAllMembers(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"listofallmembers start\n"); +} + +void ListOfAllMembersHandler::endListOfAllMembers() +{ + m_parent->setDelegate(0); + debug(2,"listofallmembers end\n"); +} + +IMemberReferenceIterator *ListOfAllMembersHandler::members() const +{ + return new MemberReferenceIterator(m_members); +} diff --git a/trunk/addon/doxmlparser/src/loamhandler.h b/trunk/addon/doxmlparser/src/loamhandler.h new file mode 100644 index 0000000..ce2eda2 --- /dev/null +++ b/trunk/addon/doxmlparser/src/loamhandler.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _LOAMHANDLER_H +#define _LOAMHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <doxmlintf.h> + +#include "basehandler.h" + +class MainHandler; +class MemberReference; + +class ListOfAllMembersHandler : public BaseHandler<ListOfAllMembersHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + virtual void startScope(const QXmlAttributes& attrib); + virtual void endScope(); + virtual void startListOfAllMembers(const QXmlAttributes& attrib); + virtual void endListOfAllMembers(); + + ListOfAllMembersHandler(IBaseHandler *parent); + virtual ~ListOfAllMembersHandler() {} + + void initialize(MainHandler *mh); + + virtual IMemberReferenceIterator *members() const; + + protected: + IBaseHandler *m_parent; + QList<MemberReference> m_members; +}; + +#endif + diff --git a/trunk/addon/doxmlparser/src/mainhandler.cpp b/trunk/addon/doxmlparser/src/mainhandler.cpp new file mode 100644 index 0000000..81d7d2f --- /dev/null +++ b/trunk/addon/doxmlparser/src/mainhandler.cpp @@ -0,0 +1,299 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include <qxml.h> +#include "mainhandler.h" +#include "compoundhandler.h" +#include "sectionhandler.h" +#include "graphhandler.h" +#include "dochandler.h" +#include "memberhandler.h" +#include "debug.h" + + +class ErrorHandler : public QXmlErrorHandler +{ + public: + virtual ~ErrorHandler() {} + bool warning( const QXmlParseException & ) + { + return FALSE; + } + bool error( const QXmlParseException & ) + { + return FALSE; + } + bool fatalError( const QXmlParseException &exception ) + { + debug(1,"Fatal error at line %d column %d: %s\n", + exception.lineNumber(),exception.columnNumber(), + exception.message().data()); + return FALSE; + } + QString errorString() { return ""; } + + private: + QString errorMsg; +}; + +//-------------------------------------------------------------------------- + +class CompoundEntryIterator : public ICompoundIterator, + public QListIterator<CompoundEntry> +{ + public: + CompoundEntryIterator(const MainHandler *m,const QList<CompoundEntry> &list) : + QListIterator<CompoundEntry>(list), m_mainHandler(m) {} + virtual ~CompoundEntryIterator() {} + + virtual void toFirst() + { + QListIterator<CompoundEntry>::toFirst(); + } + virtual void toLast() + { + QListIterator<CompoundEntry>::toLast(); + } + virtual void toNext() + { + QListIterator<CompoundEntry>::operator++(); + } + virtual void toPrev() + { + QListIterator<CompoundEntry>::operator--(); + } + virtual ICompound *current() const + { + CompoundEntry *ch = QListIterator<CompoundEntry>::current(); + return ch ? m_mainHandler->compoundById(ch->id) : 0; + } + virtual void release() + { delete this; } + + private: + const MainHandler *m_mainHandler; +}; + +//-------------------------------------------------------------------------- + +MainHandler::MainHandler() : m_compoundDict(2999), m_compoundNameDict(2999), + m_memberDict(12251), m_memberNameDict(12251), + m_compoundsLoaded(1009) +{ + m_compounds.setAutoDelete(TRUE); + m_memberNameDict.setAutoDelete(TRUE); + addStartHandler("doxygenindex"); + addEndHandler("doxygenindex"); + addStartHandler("compound",this,&MainHandler::startCompound); + addEndHandler("compound"); + addStartHandler("member",this,&MainHandler::startMember); + addEndHandler("member",this,&MainHandler::endMember); + addStartHandler("name",this,&MainHandler::startName); + addEndHandler("name",this,&MainHandler::endName); + m_curCompound = 0; + m_insideMember = FALSE; +} + +MainHandler::~MainHandler() +{ + debug(2,"MainHandler::~MainHandler()\n"); +} + +void MainHandler::startCompound(const QXmlAttributes& attrib) +{ + m_curCompound = new CompoundEntry(257); + m_curCompound->id = attrib.value("refid"); + m_compounds.append(m_curCompound); + m_compoundDict.insert(m_curCompound->id,m_curCompound); +} + +void MainHandler::startName(const QXmlAttributes& /*attrib*/) +{ + m_curString = ""; +} + +void MainHandler::endName() +{ + if (m_insideMember) + { + m_curMember->name = m_curString; + } + else + { + m_curCompound->name = m_curString; + m_compoundNameDict.insert(m_curString,m_curCompound); + } +} + +void MainHandler::startMember(const QXmlAttributes& attrib) +{ + m_insideMember = TRUE; + m_curMember = new MemberEntry; + m_curMember->id = attrib.value("refid"); + m_curMember->compound = m_curCompound; + m_memberDict.insert(m_curMember->id,m_curMember); +} + +void MainHandler::endMember() +{ + m_curCompound->memberDict.insert(m_curMember->name,m_curMember); + QList<CompoundEntry> *cel=0; + if ((cel=m_memberNameDict.find(m_curMember->name))==0) + { + cel = new QList<CompoundEntry>; + m_memberNameDict.insert(m_curMember->name,cel); + } + cel->append(m_curCompound); + m_insideMember = FALSE; +} + +void MainHandler::setDebugLevel(int level) +{ + ::setDebugLevel(level); +} + +void MainHandler::dump() +{ + QListIterator<CompoundEntry> cli(m_compounds); + CompoundEntry *ce; + for (cli.toFirst();(ce=cli.current());++cli) + { + debug(2,"compound id=`%s' name=`%s'\n",ce->id.data(),ce->name.data()); + QDictIterator<MemberEntry> mdi(ce->memberDict); + MemberEntry *me; + for (mdi.toFirst();(me=mdi.current());++mdi) + { + debug(2," member id=`%s' name=`%s'\n",me->id.data(),me->name.data()); + } + } +} + +bool MainHandler::readXMLDir(const char * xmlDirName) +{ + m_xmlDirName = xmlDirName; + QString xmlFileName=m_xmlDirName+"/index.xml"; + QFile xmlFile(xmlFileName); + //printf("Trying %s xmlFile.exists()=%d isReadable()=%d\n", + // xmlFileName.data(),xmlFile.exists(),xmlFile.isReadable()); + if (xmlFile.exists()) + { + ErrorHandler errorHandler; + QXmlInputSource source( xmlFile ); + QXmlSimpleReader reader; + reader.setContentHandler( this ); + reader.setErrorHandler( &errorHandler ); + reader.parse( source ); + dump(); + return TRUE; + } + return FALSE; +} + +ICompoundIterator *MainHandler::compounds() const +{ + return new CompoundEntryIterator(this,m_compounds); +} + +ICompound *MainHandler::compoundById(const char *id) const +{ + QString ids = id; + if (ids.isEmpty()) return 0; + CompoundHandler *ch = m_compoundsLoaded[ids]; + if (ch) // compound already in memory + { + ch->addref(); // returning alias -> increase reference counter + return ch->toICompound(); + } + CompoundEntry *ce = m_compoundDict.find(ids); + if (ce==0) return 0; // id not found + // create and load a new compound + ch = new CompoundHandler(m_xmlDirName); + if (!ch->parseXML(id)) + { + // compound could not be initialized. + delete ch; + return 0; + } + + // we disregard the constness here, because the object stays conceptually + // unchanged. + MainHandler *that = (MainHandler *)this; + ch->initialize(that); + //printf("loading compound %s in memory\n",id); + that->m_compoundsLoaded.insert(id,ch); + return ch->toICompound(); +} + +void MainHandler::unloadCompound(CompoundHandler *ch) +{ + //printf("unloading compound %s from memory\n",ch->id()->latin1()); + bool result = m_compoundsLoaded.remove(ch->id()->latin1()); + if (!result) debug(1,"Failed to unload component!\n"); +} + +ICompound *MainHandler::compoundByName(const char *name) const +{ + QString nameStr = name; + if (nameStr.isEmpty()) return 0; + CompoundEntry *ce = m_compoundNameDict[name]; + if (ce==0) return 0; // name not found + return compoundById(ce->id); +} + +ICompound *MainHandler::memberById(const char *id) const +{ + QString ids = id; + if (ids.isEmpty()) return 0; + MemberEntry *me = m_memberDict[id]; + if (me==0) return 0; // id not found + return compoundById(me->compound->id); +} + +ICompoundIterator *MainHandler::memberByName(const char *name) const +{ + QString nameStr = name; + if (nameStr.isEmpty()) return 0; + QList<CompoundEntry> *cel = m_memberNameDict[name]; + if (cel==0) return 0; // name not found + return new CompoundEntryIterator(this,*cel); +} + +IDoxygen *createObjectModel() +{ + compoundhandler_init(); + sectionhandler_init(); + memberhandler_init(); + dochandler_init(); + graphhandler_init(); + return new MainHandler; +} + +void MainHandler::release() +{ + //printf("MainHandler::release()\n"); + QDictIterator<CompoundHandler> chi(m_compoundsLoaded); + CompoundHandler *ch; + for (chi.toFirst();(ch=chi.current());++chi) + { + debug(1,"Compound %s not released\n",ch->name()->latin1()); + } + graphhandler_exit(); + dochandler_exit(); + memberhandler_exit(); + sectionhandler_exit(); + compoundhandler_exit(); + delete this; +} + diff --git a/trunk/addon/doxmlparser/src/mainhandler.h b/trunk/addon/doxmlparser/src/mainhandler.h new file mode 100644 index 0000000..9ac8b79 --- /dev/null +++ b/trunk/addon/doxmlparser/src/mainhandler.h @@ -0,0 +1,82 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _MAINHANDLER_H +#define _MAINHANDLER_H + +#include <qlist.h> + +#include <doxmlintf.h> +#include "basehandler.h" + +class CompoundHandler; +struct CompoundEntry; + +struct IndexEntry +{ + QString id; + QString name; +}; + +struct MemberEntry : public IndexEntry +{ + CompoundEntry *compound; +}; + +struct CompoundEntry : public IndexEntry +{ + CompoundEntry(int size) : memberDict(size) + { memberDict.setAutoDelete(TRUE); } + QDict<MemberEntry> memberDict; +}; + +class MainHandler : public IDoxygen, public BaseHandler<MainHandler> +{ + public: + virtual void startCompound(const QXmlAttributes& attrib); + virtual void startMember(const QXmlAttributes& attrib); + virtual void endMember(); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + MainHandler(); + virtual ~MainHandler(); + + // IDoxygen + ICompoundIterator *compounds() const; + ICompound *compoundById(const char *id) const; + virtual ICompound *compoundByName(const char *name) const; + virtual ICompound *memberById(const char *id) const; + virtual ICompoundIterator *memberByName(const char *name) const; + + virtual void release(); + void setDebugLevel(int level); + bool readXMLDir(const char *dirName); + void dump(); + void unloadCompound(CompoundHandler *ch); + + private: + CompoundEntry *m_curCompound; + MemberEntry *m_curMember; + QList<CompoundEntry> m_compounds; + QDict<CompoundEntry> m_compoundDict; + QDict<CompoundEntry> m_compoundNameDict; + QDict<MemberEntry> m_memberDict; + QDict<QList<CompoundEntry> > m_memberNameDict; + QString m_xmlDirName; + QDict<CompoundHandler> m_compoundsLoaded; + bool m_insideMember; +}; + +#endif diff --git a/trunk/addon/doxmlparser/src/memberhandler.cpp b/trunk/addon/doxmlparser/src/memberhandler.cpp new file mode 100644 index 0000000..9ccc014 --- /dev/null +++ b/trunk/addon/doxmlparser/src/memberhandler.cpp @@ -0,0 +1,600 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "memberhandler.h" +#include "sectionhandler.h" +#include "dochandler.h" +#include "mainhandler.h" +#include "linkedtexthandler.h" +#include "paramhandler.h" +#include "compoundhandler.h" +#include "debug.h" + +//------------------------------------------------------------------------------ + +class MemberTypeMap +{ + public: + MemberTypeMap() + { + m_map.setAutoDelete(TRUE); + m_map.insert("define",new int(IMember::Define)); + m_map.insert("property",new int(IMember::Property)); + m_map.insert("variable",new int(IMember::Variable)); + m_map.insert("typedef",new int(IMember::Typedef)); + m_map.insert("enum",new int(IMember::Enum)); + m_map.insert("function",new int(IMember::Function)); + m_map.insert("signal",new int(IMember::Signal)); + m_map.insert("prototype",new int(IMember::Prototype)); + m_map.insert("friend",new int(IMember::Friend)); + m_map.insert("dcop",new int(IMember::DCOP)); + m_map.insert("slot",new int(IMember::Slot)); + m_map.insert("enumvalue",new int(IMember::EnumValue)); + } + IMember::MemberKind map(const QString &s) + { + int *val = m_map.find(s); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid member type\n",s.data()); + return IMember::Invalid; + } + else return (IMember::MemberKind)*val; + } + private: + QDict<int> m_map; +}; + +static MemberTypeMap *s_typeMap; + +void memberhandler_init() +{ + s_typeMap = new MemberTypeMap; +} + +void memberhandler_exit() +{ + delete s_typeMap; +} + +//------------------------------------------------------------------------------ + +void MemberReference::initialize(MainHandler *mh) +{ + m_mainHandler = mh; +} + +IMember *MemberReference::member() const +{ + //return m_mainHandler->memberById(m_memId); + return 0; +} + +//------------------------------------------------------------------------------ + + +#if 0 +EnumValueHandler::EnumValueHandler(IBaseHandler *parent) : + m_parent(parent), m_brief(0), m_detailed(0), m_linkedTextHandler(0) +{ + addEndHandler("enumvalue",this,&EnumValueHandler::endEnumValue); + + addStartHandler("name",this,&EnumValueHandler::startName); + addEndHandler("name",this,&EnumValueHandler::endName); + addStartHandler("initializer",this,&EnumValueHandler::startInitializer); + + addStartHandler("briefdescription",this,&EnumValueHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&EnumValueHandler::startDetailedDesc); + + m_initializer.setAutoDelete(TRUE); +} + +EnumValueHandler::~EnumValueHandler() +{ + delete m_brief; + delete m_detailed; + delete m_linkedTextHandler; +} + +void EnumValueHandler::startEnumValue(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); +} + +void EnumValueHandler::endEnumValue() +{ + m_parent->setDelegate(0); +} + +void EnumValueHandler::startName(const QXmlAttributes& /*attrib*/) +{ + m_curString=""; +} + +void EnumValueHandler::endName() +{ + m_name = m_curString; +} + +void EnumValueHandler::startInitializer(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_initializer); + m_linkedTextHandler->start("initializer"); +} + +void EnumValueHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void EnumValueHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} +#endif + +//------------------------------------------------------------------------------ + +MemberHandler::MemberHandler(IBaseHandler *parent) + : m_brief(0), m_detailed(0), m_inbody(0), + m_compound(0), m_section(0), m_parent(parent) +{ + //printf("MemberHandler::MemberHandler() %p\n",this); + addEndHandler("memberdef",this,&MemberHandler::endMember); + + addStartHandler("templateparamlist",this,&MemberHandler::startTemplateParamList); + addEndHandler("templateparamlist",this,&MemberHandler::endTemplateParamList); + + addStartHandler("type",this,&MemberHandler::startType); + + addStartHandler("definition",this,&MemberHandler::startDefinition); + addEndHandler("definition",this,&MemberHandler::endDefinition); + + addStartHandler("argsstring",this,&MemberHandler::startArgsString); + addEndHandler("argsstring",this,&MemberHandler::endArgsString); + + addStartHandler("name",this,&MemberHandler::startName); + addEndHandler("name",this,&MemberHandler::endName); + + addStartHandler("read",this,&MemberHandler::startRead); + addEndHandler("read",this,&MemberHandler::endRead); + + addStartHandler("write",this,&MemberHandler::startWrite); + addEndHandler("write",this,&MemberHandler::endWrite); + + addStartHandler("reimplements",this,&MemberHandler::startReimplements); + addEndHandler("reimplements",this,&MemberHandler::endReimplements); + + addStartHandler("reimplementedby",this,&MemberHandler::startReimplementedBy); + addEndHandler("reimplementedby",this,&MemberHandler::endReimplementedBy); + + addStartHandler("param",this,&MemberHandler::startParam); + + addStartHandler("enumvalue",this,&MemberHandler::startEnumValue2); + addEndHandler("enumvalue",this,&MemberHandler::endMember); + + addStartHandler("initializer",this,&MemberHandler::startInitializer); + addStartHandler("exceptions",this,&MemberHandler::startException); + + addStartHandler("briefdescription",this,&MemberHandler::startBriefDesc); + + addStartHandler("detaileddescription",this,&MemberHandler::startDetailedDesc); + + addStartHandler("inbodydescription",this,&MemberHandler::startInbodyDesc); + + addStartHandler("location",this,&MemberHandler::startLocation); + addEndHandler("location"); + + addStartHandler("references",this,&MemberHandler::startReferences); + addEndHandler("references",this,&MemberHandler::endReferences); + + addStartHandler("referencedby",this,&MemberHandler::startReferencedBy); + addEndHandler("referencedby",this,&MemberHandler::endReferencedBy); + + m_type.setAutoDelete(TRUE); + m_initializer.setAutoDelete(TRUE); + m_exception.setAutoDelete(TRUE); + m_params.setAutoDelete(TRUE); + m_references.setAutoDelete(TRUE); + m_referencedBy.setAutoDelete(TRUE); + m_reimplements = 0; + m_reimplementedBy.setAutoDelete(TRUE); + m_enumValues.setAutoDelete(TRUE); + m_linkedTextHandler = 0; + m_defLine=0; + m_bodyStart=0; + m_bodyEnd=0; + m_insideTemplateParamList=FALSE; + m_hasTemplateParamList=FALSE; +} + +MemberHandler::~MemberHandler() +{ + debug(2,"MemberHandler::~MemberHandler() %p\n",this); + delete m_brief; + delete m_detailed; + delete m_inbody; + delete m_linkedTextHandler; + delete m_reimplements; +} + +void MemberHandler::startMember(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = attrib.value("kind"); + //printf("startMember kindString=`%s'\n",m_kindString.data()); + m_kind = s_typeMap->map(m_kindString); + m_id = attrib.value("id"); + m_protection = attrib.value("prot"); + m_isStatic = attrib.value("static")=="yes"; + m_isConst = attrib.value("const")=="yes"; + m_isExplicit = attrib.value("explicit")=="yes"; + m_isInline = attrib.value("inline")=="yes"; + m_virtualness = attrib.value("virt"); + m_isVolatile = attrib.value("volatile")=="yes"; + m_isMutable = attrib.value("mutable")=="yes"; + m_isReadable = attrib.value("readable")=="yes"; + m_isWritable = attrib.value("writable")=="yes"; + + debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n", + m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data()); +} + +void MemberHandler::startEnumValue(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = "enumvalue"; + //printf("startEnumValue kindString=`%s'\n",m_kindString.data()); + m_kind = s_typeMap->map(m_kindString); + m_id = attrib.value("id"); + m_protection = attrib.value("prot"); + m_isStatic = FALSE; + m_isConst = FALSE; + m_isExplicit = FALSE; + m_isInline = FALSE; + m_virtualness = "non-virtual"; + m_isVolatile = FALSE; + m_isMutable = FALSE; + m_isReadable = FALSE; + m_isWritable = FALSE; + debug(2,"member kind=`%s' id=`%s' prot=`%s' virt=`%s'\n", + m_kindString.data(),m_id.data(),m_protection.data(),m_virtualness.data()); +} + +void MemberHandler::startEnumValue2(const QXmlAttributes& attrib) +{ + MemberHandler *mh = new MemberHandler(this); + mh->startEnumValue(attrib); + m_enumValues.append(mh); +} + + +void MemberHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +void MemberHandler::startDetailedDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_detailed = docHandler; +} + +void MemberHandler::startInbodyDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_inbody = docHandler; +} + +void MemberHandler::startLocation(const QXmlAttributes& attrib) +{ + m_defFile = attrib.value("file"); + m_bodyFile = attrib.value("bodyfile"); + QCString s; + s = attrib.value("line"); + if (!s.isEmpty()) m_defLine=s.toInt(); + s = attrib.value("bodystart"); + if (!s.isEmpty()) m_bodyStart=s.toInt(); + s = attrib.value("bodyend"); + if (!s.isEmpty()) m_bodyEnd=s.toInt(); +} + +void MemberHandler::startReferences(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_references.append(mr); + m_curString=""; +} + +void MemberHandler::endReferences() +{ + m_references.getLast()->m_name = m_curString; +} + +void MemberHandler::startReferencedBy(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_referencedBy.append(mr); + m_curString=""; +} + +void MemberHandler::endReferencedBy() +{ + m_referencedBy.getLast()->m_name = m_curString; +} + +void MemberHandler::startReimplements(const QXmlAttributes& attrib) +{ + m_reimplements = new MemberReference; + m_reimplements->m_memId = attrib.value("refid"); + m_curString=""; +} + +void MemberHandler::endReimplements() +{ + m_reimplements->m_name = m_curString; +} + +void MemberHandler::startReimplementedBy(const QXmlAttributes& attrib) +{ + MemberReference *mr = new MemberReference; + mr->m_memId = attrib.value("refid"); + m_reimplementedBy.append(mr); + m_curString=""; +} + +void MemberHandler::endReimplementedBy() +{ + m_reimplementedBy.getLast()->m_name = m_curString; +} + +void MemberHandler::endMember() +{ + m_parent->setDelegate(0); +} + +void MemberHandler::startType(const QXmlAttributes &) +{ + debug(2,"startType!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_type); + m_linkedTextHandler->start("type"); +} + +void MemberHandler::startInitializer(const QXmlAttributes &) +{ + debug(2,"startInitializer!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_initializer); + m_linkedTextHandler->start("initializer"); +} + +void MemberHandler::startException(const QXmlAttributes &) +{ + debug(2,"startException!\n"); + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_exception); + m_linkedTextHandler->start("exceptions"); +} + +void MemberHandler::startName(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endName() +{ + m_name = m_curString.stripWhiteSpace(); + debug(2,"member name=`%s'\n",m_name.data()); +} + +void MemberHandler::startRead(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endRead() +{ + m_read = m_curString.stripWhiteSpace(); + debug(2,"member read=`%s'\n",m_read.data()); +} + +void MemberHandler::startWrite(const QXmlAttributes &) +{ + m_curString=""; +} + +void MemberHandler::endWrite() +{ + m_write = m_curString.stripWhiteSpace(); + debug(2,"member write=`%s'\n",m_write.data()); +} + +void MemberHandler::startDefinition(const QXmlAttributes&) +{ + m_curString=""; +} + +void MemberHandler::endDefinition() +{ + m_definition = m_curString.stripWhiteSpace(); + debug(2,"definition=%s\n",m_definition.data()); +} + +void MemberHandler::startArgsString(const QXmlAttributes&) +{ + m_curString=""; +} + +void MemberHandler::endArgsString() +{ + m_argsstring = m_curString.stripWhiteSpace(); + debug(2,"arggstring=%s\n",m_argsstring.data()); +} + +void MemberHandler::startParam(const QXmlAttributes& attrib) +{ + ParamHandler *paramHandler = new ParamHandler(this); + paramHandler->startParam(attrib); + if (m_insideTemplateParamList) + { + m_templateParams.append(paramHandler); + } + else + { + m_params.append(paramHandler); + } +} + +void MemberHandler::startTemplateParamList(const QXmlAttributes&) +{ + m_insideTemplateParamList = TRUE; + m_hasTemplateParamList = TRUE; +} + +void MemberHandler::endTemplateParamList() +{ + m_insideTemplateParamList = FALSE; +} + +void MemberHandler::initialize(MainHandler *mh) +{ + { + QListIterator<MemberReference> mli(m_references); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + { + QListIterator<MemberReference> mli(m_referencedBy); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + { + QListIterator<MemberReference> mli(m_reimplementedBy); + MemberReference *mr; + for (;(mr=mli.current());++mli) + { + mr->initialize(mh); + } + } + if (m_reimplements) m_reimplements->initialize(mh); +} + +void MemberHandler::setCompoundHandler(CompoundHandler *c) +{ + m_compound = c; +} + +ICompound *MemberHandler::compound() const +{ + m_compound->addref(); + return m_compound->toICompound(); +} + +void MemberHandler::setSectionHandler(SectionHandler *c) +{ + m_section = c; +} + +ISection *MemberHandler::section() const +{ + return m_section; +} + +IMemberIterator *MemberHandler::enumValues() const +{ + return new MemberIterator(m_enumValues); +} + +ILinkedTextIterator *MemberHandler::type() const +{ + return new LinkedTextIterator(m_type); +} + +const IString *MemberHandler::typeString() const +{ + MemberHandler *that = (MemberHandler *)this; + that->m_typeString = LinkedTextHandler::toString(m_type); + return &m_typeString; +} + +IParamIterator *MemberHandler::parameters() const +{ + return new ParamIterator(m_params); +} + +IParamIterator *MemberHandler::templateParameters() const +{ + return m_hasTemplateParamList ? new ParamIterator(m_templateParams) : 0; +} + +IMemberReferenceIterator *MemberHandler::references() const +{ + return new MemberReferenceIterator(m_references); +} + +IMemberReferenceIterator *MemberHandler::referencedBy() const +{ + return new MemberReferenceIterator(m_referencedBy); +} + +ILinkedTextIterator *MemberHandler::initializer() const +{ + return new LinkedTextIterator(m_initializer); +} + +ILinkedTextIterator *MemberHandler::exceptions() const +{ + return new LinkedTextIterator(m_exception); +} + +IMemberReferenceIterator *MemberHandler::reimplementedBy() const +{ + return new MemberReferenceIterator(m_reimplementedBy); +} + +IDocRoot *MemberHandler::briefDescription() const +{ + return m_brief; +} + +IDocRoot *MemberHandler::detailedDescription() const +{ + return m_detailed; +} + +IDocRoot *MemberHandler::inbodyDescription() const +{ + return m_inbody; +} + diff --git a/trunk/addon/doxmlparser/src/memberhandler.h b/trunk/addon/doxmlparser/src/memberhandler.h new file mode 100644 index 0000000..9b409b6 --- /dev/null +++ b/trunk/addon/doxmlparser/src/memberhandler.h @@ -0,0 +1,252 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _MEMBERHANDLER_H +#define _MEMBERHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "basehandler.h" +#include "baseiterator.h" +#include "stringimpl.h" + +class MainHandler; +class CompoundHandler; +class SectionHandler; +class ParamHandler; +class LinkedTextImpl; +class LinkedTextHandler; +class DocHandler; + +class MemberReference : public IMemberReference +{ + public: + virtual ~MemberReference() {} + virtual IMember *member() const; + virtual const IString *name() const { return &m_name; } + virtual const IString *scope() const { return &m_scope; } + virtual const IString *protection() const { return &m_protection; } + virtual const IString *virtualness() const { return &m_virtualness; } + virtual const IString *ambiguityScope() const { return &m_ambiguityScope; } + void initialize(MainHandler *m); + + QString m_memId; + StringImpl m_name; + StringImpl m_scope; + StringImpl m_virtualness; + StringImpl m_protection; + StringImpl m_ambiguityScope; + MainHandler *m_mainHandler; +}; + +class MemberReferenceIterator : public BaseIterator<IMemberReferenceIterator,IMemberReference,MemberReference> +{ + public: + MemberReferenceIterator(const QList<MemberReference> &list) : + BaseIterator<IMemberReferenceIterator,IMemberReference,MemberReference>(list) {} +}; + +class MemberHandler : public IDefine, + public IProperty, + public IVariable, + public ITypedef, + public IFunction, + public ISignal, + public IPrototype, + public IFriend, + public IDCOP, + public ISlot, + public IEnum, + public IEnumValue, + public BaseHandler<MemberHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void endMember(); + virtual void startParam(const QXmlAttributes& attrib); + virtual void startType(const QXmlAttributes& attrib); + virtual void startName(const QXmlAttributes& attrib); + virtual void endName(); + virtual void startRead(const QXmlAttributes& attrib); + virtual void endRead(); + virtual void startWrite(const QXmlAttributes& attrib); + virtual void endWrite(); + virtual void startDefinition(const QXmlAttributes& attrib); + virtual void endDefinition(); + virtual void startArgsString(const QXmlAttributes& attrib); + virtual void endArgsString(); + virtual void startBriefDesc(const QXmlAttributes& attrib); + virtual void startDetailedDesc(const QXmlAttributes& attrib); + virtual void startInbodyDesc(const QXmlAttributes& attrib); + virtual void startLocation(const QXmlAttributes& attrib); + virtual void startReferences(const QXmlAttributes& attrib); + virtual void endReferences(); + virtual void startReferencedBy(const QXmlAttributes& attrib); + virtual void endReferencedBy(); + virtual void startReimplements(const QXmlAttributes& attrib); + virtual void endReimplements(); + virtual void startReimplementedBy(const QXmlAttributes& attrib); + virtual void endReimplementedBy(); + virtual void startInitializer(const QXmlAttributes& attrib); + virtual void startException(const QXmlAttributes& attrib); + virtual void startEnumValue(const QXmlAttributes& attrib); + virtual void startEnumValue2(const QXmlAttributes& attrib); + virtual void startTemplateParamList(const QXmlAttributes &attrib); + virtual void endTemplateParamList(); + + MemberHandler(IBaseHandler *parent); + virtual ~MemberHandler(); + + // IMember implementation + virtual ICompound *compound() const; + virtual ISection *section() const; + virtual MemberKind kind() const + { return m_kind; } + virtual const IString *kindString() const + { return &m_kindString; } + virtual const IString *id() const + { return &m_id; } + virtual const IString *protection() const + { return &m_protection; } + virtual const IString *virtualness() const + { return &m_virtualness; } + virtual const IString *name() const + { return &m_name; } + virtual const IString *readAccessor() const + { return &m_read; } + virtual const IString *writeAccessor() const + { return &m_write; } + virtual const IString *definition() const + { return &m_definition; } + virtual const IString *argsstring() const + { return &m_argsstring; } + virtual bool isConst() const + { return m_isConst; } + virtual bool isVolatile() const + { return m_isVolatile; } + virtual bool isStatic() const + { return m_isStatic; } + virtual bool isExplicit() const + { return m_isExplicit; } + virtual bool isInline() const + { return m_isInline; } + virtual bool isMutable() const + { return m_isMutable; } + virtual bool isReadable() const + { return m_isReadable; } + virtual bool isWritable() const + { return m_isWritable; } + virtual ILinkedTextIterator *type() const; + virtual const IString *typeString() const; + virtual IParamIterator *parameters() const; + virtual IParamIterator *templateParameters() const; + virtual IMemberReferenceIterator *references() const; + virtual IMemberReferenceIterator *referencedBy() const; + virtual ILinkedTextIterator *initializer() const; + virtual ILinkedTextIterator *exceptions() const; + virtual const IString *bodyFile() const + { return &m_bodyFile; } + virtual int bodyStart() const + { return m_bodyStart; } + virtual int bodyEnd() const + { return m_bodyEnd; } + virtual const IString *definitionFile() const + { return &m_defFile; } + virtual int definitionLine() const + { return m_defLine; } + virtual IMemberReference *reimplements() const + { return m_reimplements; } + virtual IMemberReferenceIterator *reimplementedBy() const; + virtual IDocRoot *briefDescription() const; + virtual IDocRoot *detailedDescription() const; + virtual IDocRoot *inbodyDescription() const; + + // IEnum + virtual IMemberIterator *enumValues() const; + + void initialize(MainHandler *m); + void setCompoundHandler(CompoundHandler *c); + void setSectionHandler(SectionHandler *s); + + private: + // XML elements: + // ----------------- + QList<ParamHandler> m_templateParams; // templateparamlist + QList<LinkedTextImpl> m_type; // type + StringImpl m_definition; // definition + StringImpl m_argsstring; // argsstring + StringImpl m_name; // name + StringImpl m_read; // read + StringImpl m_write; // write + MemberReference *m_reimplements; // reimplements + QList<MemberReference> m_reimplementedBy; // reimplementedby + QList<ParamHandler> m_params; // param + QList<MemberHandler> m_enumValues; // enumvalue + QList<LinkedTextImpl> m_initializer; // initializer + QList<LinkedTextImpl> m_exception; // exceptions + DocHandler *m_brief; // briefdescription + DocHandler *m_detailed; // detaileddescription + DocHandler *m_inbody; // inbodydescription + // location + StringImpl m_defFile; // - file + int m_defLine; // - line + StringImpl m_bodyFile; // - bodyfile + int m_bodyStart; // - bodystart + int m_bodyEnd; // - bodyend + QList<MemberReference> m_references; // references + QList<MemberReference> m_referencedBy; // referencedby + + // XML attributes: + // --------------- + MemberKind m_kind; // kind + StringImpl m_kindString; // kind as a string + StringImpl m_id; // id + StringImpl m_protection; // prot + bool m_isStatic; // static + bool m_isConst; // const + bool m_isExplicit; // explicit + bool m_isInline; // inline + StringImpl m_virtualness; // virt + bool m_isVolatile; // volatile + bool m_isMutable; // mutable + bool m_isReadable; // readable + bool m_isWritable; // writable + + CompoundHandler *m_compound; + SectionHandler *m_section; + StringImpl m_typeString; + LinkedTextHandler *m_linkedTextHandler; + bool m_insideTemplateParamList; + bool m_hasTemplateParamList; + IBaseHandler *m_parent; +}; + +class MemberIterator : public BaseIteratorVia<IMemberIterator, + IMember, + MemberHandler, + IFunction> +{ + public: + MemberIterator(const QList<MemberHandler> &list) : + BaseIteratorVia<IMemberIterator,IMember,MemberHandler,IFunction>(list) {} +}; + +void memberhandler_init(); +void memberhandler_exit(); + +#endif diff --git a/trunk/addon/doxmlparser/src/paramhandler.cpp b/trunk/addon/doxmlparser/src/paramhandler.cpp new file mode 100644 index 0000000..733dde4 --- /dev/null +++ b/trunk/addon/doxmlparser/src/paramhandler.cpp @@ -0,0 +1,158 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "paramhandler.h" +#include "memberhandler.h" +#include "linkedtexthandler.h" +#include "debug.h" +#include "dochandler.h" + +TemplateParamListHandler::TemplateParamListHandler(IBaseHandler *parent) : m_parent(parent) +{ + addStartHandler("param",this,&TemplateParamListHandler::startParam); + + addEndHandler("templateparamlist",this,&TemplateParamListHandler::endTemplateParamList); +} + +void TemplateParamListHandler::startParam(const QXmlAttributes& attrib) +{ + ParamHandler *ph = new ParamHandler(this); + ph->startParam(attrib); + m_templateParams.append(ph); +} + +void TemplateParamListHandler::endParam() +{ +} + +void TemplateParamListHandler::startTemplateParamList(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"templateparamlist\n"); +} + +void TemplateParamListHandler::endTemplateParamList() +{ + m_parent->setDelegate(0); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////// + +ParamHandler::ParamHandler(IBaseHandler *parent) : m_brief(0), m_parent(parent) +{ + addEndHandler("param",this,&ParamHandler::endParam); + + addStartHandler("type",this,&ParamHandler::startType); + + addStartHandler("declname"); + addEndHandler("declname",this,&ParamHandler::endDeclName); + + addStartHandler("defname"); + addEndHandler("defname",this,&ParamHandler::endDefName); + + addStartHandler("array"); + addEndHandler("array",this,&ParamHandler::endArray); + + addStartHandler("attribute"); + addEndHandler("attribute",this,&ParamHandler::endAttrib); + + addStartHandler("briefdescription",this,&ParamHandler::startBriefDesc); + + addStartHandler("defval",this,&ParamHandler::startDefVal); + + m_linkedTextHandler = 0; +} + +ParamHandler::~ParamHandler() +{ + delete m_brief; + delete m_linkedTextHandler; +} + +void ParamHandler::startParam(const QXmlAttributes& /*attrib*/) +{ + m_parent->setDelegate(this); + debug(2,"param\n"); +} + +void ParamHandler::endParam() +{ + m_parent->setDelegate(0); +} + +void ParamHandler::startType(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_type); + m_linkedTextHandler->start("type"); + debug(2,"param type\n"); +} + +void ParamHandler::endDeclName() +{ + m_declName = m_curString.stripWhiteSpace(); + debug(2,"member declName=`%s'\n",m_declName.data()); +} + +void ParamHandler::endDefName() +{ + m_defName = m_curString.stripWhiteSpace(); + debug(2,"member defName=`%s'\n",m_defName.data()); +} + +void ParamHandler::endAttrib() +{ + m_attrib = m_curString.stripWhiteSpace(); + debug(2,"member attrib=`%s'\n",m_attrib.data()); +} + +void ParamHandler::endArray() +{ + m_array = m_curString.stripWhiteSpace(); + debug(2,"member array=`%s'\n",m_array.data()); +} + +void ParamHandler::startDefVal(const QXmlAttributes& /*attrib*/) +{ + delete m_linkedTextHandler; + m_linkedTextHandler = new LinkedTextHandler(this,m_defVal); + m_linkedTextHandler->start("defval"); + debug(2,"member defVal\n"); +} + +void ParamHandler::startBriefDesc(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_brief = docHandler; +} + +ILinkedTextIterator *ParamHandler::type() const +{ + return new LinkedTextIterator(m_type); +} + +ILinkedTextIterator *ParamHandler::defaultValue() const +{ + return new LinkedTextIterator(m_defVal); +} + +IDocRoot *ParamHandler::briefDescription() const +{ + return m_brief; +} + + + diff --git a/trunk/addon/doxmlparser/src/paramhandler.h b/trunk/addon/doxmlparser/src/paramhandler.h new file mode 100644 index 0000000..d840679 --- /dev/null +++ b/trunk/addon/doxmlparser/src/paramhandler.h @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _PARAMHANDLER_H +#define _PARAMHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "stringimpl.h" +#include "basehandler.h" +#include "baseiterator.h" + +class LinkedTextImpl; +class LinkedTextHandler; +class DocHandler; + + +class ParamHandler : public IParam, public BaseHandler<ParamHandler> +{ + public: + virtual void startParam(const QXmlAttributes& attrib); + virtual void endParam(); + virtual void startType(const QXmlAttributes& attrib); + virtual void endDeclName(); + virtual void endDefName(); + virtual void endAttrib(); + virtual void endArray(); + virtual void startDefVal(const QXmlAttributes& attrib); + virtual void startBriefDesc(const QXmlAttributes& attrib); + + ParamHandler(IBaseHandler *parent); + virtual ~ParamHandler(); + + // IParam + virtual ILinkedTextIterator *type() const; + virtual const IString * declarationName() const { return &m_declName; } + virtual const IString * definitionName() const { return &m_defName; } + virtual const IString * attrib() const { return &m_attrib; } + virtual const IString * arraySpecifier() const { return &m_array; } + virtual ILinkedTextIterator *defaultValue() const; + virtual IDocRoot *briefDescription() const; + + private: + + // XML elements: + // ------------- + QList<LinkedTextImpl> m_type; // type + StringImpl m_declName; // declname + StringImpl m_defName; // defname + StringImpl m_array; // array + QList<LinkedTextImpl> m_defVal; // defval + DocHandler *m_brief; // briefdescription + + StringImpl m_attrib; // TODO: not yet in XML output + + IBaseHandler *m_parent; + LinkedTextHandler *m_linkedTextHandler; +}; + +class ParamIterator : public BaseIterator<IParamIterator,IParam,ParamHandler> +{ + public: + ParamIterator(const QList<ParamHandler> &list) : + BaseIterator<IParamIterator,IParam,ParamHandler>(list) {} +}; + +class TemplateParamListHandler : public BaseHandler<TemplateParamListHandler> +{ + public: + + virtual void startParam(const QXmlAttributes& attrib); + virtual void endParam(); + + virtual void startTemplateParamList(const QXmlAttributes& attrib); + virtual void endTemplateParamList(); + + TemplateParamListHandler(IBaseHandler *parent); + virtual ~TemplateParamListHandler() {} + + ParamIterator* templateParams() { return new ParamIterator(m_templateParams); } + + protected: + IBaseHandler *m_parent; + QList<ParamHandler> m_templateParams; +}; + + +#endif diff --git a/trunk/addon/doxmlparser/src/sectionhandler.cpp b/trunk/addon/doxmlparser/src/sectionhandler.cpp new file mode 100644 index 0000000..403cb6f --- /dev/null +++ b/trunk/addon/doxmlparser/src/sectionhandler.cpp @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "mainhandler.h" +#include "compoundhandler.h" +#include "sectionhandler.h" +#include "memberhandler.h" +#include "dochandler.h" +#include "debug.h" + +class SectionTypeMap +{ + public: + SectionTypeMap() : m_map(37) + { + m_map.setAutoDelete(TRUE); + m_map.insert("user-defined",new int(ISection::UserDefined)); + m_map.insert("public-type",new int(ISection::PubTypes)); + m_map.insert("public-func",new int(ISection::PubFuncs)); + m_map.insert("public-attrib",new int(ISection::PubAttribs)); + m_map.insert("public-slot",new int(ISection::PubSlots)); + m_map.insert("signal",new int(ISection::Signals)); + m_map.insert("dcop-func",new int(ISection::DCOPFuncs)); + m_map.insert("property",new int(ISection::Properties)); + m_map.insert("event",new int(ISection::Events)); + m_map.insert("public-static-func",new int(ISection::PubStatFuncs)); + m_map.insert("public-static-attrib",new int(ISection::PubStatAttribs)); + m_map.insert("protected-type",new int(ISection::ProTypes)); + m_map.insert("protected-func",new int(ISection::ProFuncs)); + m_map.insert("protected-attrib",new int(ISection::ProAttribs)); + m_map.insert("protected-slot",new int(ISection::ProSlots)); + m_map.insert("protected-static-func",new int(ISection::ProStatFuncs)); + m_map.insert("protected-static-attrib",new int(ISection::ProStatAttribs)); + m_map.insert("package-type",new int(ISection::PacTypes)); + m_map.insert("package-func",new int(ISection::PacFuncs)); + m_map.insert("package-attrib",new int(ISection::PacAttribs)); + m_map.insert("package-static-func",new int(ISection::PacStatFuncs)); + m_map.insert("package-static-attrib",new int(ISection::PacStatAttribs)); + m_map.insert("private-type",new int(ISection::PriTypes)); + m_map.insert("private-func",new int(ISection::PriFuncs)); + m_map.insert("private-attrib",new int(ISection::PriAttribs)); + m_map.insert("private-slot",new int(ISection::PriSlots)); + m_map.insert("private-static-func",new int(ISection::PriStatFuncs)); + m_map.insert("private-static-attrib",new int(ISection::PriStatAttribs)); + m_map.insert("friend",new int(ISection::Friend)); + m_map.insert("related",new int(ISection::Related)); + m_map.insert("define",new int(ISection::Defines)); + m_map.insert("prototype",new int(ISection::Prototypes)); + m_map.insert("typedef",new int(ISection::Typedefs)); + m_map.insert("enum",new int(ISection::Enums)); + m_map.insert("func",new int(ISection::Functions)); + m_map.insert("var",new int(ISection::Variables)); + } + ISection::SectionKind map(const QString &s) + { + int *val = m_map.find(s); + if (val==0) + { + debug(1,"Warning: `%s' is an invalid section type\n",s.data()); + return ISection::Invalid; + } + else return (ISection::SectionKind)*val; + } + private: + QDict<int> m_map; +}; + +static SectionTypeMap *s_typeMap; + +void sectionhandler_init() +{ + s_typeMap = new SectionTypeMap; +} + +void sectionhandler_exit() +{ + delete s_typeMap; +} + +SectionHandler::SectionHandler(IBaseHandler *parent) : m_parent(parent) +{ + //printf("SectionHandler::SectionHandler()\n"); + m_members.setAutoDelete(TRUE); + addEndHandler("sectiondef",this,&SectionHandler::endSection); + addStartHandler("memberdef",this,&SectionHandler::startMember); + addStartHandler("header",this,&SectionHandler::startHeader); + addEndHandler("header",this,&SectionHandler::endHeader); + addStartHandler("description",this,&SectionHandler::startDescription); +} + +SectionHandler::~SectionHandler() +{ + debug(2,"SectionHandler::~SectionHandler()\n"); +} + +void SectionHandler::startSection(const QXmlAttributes& attrib) +{ + m_parent->setDelegate(this); + m_kindString = attrib.value("kind"); + m_kind = s_typeMap->map(m_kindString); + debug(2,"section kind=`%s'\n",m_kindString.data()); +} + +void SectionHandler::startDescription(const QXmlAttributes& attrib) +{ + DocHandler *docHandler = new DocHandler(this); + docHandler->startDoc(attrib); + m_description = docHandler; +} + +void SectionHandler::endSection() +{ + m_parent->setDelegate(0); +} + +void SectionHandler::startMember(const QXmlAttributes& attrib) +{ + MemberHandler *memHandler = new MemberHandler(this); + memHandler->startMember(attrib); + m_members.append(memHandler); +} + +void SectionHandler::startHeader(const QXmlAttributes&) +{ + m_header=""; + m_curString=""; +} + +void SectionHandler::endHeader() +{ + m_header = m_curString.stripWhiteSpace(); + debug(2,"member header=`%s'\n",m_header.data()); +} + +void SectionHandler::initialize(CompoundHandler *ch) +{ + QListIterator<MemberHandler> mli(m_members); + MemberHandler *mh; + for (;(mh=mli.current());++mli) + { + mh->setCompoundHandler(ch); + ch->insertMember(mh); + mh->setSectionHandler(this); + } +} + +IDocRoot *SectionHandler::description() const +{ + return m_description; +} + +IMemberIterator *SectionHandler::members() const +{ + return new MemberIterator(m_members); +} + diff --git a/trunk/addon/doxmlparser/src/sectionhandler.h b/trunk/addon/doxmlparser/src/sectionhandler.h new file mode 100644 index 0000000..c462b91 --- /dev/null +++ b/trunk/addon/doxmlparser/src/sectionhandler.h @@ -0,0 +1,102 @@ +/****************************************************************************** + * + * $Id:$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _SECTIONHANDLER_H +#define _SECTIONHANDLER_H + +#include <qstring.h> +#include <qlist.h> +#include <qxml.h> +#include <doxmlintf.h> + +#include "basehandler.h" + +class SectionIterator : + public BaseIterator<ISectionIterator,ISection,SectionHandler> +{ + public: + SectionIterator(const QList<SectionHandler> &list) : + BaseIterator<ISectionIterator,ISection,SectionHandler>(list) {} +}; + + +class SectionHandler : public IUserDefined, public BaseHandler<SectionHandler> +{ + public: + virtual void startMember(const QXmlAttributes& attrib); + virtual void startHeader(const QXmlAttributes& attrib); + virtual void startSection(const QXmlAttributes& attrib); + virtual void startDescription(const QXmlAttributes& attrib); + virtual void endSection(); + virtual void endHeader(); + + SectionHandler(IBaseHandler *parent); + virtual ~SectionHandler(); + + // ISection + virtual const IString *kindString() const + { return &m_kindString; } + virtual SectionKind kind() const + { return m_kind; } + IDocRoot *description() const; + virtual IMemberIterator *members() const; + virtual bool isStatic() const + { + return m_kind==PubStatFuncs || m_kind==PubStatAttribs || + m_kind==ProStatFuncs || m_kind==ProStatAttribs || + m_kind==PriStatFuncs || m_kind==PriStatAttribs; + } + virtual bool isPublic() const + { + return !isProtected() && !isPrivate(); + } + virtual bool isProtected() const + { + return m_kind==ProTypes || m_kind==ProFuncs || m_kind==ProAttribs || + m_kind==ProSlots || m_kind==ProStatFuncs || m_kind==ProStatAttribs; + } + virtual bool isPrivate() const + { + return m_kind==PriTypes || m_kind==PriFuncs || m_kind==PriAttribs || + m_kind==PriSlots || m_kind==PriStatFuncs || m_kind==PriStatAttribs; + } + + void initialize(CompoundHandler *c); + + // IUserDefined implementation + virtual const IString *header() const + { + return &m_header; + } + + private: + IBaseHandler *m_parent; + + // XML elements: + // ------------- + StringImpl m_header; // header + DocHandler* m_description; // description + QList<MemberHandler> m_members; // memberdef + + // XML attributes: + // --------------- + SectionKind m_kind; // kind + StringImpl m_kindString; // kind as a string +}; + +void sectionhandler_init(); +void sectionhandler_exit(); + +#endif diff --git a/trunk/addon/doxmlparser/src/stringimpl.h b/trunk/addon/doxmlparser/src/stringimpl.h new file mode 100644 index 0000000..013858f --- /dev/null +++ b/trunk/addon/doxmlparser/src/stringimpl.h @@ -0,0 +1,30 @@ +#ifndef STRINGIMPL_H +#define STRINGIMPL_H + +#include <qstring.h> +#include "doxmlintf.h" + +class StringImpl : public QString, public IString +{ + public: + StringImpl() {} + StringImpl(const QString &str) : QString(str) {} + StringImpl &operator=(const QString &str) + { QString::operator=(str); return *this; } + virtual ~StringImpl() {} + + // IString + const char *latin1() const + { return QString::latin1(); } + const char *utf8() const + { return QString::utf8(); } + unsigned short unicodeCharAt(int index) const + { return QString::unicode()[index].unicode(); } + bool isEmpty() const + { return QString::isEmpty(); } + int length() const + { return QString::length(); } +}; + +#endif + diff --git a/trunk/addon/doxmlparser/test/Makefile.in b/trunk/addon/doxmlparser/test/Makefile.in new file mode 100644 index 0000000..1dfbd17 --- /dev/null +++ b/trunk/addon/doxmlparser/test/Makefile.in @@ -0,0 +1,13 @@ +all clean depend: Makefile.xmlparse + $(MAKE) -f Makefile.xmlparse $@ + +distclean: clean + $(RM) -rf Makefile.xmlparse xmlparse.pro Makefile obj + +tmake: + $(ENV) $(PERL) $(TMAKE) xmlparse.pro >Makefile.xmlparse + +Makefile.xmlparse: xmlparse.pro + $(ENV) $(PERL) $(TMAKE) xmlparse.pro >Makefile.xmlparse + +install: diff --git a/trunk/addon/doxmlparser/test/main.cpp b/trunk/addon/doxmlparser/test/main.cpp new file mode 100644 index 0000000..5f37c81 --- /dev/null +++ b/trunk/addon/doxmlparser/test/main.cpp @@ -0,0 +1,759 @@ +/****************************************************************************** + * + * $Id$ + * + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <doxmlintf.h> +#include <qstring.h> + +/*! Dumps the contents of a hyperlinked text fragment as plain text to the + * output. + */ +QString linkedTextToString(ILinkedTextIterator *ti) +{ + QString result; + ILinkedText *lt=0; + for (ti->toFirst();(lt=ti->current());ti->toNext()) + { + switch (lt->kind()) + { + case ILinkedText::Kind_Text: // plain text + result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1(); break; + case ILinkedText::Kind_Ref: // a link + result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1(); break; + } + } + return result; +} + +/*! Macro for printing an indented message. */ +#define InPrint(x) printf("%s",indent.latin1()), printf x; + +/*! Dumps the contents of a documentation block to stdout. + * @note This function will call itself recursively. + * @param doc The root of the documentation tree. + * @param level The indent level. + */ +void DumpDoc(IDoc *doc,int level) +{ + if (doc==0) return; + QString indent; + indent.fill(' ',level); + //printf(" doc node kind=`%d'\n",doc->kind()); + switch (doc->kind()) + { + case IDoc::Para: + { + InPrint(("<para>\n")); + IDocPara *par = dynamic_cast<IDocPara*>(doc); + ASSERT(par!=0); + IDocIterator *di = par->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</para>\n")); + } + break; + case IDoc::Text: + { + IDocText *txt = dynamic_cast<IDocText*>(doc); + ASSERT(txt!=0); + InPrint(("<text value=`%s' markup=%d headingLevel=%d/>\n", + txt->text()->latin1(),txt->markup(),txt->headingLevel())); + } + break; + case IDoc::MarkupModifier: + { + IDocMarkupModifier *md = dynamic_cast<IDocMarkupModifier*>(doc); + ASSERT(md!=0); + InPrint(("<markup modifier enabled=%d markup=%d headingLevel=%d/>\n", + md->enabled(),md->markup(),md->headingLevel())); + } + break; + case IDoc::ItemizedList: + { + InPrint(("<itemized list>\n")); + IDocItemizedList *list = dynamic_cast<IDocItemizedList*>(doc); + ASSERT(list!=0); + IDocIterator *di = list->elements(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</itemized list>\n")); + } + break; + case IDoc::OrderedList: + { + InPrint(("<ordered list>\n")); + IDocOrderedList *list = dynamic_cast<IDocOrderedList*>(doc); + ASSERT(list!=0); + IDocIterator *di = list->elements(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</ordered list>\n")); + } + break; + case IDoc::ListItem: + { + InPrint(("<list item>\n")); + IDocListItem *li = dynamic_cast<IDocListItem*>(doc); + ASSERT(li!=0); + IDocIterator *di = li->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</list item>\n")); + } + break; + case IDoc::ParameterItem: + { + IDocParameterItem *item = dynamic_cast<IDocParameterItem*>(doc); + InPrint(("<parameter item>\n")); + IDocIterator *di = item->paramNames(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + DumpDoc(item->description(),level+1); + InPrint(("</parameter item>\n")); + } + break; + case IDoc::ParameterList: + { + IDocParameterList *list = dynamic_cast<IDocParameterList*>(doc); + InPrint(("<parameter list type=%d>\n",list->sectType())); + IDocIterator *di = list->params(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</parameter list>\n")); + ASSERT(list!=0); + } + break; + case IDoc::Parameter: + { + IDocParameter *par = dynamic_cast<IDocParameter*>(doc); + ASSERT(par!=0); + InPrint(("<parameter name=%s/>\n",par->name()->latin1())); + } + break; + case IDoc::SimpleSect: + { + IDocSimpleSect *ss = dynamic_cast<IDocSimpleSect*>(doc); + ASSERT(ss!=0); + InPrint(("<simplesect type=%s>\n",ss->typeString()->latin1())); + DumpDoc(ss->title(),level+1); + DumpDoc(ss->description(),level+1); + InPrint(("<simplesect/>\n")); + } + break; + case IDoc::Title: + { + InPrint(("<title>\n")); + IDocTitle *t = dynamic_cast<IDocTitle*>(doc); + ASSERT(t!=0); + IDocIterator *di = t->title(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + InPrint(("<title/>\n")); + } + break; + case IDoc::Ref: + { + IDocRef *ref = dynamic_cast<IDocRef*>(doc); + ASSERT(ref!=0); + InPrint(("<ref id=%s text=%s/>\n", + ref->refId()->latin1(),ref->text()->latin1())); + } + break; + case IDoc::VariableList: + { + InPrint(("<variablelist>\n")); + IDocVariableList *vl = dynamic_cast<IDocVariableList*>(doc); + ASSERT(vl!=0); + IDocIterator *di = vl->entries(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("<variablelist/>\n")); + } + break; + case IDoc::VariableListEntry: + { + IDocVariableListEntry *vle = dynamic_cast<IDocVariableListEntry*>(doc); + ASSERT(vle!=0); + ILinkedTextIterator *lti = vle->term(); + QString term = linkedTextToString(lti); + lti->release(); + InPrint(("<variablelistentry term=%s>\n",term.latin1())); + DumpDoc(vle->description(),level+1); + InPrint(("<variablelistentry/>\n")); + } + break; + case IDoc::HRuler: + { + IDocHRuler *hr = dynamic_cast<IDocHRuler*>(doc); + ASSERT(hr!=0); + InPrint(("<hruler/>\n")); + } + break; + case IDoc::LineBreak: + { + IDocLineBreak *lb = dynamic_cast<IDocLineBreak*>(doc); + ASSERT(lb!=0); + InPrint(("<linebreak/>\n")); + } + break; + case IDoc::ULink: + { + IDocULink *ul = dynamic_cast<IDocULink*>(doc); + ASSERT(ul!=0); + InPrint(("<ulink url=`%s' text=`%s'/>\n",ul->url()->latin1(),ul->text()->latin1())); + } + break; + case IDoc::EMail: + { + IDocEMail *em = dynamic_cast<IDocEMail*>(doc); + ASSERT(em!=0); + InPrint(("<email address=`%s'/>\n",em->address()->latin1())); + } + break; + case IDoc::Link: + { + IDocLink *lk = dynamic_cast<IDocLink*>(doc); + ASSERT(lk!=0); + InPrint(("<link refid=`%s' text=`%s'/>\n",lk->refId()->latin1(),lk->text()->latin1())); + } + break; + case IDoc::ProgramListing: + { + IDocProgramListing *pl = dynamic_cast<IDocProgramListing*>(doc); + ASSERT(pl!=0); + InPrint(("<programlisting>\n")); + IDocIterator *cli = pl->codeLines(); + IDoc *cl; + for (cli->toFirst();(cl=cli->current());cli->toNext()) + { + DumpDoc(cl,level+1); + } + cli->release(); + InPrint(("</programlisting>\n")); + } + break; + case IDoc::CodeLine: + { + IDocCodeLine *cl = dynamic_cast<IDocCodeLine*>(doc); + ASSERT(cl!=0); + InPrint(("<codeline lineNumber=%d refId=`%s'>\n",cl->lineNumber(),cl->refId()->latin1())); + IDocIterator *cei = cl->codeElements(); + IDoc *ce; + for (cei->toFirst();(ce=cei->current());cei->toNext()) + { + DumpDoc(ce,level+1); + } + cei->release(); + InPrint(("</codeline>\n")); + } + break; + case IDoc::Highlight: + { + IDocHighlight *hl = dynamic_cast<IDocHighlight*>(doc); + ASSERT(hl!=0); + InPrint(("<highlight kind=%d>\n",hl->kind())); + IDocIterator *cei = hl->codeElements(); + IDoc *ce; + for (cei->toFirst();(ce=cei->current());cei->toNext()) + { + DumpDoc(ce,level+1); + } + cei->release(); + InPrint(("</highlight>\n")); + } + break; + case IDoc::Formula: + { + IDocFormula *fm = dynamic_cast<IDocFormula*>(doc); + ASSERT(fm!=0); + InPrint(("<formula id=`%s' text=`%s'/>\n",fm->id()->latin1(),fm->text()->latin1())); + } + break; + case IDoc::Image: + { + IDocImage *img = dynamic_cast<IDocImage*>(doc); + ASSERT(img!=0); + InPrint(("<image name=`%s' caption=`%s'/>\n",img->name()->latin1(),img->caption()->latin1())); + } + break; + case IDoc::DotFile: + { + IDocDotFile *df = dynamic_cast<IDocDotFile*>(doc); + ASSERT(df!=0); + InPrint(("<dotfile name=`%s' caption=`%s'/>\n",df->name()->latin1(),df->caption()->latin1())); + } + break; + case IDoc::IndexEntry: + { + IDocIndexEntry *ie = dynamic_cast<IDocIndexEntry*>(doc); + ASSERT(ie!=0); + InPrint(("<indexentry primary=`%s' secondary=`%s'/>\n",ie->primary()->latin1(),ie->secondary()->latin1())); + } + break; + case IDoc::Table: + { + IDocTable *tbl = dynamic_cast<IDocTable*>(doc); + ASSERT(tbl!=0); + InPrint(("<table numcols=%d caption=`%s'>\n",tbl->numColumns(),tbl->caption()->latin1())); + IDocIterator *ri = tbl->rows(); + IDoc *row; + for (ri->toFirst();(row=ri->current());ri->toNext()) + { + DumpDoc(row,level+1); + } + ri->release(); + InPrint(("</table>\n")); + } + break; + case IDoc::Row: + { + IDocRow *row = dynamic_cast<IDocRow*>(doc); + ASSERT(row!=0); + InPrint(("<row>\n")); + IDocIterator *ei = row->entries(); + IDoc *e; + for (ei->toFirst();(e=ei->current());ei->toNext()) + { + DumpDoc(e,level+1); + } + ei->release(); + InPrint(("</row>\n")); + } + break; + case IDoc::Entry: + { + IDocEntry *ent = dynamic_cast<IDocEntry*>(doc); + ASSERT(ent!=0); + InPrint(("<entry>\n")); + IDocIterator *di = ent->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</entry>\n")); + } + break; + case IDoc::Section: + { + IDocSection *sec = dynamic_cast<IDocSection*>(doc); + ASSERT(sec!=0); + InPrint(("<section id=`%s' level=%d>\n", + sec->id()->latin1(),sec->level())); + DumpDoc(sec->title(),level+1); + IDocIterator *di = sec->paragraphs(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di=sec->subSections(); + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + IDocInternal *intern = sec->internal(); + if (intern) + { + DumpDoc(intern,level+1); + } + InPrint(("</section>\n")); + } + break; + case IDoc::Internal: + { + IDocInternal *intern = dynamic_cast<IDocInternal*>(doc); + ASSERT(intern!=0); + InPrint(("<internal>\n")); + IDocIterator *di = intern->paragraphs(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di=intern->subSections(); + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + InPrint(("</internal>\n")); + } + break; + case IDoc::Copy: + { + IDocCopy *cpy = dynamic_cast<IDocCopy*>(doc); + ASSERT(cpy!=0); + InPrint(("<copydoc>\n")); + IDocIterator *di = cpy->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("<copydoc/>\n")); + } + break; + case IDoc::TocItem: + { + IDocTocItem *ti = dynamic_cast<IDocTocItem*>(doc); + ASSERT(ti!=0); + InPrint(("<tocitem id=\"%s\" title=\"%s\"/>\n", + ti->id()->latin1(),ti->title()->latin1())); + } + break; + case IDoc::TocList: + { + IDocTocList *tl = dynamic_cast<IDocTocList*>(doc); + ASSERT(tl!=0); + InPrint(("<toclist>\n")); + IDocIterator *di = tl->elements(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("<toclist/>\n")); + } + break; + case IDoc::Verbatim: + { + IDocVerbatim *vt = dynamic_cast<IDocVerbatim*>(doc); + ASSERT(vt!=0); + const char *s=0; + switch (vt->type()) + { + case IDocVerbatim::Verbatim: s="verbatim"; break; + case IDocVerbatim::HtmlOnly: s="htmlonly"; break; + case IDocVerbatim::LatexOnly: s="latexonly"; break; + default: + printf("Invalid verbatim type!\n"); + } + InPrint(("<verbatim %s>\n",s)); + InPrint(("%s",vt->text()->latin1())); + InPrint(("</verbatim>\n")); + } + break; + case IDoc::Anchor: + { + IDocAnchor *anc = dynamic_cast<IDocAnchor*>(doc); + ASSERT(anc!=0); + InPrint(("<anchor id='%s'/>\n",anc->id()->latin1())); + } + break; + case IDoc::Symbol: + { + IDocSymbol *sym = dynamic_cast<IDocSymbol*>(doc); + ASSERT(sym!=0); + InPrint(("<symbol type=%s letter=%c/>\n", + sym->typeString()->latin1(),sym->letter())); + } + break; + case IDoc::Root: + { + InPrint(("<root>\n")); + IDocRoot *root = dynamic_cast<IDocRoot*>(doc); + ASSERT(root!=0); + IDocIterator *di = root->contents(); + IDoc *pdoc; + for (di->toFirst();(pdoc=di->current());di->toNext()) + { + DumpDoc(pdoc,level+1); + } + di->release(); + InPrint(("</root>\n")); + } + break; + + default: + printf("Found unsupported node type %d!\n",doc->kind()); + break; + } +} + +void DumpGraph(IGraph *graph) +{ + if (graph==0) { printf(" --- no graph ---\n"); return; } + printf(" --- graph ----\n"); + INodeIterator *ni = graph->nodes(); + INode *node; + for (ni->toFirst();(node=ni->current());ni->toNext()) + { + printf(" --- node id=%s label=%s linkId=%s\n", + node->id()->latin1(), + node->label()->latin1(), + node->linkId()->latin1() + ); + IChildNodeIterator *cni = node->children(); + IChildNode *cn; + for (cni->toFirst();(cn=cni->current());cni->toNext()) + { + printf(" + child id=%s label=%s relation=%s\n", + cn->node()->id()->latin1(), + cn->node()->label()->latin1(), + cn->relationString()->latin1() + ); + IEdgeLabelIterator *eli = cn->edgeLabels(); + IEdgeLabel *el; + for (eli->toFirst();(el=eli->current());eli->toNext()) + { + printf(" edgeLabel=%s\n",el->label()->latin1()); + } + eli->release(); + } + cni->release(); + } + ni->release(); + printf(" --- end graph ----\n"); + +} + +void DumpParamList(IParamIterator *pli,int indent) +{ + QString indentStr; + indentStr.fill(' ',indent); + IParam *par; + for (pli->toFirst();(par=pli->current());pli->toNext()) + { + ILinkedTextIterator *lti = par->type(); + QString parType = linkedTextToString(lti); + lti->release(); + lti = par->defaultValue(); + QString defVal = linkedTextToString(lti); + lti->release(); + printf("%sParam type=%s decl_name=%s def_name=%s defvalue=%s\n", + indentStr.data(), parType.latin1(), + par->declarationName()->latin1(), + par->definitionName()->latin1(), + defVal.latin1()); + } +} + +int main(int argc,char **argv) +{ + if (argc!=2) + { + printf("Usage: %s xmldir\n",argv[0]); + exit(1); + } + + IDoxygen *dox = createObjectModel(); + + dox->setDebugLevel(4); + + if (!dox->readXMLDir(argv[1])) + { + printf("Error reading %s/index.xml\n",argv[1]); + exit(1); + } + + ICompoundIterator *cli = dox->compounds(); + ICompound *comp; + printf("--- compound list ---------\n"); + for (cli->toFirst();(comp=cli->current());cli->toNext()) + { + printf("Compound name=%s id=%s kind=%s\n", + comp->name()->latin1(),comp->id()->latin1(),comp->kindString()->latin1()); + + ISectionIterator *sli = comp->sections(); + ISection *sec; + for (sli->toFirst();(sec=sli->current());sli->toNext()) + { + printf(" Section kind=%s\n",sec->kindString()->latin1()); + IMemberIterator *mli = sec->members(); + IMember *mem; + if( sec->kind() == ISection::UserDefined ) + { + IUserDefined *group = dynamic_cast<IUserDefined*>(sec); + printf(" Title=%s\n", group->header()->latin1() ); + } + for (mli->toFirst();(mem=mli->current());mli->toNext()) + { + ILinkedTextIterator *lti = mem->type(); + printf(" Member type=%s name=%s\n", + linkedTextToString(lti).latin1(),mem->name()->latin1()); + lti->release(); + + IParamIterator *pli = mem->parameters(); + DumpParamList(pli,6); + pli->release(); + IMemberReferenceIterator *mri = mem->references(); + IMemberReference *mr; + for (mri->toFirst();(mr=mri->current());mri->toNext()) + { + IMember *memr = mr->member(); + printf(" References %s at line %d\n", + mr->name()->latin1(),memr->bodyStart()); + } + + mri->release(); + mri = mem->referencedBy(); + for (mri->toFirst();(mr=mri->current());mri->toNext()) + { + IMember *memr = mr->member(); + printf(" ReferencedBy %s at line %d\n", + mr->name()->latin1(),memr->bodyStart()); + } + mri->release(); + + if (mem->kind()==IMember::Enum) // we have found an enum + { + IEnum *e = dynamic_cast<IEnum*>(mem); + IMemberIterator *evi = e->enumValues(); // get the enum values + IMember *mev; + for (evi->toFirst();(mev=evi->current());evi->toNext()) + { + IEnumValue *ev = dynamic_cast<IEnumValue*>(mev); + ILinkedTextIterator *lti = ev->initializer(); + QString init = linkedTextToString(lti); + lti->release(); + printf(" Enum value `%s' init=`%s'\n", + ev->name()->latin1(),init.latin1()); + } + evi->release(); + } + + pli = mem->templateParameters(); + if (pli) + { + printf(" Template parameters\n"); + DumpParamList(pli,8); + pli->release(); + } + + IDoc *doc = mem->briefDescription(); + if (doc) + { + printf("===== brief description ==== \n"); + DumpDoc(doc,0); + } + + doc = mem->detailedDescription(); + if (doc) + { + printf("===== detailed description ==== \n"); + DumpDoc(doc,0); + } + } + mli->release(); + } + sli->release(); + + IDoc *doc = comp->briefDescription(); + if (doc) + { + printf("===== brief description ==== \n"); + DumpDoc(doc,0); + } + + doc = comp->detailedDescription(); + if (doc) + { + printf("===== detailed description ==== \n"); + DumpDoc(doc,0); + } + + if (comp->kind()==ICompound::Class) + { + IClass *cls = dynamic_cast<IClass*>(comp); + ASSERT(cls!=0); + + printf("==== inheritance graph ==== \n"); + DumpGraph(cls->inheritanceGraph()); + + printf("==== collabration graph ==== \n"); + DumpGraph(cls->collaborationGraph()); + + printf("==== base classes ==== \n"); + IRelatedCompoundIterator *bcli = cls->baseCompounds(); + IRelatedCompound *bClass; + for (bcli->toFirst();(bClass=bcli->current());bcli->toNext()) + { + ICompound *bc = bClass->compound(); + printf(" + class %s\n",bc->name()->latin1()); + bc->release(); + } + bcli->release(); + + printf("==== derived classes ==== \n"); + IRelatedCompoundIterator *dcli = cls->derivedCompounds(); + IRelatedCompound *dClass; + for (dcli->toFirst();(dClass=dcli->current());dcli->toNext()) + { + ICompound *dc = dClass->compound(); + printf(" + class %s\n",dc->name()->latin1()); + dc->release(); + } + dcli->release(); + } + else if (comp->kind()==ICompound::File) + { + IFile *file = dynamic_cast<IFile*>(comp); + ASSERT(file!=0); + + printf("==== include dependency graph ==== \n"); + DumpGraph(file->includeDependencyGraph()); + + printf("==== included by dependency graph ==== \n"); + DumpGraph(file->includedByDependencyGraph()); + + printf("==== source ====\n"); + DumpDoc(file->source(),0); + } + + comp->release(); + } + cli->release(); + printf("---------------------------\n"); + + dox->release(); + + return 0; +} + diff --git a/trunk/addon/doxmlparser/test/xmlparse.pro.in b/trunk/addon/doxmlparser/test/xmlparse.pro.in new file mode 100644 index 0000000..cfb95be --- /dev/null +++ b/trunk/addon/doxmlparser/test/xmlparse.pro.in @@ -0,0 +1,20 @@ +TEMPLATE = app.t +CONFIG = console warn_on $extraopts +HEADERS = +SOURCES = main.cpp +unix:LIBS += -L../../../lib -L../lib -ldoxmlparser -lqtools +win32:INCLUDEPATH += . +win32-mingw:LIBS += -L../../../lib -L../lib -ldoxmlparser -lqtools +win32-msvc:LIBS += doxmlparser.lib qtools.lib shell32.lib +win32-msvc:TMAKE_LFLAGS += /LIBPATH:..\..\..\lib;..\lib +win32-borland:LIBS += doxmlparser.lib qtools.lib shell32.lib +win32-borland:TMAKE_LFLAGS += -L..\..\..\lib -L..\lib +win32:TMAKE_CXXFLAGS += -DQT_NODLL +DESTDIR = +OBJECTS_DIR = ../objects +TARGET = xmlparse +INCLUDEPATH += ../../../qtools ../include +DEPENDPATH += ../include +unix:TARGETDEPS = ../lib/libdoxmlparser.a +win32:TARGETDEPS = ..\lib\doxmlparser.lib + diff --git a/trunk/addon/doxyapp/Makefile.in b/trunk/addon/doxyapp/Makefile.in new file mode 100644 index 0000000..c5acd67 --- /dev/null +++ b/trunk/addon/doxyapp/Makefile.in @@ -0,0 +1,17 @@ + +all clean depend distclean: Makefile.doxyapp + $(MAKE) -f Makefile.doxyapp $@ + +distclean: clean + $(RM) -rf Makefile doxyapp.pro Makefile.doxyapp + +tmake: + $(ENV) $(PERL) $(TMAKE) doxyapp.pro >Makefile.doxyapp + +strip: + strip doxyapp + +Makefile.doxyapp: doxyapp.pro + $(ENV) $(PERL) $(TMAKE) doxyapp.pro >Makefile.doxyapp + +install: diff --git a/trunk/addon/doxyapp/README b/trunk/addon/doxyapp/README new file mode 100644 index 0000000..f92e106 --- /dev/null +++ b/trunk/addon/doxyapp/README @@ -0,0 +1,8 @@ +This directory contains an example of how to use doxygen as +an "source parsing engine" in an application. It shows how to configure doxygen +from the application and shows how to run doxygen without generating output, +and then uses the information about the symbols found in the source code. + +Note that if you use this approach your application should be licensed under the GPL. + + diff --git a/trunk/addon/doxyapp/doxyapp.cpp b/trunk/addon/doxyapp/doxyapp.cpp new file mode 100644 index 0000000..c6b7ed4 --- /dev/null +++ b/trunk/addon/doxyapp/doxyapp.cpp @@ -0,0 +1,314 @@ +/****************************************************************************** + * + * Copyright (C) 1997-2006 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +/** @file + * @brief Example of how to use doxygen as part of another GPL applications + * + * This example shows how to configure and run doxygen programmatically from + * within an application without generating the usual output. + * The example should work on any Unix like OS (including Linux and Mac OS X). + * + * This example shows how to use to code parser to get cross-references information + * and it also shows how to look up symbols in a program parsed by doxygen and + * show some information about them. + */ + +#include <stdlib.h> +#include <unistd.h> +#include "doxygen.h" +#include "outputgen.h" +#include "parserintf.h" + +class XRefDummyCodeGenerator : public CodeOutputInterface +{ + public: + XRefDummyCodeGenerator(FileDef *fd) : m_fd(fd) {} + ~XRefDummyCodeGenerator() {} + + // these are just null functions, they can be used to produce a syntax highlighted + // and cross-linked version of the source code, but who needs that anyway ;-) + void codify(const char *) {} + void writeCodeLink(const char *,const char *,const char *,const char *,const char *) {} + void startCodeLine() {} + void endCodeLine() {} + void startCodeAnchor(const char *) {} + void endCodeAnchor() {} + void startFontClass(const char *) {} + void endFontClass() {} + void writeCodeAnchor(const char *) {} + void writeLineNumber(const char *,const char *,const char *,int) {} + + // here we are presented with the symbols found by the code parser + void linkableSymbol(int l, const char *sym,Definition *symDef,Definition *context) + { + QCString ctx; + if (context) // the context of the symbol is known + { + if (context->definitionType()==Definition::TypeMember) // it is inside a member + { + Definition *parentContext = context->getOuterScope(); + if (parentContext && parentContext->definitionType()==Definition::TypeClass) + // it is inside a member of a class + { + ctx.sprintf("inside %s %s of %s %s", + ((MemberDef *)context)->memberTypeName().data(), + context->name().data(), + ((ClassDef*)parentContext)->compoundTypeString().data(), + parentContext->name().data()); + } + else if (parentContext==Doxygen::globalScope) // it is inside a global member + { + ctx.sprintf("inside %s %s", + ((MemberDef *)context)->memberTypeName().data(), + context->name().data()); + } + } + if (ctx.isEmpty()) // it is something else (class, or namespace member, ...) + { + ctx.sprintf("in %s",context->name().data()); + } + } + printf("Found symbol %s at line %d of %s %s\n", + sym,l,m_fd->getDefFileName().data(),ctx.data()); + if (symDef && context) // in this case the definition of the symbol is + // known to doxygen. + { + printf("-> defined at line %d of %s\n", + symDef->getDefLine(),symDef->getDefFileName().data()); + } + } + private: + FileDef *m_fd; +}; + +static void findXRefSymbols(FileDef *fd) +{ + // get the interface to a parser that matches the file extension + ParserInterface *pIntf=Doxygen::parserManager->getParser(fd->getDefFileExtension()); + + // reset the parsers state + pIntf->resetCodeParserState(); + + // create a new backend object + XRefDummyCodeGenerator *xrefGen = new XRefDummyCodeGenerator(fd); + + // parse the source code + pIntf->parseCode(*xrefGen, + 0, + fileToString(fd->absFilePath()), + FALSE, + 0, + fd); + + // dismiss the object. + delete xrefGen; +} + +static void listSymbol(Definition *d) +{ + if (d!=Doxygen::globalScope && // skip the global namespace symbol + d->name().at(0)!='@' // skip anonymous stuff + ) + { + printf("%s\n", + d->name().data()); + } +} + +static void listSymbols() +{ + QDictIterator<DefinitionIntf> sli(*Doxygen::symbolMap); + DefinitionIntf *di; + for (sli.toFirst();(di=sli.current());++sli) + { + if (di->definitionType()==DefinitionIntf::TypeSymbolList) // list of symbols + // with same name + { + DefinitionListIterator dli(*(DefinitionList*)di); + Definition *d; + // for each symbol + for (dli.toFirst();(d=dli.current());++dli) + { + listSymbol(d); + } + } + else // single symbol + { + listSymbol((Definition*)di); + } + } +} + +static void lookupSymbol(Definition *d) +{ + if (d!=Doxygen::globalScope && // skip the global namespace symbol + d->name().at(0)!='@' // skip anonymous stuff + ) + { + printf("Symbol info\n"); + printf("-----------\n"); + printf("Name: %s\n",d->name().data()); + printf("File: %s\n",d->getDefFileName().data()); + printf("Line: %d\n",d->getDefLine()); + // depending on the definition type we can case to the appropriate + // derived to get additional information + switch (d->definitionType()) + { + case Definition::TypeClass: + { + ClassDef *cd = (ClassDef *)d; + printf("Kind: %s\n",cd->compoundTypeString().data()); + } + break; + case Definition::TypeFile: + { + FileDef *fd = (FileDef *)d; + printf("Kind: File: #includes %d other files\n", + fd->includeFileList() ? fd->includeFileList()->count() : 0); + } + break; + case Definition::TypeNamespace: + { + NamespaceDef *nd = (NamespaceDef *)d; + printf("Kind: Namespace: contains %d classes and %d namespaces\n", + nd->getClassSDict() ? nd->getClassSDict()->count() : 0, + nd->getNamespaceSDict() ? nd->getNamespaceSDict()->count() : 0); + } + break; + case Definition::TypeMember: + { + MemberDef *md = (MemberDef *)d; + printf("Kind: %s\n",md->memberTypeName().data()); + } + break; + default: + // ignore groups/pages/packages/dirs for now + break; + } + } +} + +static void lookupSymbols(const QCString &sym) +{ + if (!sym.isEmpty()) + { + DefinitionIntf *di = Doxygen::symbolMap->find(sym); + if (di) + { + if (di->definitionType()==DefinitionIntf::TypeSymbolList) + { + DefinitionListIterator dli(*(DefinitionList*)di); + Definition *d; + // for each symbol with the given name + for (dli.toFirst();(d=dli.current());++dli) + { + lookupSymbol(d); + } + } + else + { + lookupSymbol((Definition*)di); + } + } + else + { + printf("Unknown symbol\n"); + } + } +} + +int main(int argc,char **argv) +{ + char cmd[256]; + + if (argc<2) + { + printf("Usage: %s [source_file | source_dir]\n",argv[0]); + exit(1); + } + + // initialize data structures + initDoxygen(); + + // setup the non-default configuration options + + // we need a place to put intermediate files + Config_getString("OUTPUT_DIRECTORY")="/tmp/doxygen"; + // disable html output + Config_getBool("GENERATE_HTML")=FALSE; + // disable latex output + Config_getBool("GENERATE_LATEX")=FALSE; + // be quiet + Config_getBool("QUIET")=TRUE; + // turn off warnings + Config_getBool("WARNINGS")=FALSE; + Config_getBool("WARN_IF_UNDOCUMENTED")=FALSE; + Config_getBool("WARN_IF_DOC_ERROR")=FALSE; + // Extract as much as possible + Config_getBool("EXTRACT_ALL")=TRUE; + Config_getBool("EXTRACT_STATIC")=TRUE; + Config_getBool("EXTRACT_PRIVATE")=TRUE; + Config_getBool("EXTRACT_LOCAL_METHODS")=TRUE; + // Extract source browse information, needed + // to make doxygen gather the cross reference info + Config_getBool("SOURCE_BROWSER")=TRUE; + + // set the input + Config_getList("INPUT").append(argv[1]); + + // check and finialize the configuration + checkConfiguration(); + adjustConfiguration(); + + // parse the files + parseInput(); + + // iterate over the input files + FileNameListIterator fnli(*Doxygen::inputNameList); + FileName *fn; + // foreach file with a certain name + for (fnli.toFirst();(fn=fnli.current());++fnli) + { + FileNameIterator fni(*fn); + FileDef *fd; + // for each file definition + for (;(fd=fni.current());++fni) + { + // get the references (linked and unlinked) found in this file + findXRefSymbols(fd); + } + } + + // remove temporary files + if (!Doxygen::objDBFileName.isEmpty()) unlink(Doxygen::objDBFileName); + if (!Doxygen::entryDBFileName.isEmpty()) unlink(Doxygen::entryDBFileName); + // clean up after us + rmdir("/tmp/doxygen"); + + while (1) + { + printf("> Type a symbol name or\n> .list for a list of symbols or\n> .quit to exit\n> "); + fgets(cmd,256,stdin); + QCString s(cmd); + if (s.at(s.length()-1)=='\n') s=s.left(s.length()-1); // strip trailing \n + if (s==".list") + listSymbols(); + else if (s==".quit") + exit(0); + else + lookupSymbols(s); + } +} + diff --git a/trunk/addon/doxyapp/doxyapp.pro.in b/trunk/addon/doxyapp/doxyapp.pro.in new file mode 100644 index 0000000..68fea3d --- /dev/null +++ b/trunk/addon/doxyapp/doxyapp.pro.in @@ -0,0 +1,12 @@ +TEMPLATE = app.t +CONFIG = console warn_on debug +HEADERS = +SOURCES = doxyapp.cpp +LIBS += -L../../lib -L../../lib -ldoxygen -lqtools -lmd5 -ldoxycfg -lpng +DESTDIR = +OBJECTS_DIR = ../../objects +TARGET = ../../bin/doxyapp +INCLUDEPATH += ../../qtools ../../src +DEPENDPATH += ../../src +TARGETDEPS = ../../lib/libdoxygen.a + diff --git a/trunk/addon/doxywizard/Makefile.in b/trunk/addon/doxywizard/Makefile.in new file mode 100644 index 0000000..fa459c2 --- /dev/null +++ b/trunk/addon/doxywizard/Makefile.in @@ -0,0 +1,39 @@ +# +# +# +# Copyright (C) 1997-2008 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 +# for any purpose. It is provided "as is" without express or implied warranty. +# See the GNU General Public License for more details. +# + +QMAKE = qmake + +all: Makefile.doxywizard + $(MAKE) -f Makefile.doxywizard + +Makefile.doxywizard: doxywizard.pro + $(QTDIR)/bin/qmake doxywizard.pro -o Makefile.doxywizard + +qmake: + $(QTDIR)/bin/qmake doxywizard.pro -o Makefile.doxywizard + +clean: Makefile.doxywizard + $(MAKE) -f Makefile.doxywizard clean + +distclean: Makefile.doxywizard + $(MAKE) -f Makefile.doxywizard distclean + $(RM) Makefile.doxywizard + +install: + $(INSTTOOL) -d $(INSTALL)/bin + $(INSTTOOL) -m 755 ../../bin/doxywizard $(INSTALL)/bin + $(INSTTOOL) -d $(INSTALL)/$(MAN1DIR) + cat ../../doc/doxywizard.1 | sed -e "s/DATE/$(DATE)/g" -e "s/VERSION/$(VERSION)/g" > doxywizard.1 + $(INSTTOOL) -m 644 doxywizard.1 $(INSTALL)/$(MAN1DIR)/doxywizard.1 + rm doxywizard.1 + +FORCE: diff --git a/trunk/addon/doxywizard/README b/trunk/addon/doxywizard/README new file mode 100644 index 0000000..57705f0 --- /dev/null +++ b/trunk/addon/doxywizard/README @@ -0,0 +1,3 @@ +Doxywizard is a graphical front-end to read/edit/write doxygen configuration +files and to launch doxygen. It requires Qt version 4.3 or higher. + diff --git a/trunk/addon/doxywizard/doxywizard.cpp b/trunk/addon/doxywizard/doxywizard.cpp new file mode 100644 index 0000000..5928524 --- /dev/null +++ b/trunk/addon/doxywizard/doxywizard.cpp @@ -0,0 +1,600 @@ +#include <QtGui> +#include "doxywizard.h" +#include "version.h" +#include "expert.h" +#include "wizard.h" + +const int messageTimeout = 5000; //!< status bar message timeout in millisec. + +MainWindow &MainWindow::instance() +{ + static MainWindow *theInstance = new MainWindow; + return *theInstance; +} + +MainWindow::MainWindow() + : m_settings(QString::fromAscii("Doxygen.org"), QString::fromAscii("Doxywizard")) +{ + QMenu *file = menuBar()->addMenu(tr("File")); + file->addAction(tr("Open..."), + this, SLOT(openConfig()), Qt::CTRL+Qt::Key_O); + m_recentMenu = file->addMenu(tr("Open recent")); + file->addAction(tr("Save"), + this, SLOT(saveConfig()), Qt::CTRL+Qt::Key_S); + file->addAction(tr("Save as..."), + this, SLOT(saveConfigAs()), Qt::SHIFT+Qt::CTRL+Qt::Key_S); + file->addAction(tr("Quit"), + this, SLOT(quit()), Qt::CTRL+Qt::Key_Q); + + QMenu *settings = menuBar()->addMenu(tr("Settings")); + settings->addAction(tr("Reset to factory defaults"), + this,SLOT(resetToDefaults())); + settings->addAction(tr("Use current settings at startup"), + this,SLOT(makeDefaults())); + + QMenu *help = menuBar()->addMenu(tr("Help")); + help->addAction(tr("Online manual"), + this, SLOT(manual()), Qt::Key_F1); + help->addAction(tr("About"), + this, SLOT(about()) ); + + m_expert = new Expert; + m_wizard = new Wizard(m_expert->modelData()); + + // ----------- top part ------------------ + QWidget *topPart = new QWidget; + QVBoxLayout *rowLayout = new QVBoxLayout(topPart); + + // select working directory + QHBoxLayout *dirLayout = new QHBoxLayout; + m_workingDir = new QLineEdit; + m_selWorkingDir = new QPushButton(tr("Select...")); + dirLayout->addWidget(m_workingDir); + dirLayout->addWidget(m_selWorkingDir); + + //------------- bottom part -------------- + QWidget *runTab = new QWidget; + QVBoxLayout *runTabLayout = new QVBoxLayout(runTab); + + // run doxygen + QHBoxLayout *runLayout = new QHBoxLayout; + m_run = new QPushButton(tr("Run doxygen")); + m_run->setEnabled(false); + m_runStatus = new QLabel(tr("Status: not running")); + m_saveLog = new QPushButton(tr("Save log...")); + m_saveLog->setEnabled(false); + QPushButton *showSettings = new QPushButton(tr("Show configuration")); + runLayout->addWidget(m_run); + runLayout->addWidget(m_runStatus); + runLayout->addStretch(1); + runLayout->addWidget(showSettings); + runLayout->addWidget(m_saveLog); + + // output produced by doxygen + runTabLayout->addLayout(runLayout); + runTabLayout->addWidget(new QLabel(tr("Output produced by doxygen"))); + QGridLayout *grid = new QGridLayout; + m_outputLog = new QTextEdit; + m_outputLog->setReadOnly(true); + m_outputLog->setFontFamily(QString::fromAscii("courier")); + m_outputLog->setMinimumWidth(600); + grid->addWidget(m_outputLog,0,0); + grid->setColumnStretch(0,1); + grid->setRowStretch(0,1); + QHBoxLayout *launchLayout = new QHBoxLayout; + m_launchHtml = new QPushButton(tr("Show HTML output")); + launchLayout->addWidget(m_launchHtml); + +#if 0 + m_launchPdf = new QPushButton(tr("Show PDF output")); + launchLayout->addWidget(m_launchPdf); +#endif + launchLayout->addStretch(1); + grid->addLayout(launchLayout,1,0); + runTabLayout->addLayout(grid); + + QTabWidget *tabs = new QTabWidget; + tabs->addTab(m_wizard,tr("Wizard")); + tabs->addTab(m_expert,tr("Expert")); + tabs->addTab(runTab,tr("Run")); + + rowLayout->addWidget(new QLabel(tr("Step 1: Specify the working directory from which doxygen will run"))); + rowLayout->addLayout(dirLayout); + rowLayout->addWidget(new QLabel(tr("Step 2: Configure doxygen using the Wizard and/or Expert tab, then switch to the Run tab to generate the documentation"))); + rowLayout->addWidget(tabs); + + setCentralWidget(topPart); + statusBar()->showMessage(tr("Welcome to Doxygen"),messageTimeout); + loadSettings(); + + m_runProcess = new QProcess; + m_running = false; + m_timer = new QTimer; + updateLaunchButtonState(); + m_modified = false; + updateTitle(); + + // connect signals and slots + connect(tabs,SIGNAL(currentChanged(int)),SLOT(selectTab(int))); + connect(m_selWorkingDir,SIGNAL(clicked()),SLOT(selectWorkingDir())); + connect(m_recentMenu,SIGNAL(triggered(QAction*)),SLOT(openRecent(QAction*))); + connect(m_workingDir,SIGNAL(returnPressed()),SLOT(updateWorkingDir())); + connect(m_runProcess,SIGNAL(readyReadStandardOutput()),SLOT(readStdout())); + connect(m_runProcess,SIGNAL(finished(int, QProcess::ExitStatus)),SLOT(runComplete())); + connect(m_timer,SIGNAL(timeout()),SLOT(readStdout())); + connect(m_run,SIGNAL(clicked()),SLOT(runDoxygen())); + connect(m_launchHtml,SIGNAL(clicked()),SLOT(showHtmlOutput())); + connect(m_saveLog,SIGNAL(clicked()),SLOT(saveLog())); + connect(showSettings,SIGNAL(clicked()),SLOT(showSettings())); + connect(m_expert,SIGNAL(changed()),SLOT(configChanged())); +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + if (discardUnsavedChanges()) + { + saveSettings(); + event->accept(); + } + else + { + event->ignore(); + } +} + +void MainWindow::quit() +{ + if (discardUnsavedChanges()) + { + saveSettings(); + } + QApplication::exit(0); +} + +void MainWindow::setWorkingDir(const QString &dirName) +{ + QDir::setCurrent(dirName); + m_workingDir->setText(dirName); + m_run->setEnabled(!dirName.isEmpty()); +} + +void MainWindow::selectWorkingDir() +{ + QString dirName = QFileDialog::getExistingDirectory(this, + tr("Select working directory"),m_workingDir->text()); + if (!dirName.isEmpty()) + { + setWorkingDir(dirName); + } +} + +void MainWindow::updateWorkingDir() +{ + setWorkingDir(m_workingDir->text()); +} + +void MainWindow::manual() +{ + QDesktopServices::openUrl(QUrl(QString::fromAscii("http://www.doxygen.org/manual.html"))); +} + +void MainWindow::about() +{ + QString msg; + QTextStream t(&msg,QIODevice::WriteOnly); + t << QString::fromAscii("<qt><center>A tool to configure and run doxygen version ")+ + QString::fromAscii(versionString)+ + QString::fromAscii(" on your source files.</center><p><br>" + "<center>Written by<br> Dimitri van Heesch<br>© 2000-2008</center><p>" + "</qt>"); + QMessageBox::about(this,tr("Doxygen GUI"),msg); +} + +void MainWindow::openConfig() +{ + if (discardUnsavedChanges(false)) + { + QString fn = QFileDialog::getOpenFileName(this, + tr("Open configuration file"), + m_workingDir->text()); + if (!fn.isEmpty()) + { + loadConfigFromFile(fn); + } + } +} + +void MainWindow::updateConfigFileName(const QString &fileName) +{ + if (m_fileName!=fileName) + { + m_fileName = fileName; + QString curPath = QFileInfo(fileName).path(); + setWorkingDir(curPath); + addRecentFile(fileName); + updateTitle(); + } +} + +void MainWindow::loadConfigFromFile(const QString & fileName) +{ + m_expert->loadConfig(fileName); + m_wizard->refresh(); + updateConfigFileName(fileName); + updateLaunchButtonState(); + m_modified = false; + updateTitle(); +} + +void MainWindow::saveConfig(const QString &fileName) +{ + if (fileName.isEmpty()) return; + QFile f(fileName); + if (!f.open(QIODevice::WriteOnly)) return; + QTextStream t(&f); + m_expert->writeConfig(t,false); + updateConfigFileName(fileName); + m_modified = false; + updateTitle(); +} + +bool MainWindow::saveConfig() +{ + if (m_fileName.isEmpty()) + { + return saveConfigAs(); + } + else + { + saveConfig(m_fileName); + return true; + } +} + +bool MainWindow::saveConfigAs() +{ + QString fileName = QFileDialog::getSaveFileName(this, QString(), + m_workingDir->text()+QString::fromAscii("/Doxyfile")); + if (fileName.isEmpty()) return false; + saveConfig(fileName); + return true; +} + +void MainWindow::makeDefaults() +{ + if (QMessageBox::question(this,tr("Use current setting at startup?"), + tr("Do you want to save the current settings " + "and use them next time Doxywizard starts?"), + QMessageBox::Save| + QMessageBox::Cancel)==QMessageBox::Save) + { + //printf("MainWindow:makeDefaults()\n"); + m_expert->saveSettings(&m_settings); + m_settings.setValue(QString::fromAscii("wizard/loadsettings"), true); + } +} + +void MainWindow::resetToDefaults() +{ + if (QMessageBox::question(this,tr("Reset settings to their default values?"), + tr("Do you want to revert all settings back " + "to their original values?"), + QMessageBox::Reset| + QMessageBox::Cancel)==QMessageBox::Reset) + { + //printf("MainWindow:resetToDefaults()\n"); + m_expert->resetToDefaults(); + m_settings.setValue(QString::fromAscii("wizard/loadsettings"), false); + m_wizard->refresh(); + } +} + +void MainWindow::loadSettings() +{ + QVariant geometry = m_settings.value(QString::fromAscii("main/geometry"), QVariant::Invalid); + QVariant state = m_settings.value(QString::fromAscii("main/state"), QVariant::Invalid); + QVariant expState = m_settings.value(QString::fromAscii("expert/state"), QVariant::Invalid); + QVariant expState2 = m_settings.value(QString::fromAscii("expert/state2"), QVariant::Invalid); + QVariant wizState = m_settings.value(QString::fromAscii("wizard/state"), QVariant::Invalid); + QVariant loadSettings = m_settings.value(QString::fromAscii("wizard/loadsettings"), QVariant::Invalid); + //QVariant workingDir = m_settings.value(QString::fromAscii("main/defdir"), QVariant::Invalid); + + if (geometry !=QVariant::Invalid) restoreGeometry(geometry.toByteArray()); + if (state !=QVariant::Invalid) restoreState (state.toByteArray()); + if (expState !=QVariant::Invalid) m_expert->restoreState(expState.toByteArray()); + if (expState2 !=QVariant::Invalid) m_expert->restoreInnerState(expState2.toByteArray()); + if (wizState !=QVariant::Invalid) m_wizard->restoreState(wizState.toByteArray()); + //if (workingDir!=QVariant::Invalid) + //{ + // QString dir = workingDir.toString(); + // m_workingDir->setText(dir); + // QDir::setCurrent(dir); + // m_run->setEnabled(!dir.isEmpty()); + //} + if (loadSettings!=QVariant::Invalid && loadSettings.toBool()) + { + m_expert->loadSettings(&m_settings); + } + + for (int i=0;i<10;i++) + { + QString entry = m_settings.value(QString().sprintf("recent/config%d",i)).toString(); + if (!entry.isEmpty()) addRecentFile(entry); + } + +} + +void MainWindow::saveSettings() +{ + QSettings settings(QString::fromAscii("Doxygen.org"), QString::fromAscii("Doxywizard")); + + m_settings.setValue(QString::fromAscii("main/geometry"), saveGeometry()); + m_settings.setValue(QString::fromAscii("main/state"), saveState()); + m_settings.setValue(QString::fromAscii("expert/state"), m_expert->saveState()); + m_settings.setValue(QString::fromAscii("expert/state2"), m_expert->saveInnerState()); + m_settings.setValue(QString::fromAscii("wizard/state"), m_wizard->saveState()); +} + +void MainWindow::selectTab(int id) +{ + if (id==0) m_wizard->refresh(); +} + +void MainWindow::addRecentFile(const QString &fileName) +{ + int i=m_recentFiles.indexOf(fileName); + if (i!=-1) m_recentFiles.removeAt(i); + + // not found + if (m_recentFiles.count() < 10) // append + { + m_recentFiles.prepend(fileName); + } + else // add + drop last item + { + m_recentFiles.removeLast(); + m_recentFiles.prepend(fileName); + } + m_recentMenu->clear(); + i=0; + foreach( QString str, m_recentFiles ) + { + m_recentMenu->addAction(str); + m_settings.setValue(QString().sprintf("recent/config%d",i++),str); + } +} + +void MainWindow::openRecent(QAction *action) +{ + if (discardUnsavedChanges(false)) + { + loadConfigFromFile(action->text()); + } +} + +void MainWindow::runDoxygen() +{ + if (!m_running) + { + QString doxygenPath; +#if defined(Q_OS_MACX) + doxygenPath = qApp->applicationDirPath()+QString::fromAscii("/../Resources/"); + qDebug() << tr("Doxygen path: ") << doxygenPath; + if ( !QFile(doxygenPath + QString::fromAscii("doxygen")).exists() ) { + // No doygen binary in the resources, if there is a system doxygen binary, use that instead + if ( QFile(QString::fromAscii("/usr/local/bin/doxygen")).exists() ) + doxygenPath = QString::fromAscii("/usr/local/bin/"); + else { + qDebug() << tr("Can't find the doxygen command, make sure it's in your $$PATH"); + doxygenPath = QString::fromAscii(""); + } + } + qDebug() << tr("Getting doxygen from: ") << doxygenPath; +#endif + + m_runProcess->setReadChannel(QProcess::StandardOutput); + m_runProcess->setProcessChannelMode(QProcess::MergedChannels); + m_runProcess->setWorkingDirectory(m_workingDir->text()); + QStringList env=QProcess::systemEnvironment(); + // set PWD environment variable to m_workingDir + env.replaceInStrings(QRegExp(QString::fromAscii("^PWD=(.*)"),Qt::CaseInsensitive), + QString::fromAscii("PWD=")+m_workingDir->text()); + m_runProcess->setEnvironment(env); + + QStringList args; + args << QString::fromAscii("-b"); // make stdout unbuffered + args << QString::fromAscii("-"); // read config from stdin + + m_outputLog->clear(); + m_runProcess->start(doxygenPath + QString::fromAscii("doxygen"), args); + + if (!m_runProcess->waitForStarted()) + { + m_outputLog->append(QString::fromAscii("*** Failed to run doxygen\n")); + return; + } + QTextStream t(m_runProcess); + m_expert->writeConfig(t,false); + m_runProcess->closeWriteChannel(); + + if (m_runProcess->state() == QProcess::NotRunning) + { + m_outputLog->append(QString::fromAscii("*** Failed to run doxygen\n")); + } + else + { + m_saveLog->setEnabled(false); + m_running=true; + m_run->setText(tr("Stop doxygen")); + m_runStatus->setText(tr("Status: running")); + m_timer->start(1000); + } + } + else + { + m_running=false; + m_run->setText(tr("Run doxygen")); + m_runStatus->setText(tr("Status: not running")); + m_runProcess->kill(); + m_timer->stop(); + //updateRunnable(m_workingDir->text()); + } +} + +void MainWindow::readStdout() +{ + if (m_running) + { + QByteArray data = m_runProcess->readAllStandardOutput(); + QString text = QString::fromLocal8Bit(data); + if (!text.isEmpty()) + { + m_outputLog->append(text.trimmed()); + } + } +} + +void MainWindow::runComplete() +{ + if (m_running) + { + m_outputLog->append(tr("*** Doxygen has finished\n")); + } + else + { + m_outputLog->append(tr("*** Cancelled by user\n")); + } + m_outputLog->ensureCursorVisible(); + m_run->setText(tr("Run doxygen")); + m_runStatus->setText(tr("Status: not running")); + m_running=false; + updateLaunchButtonState(); + //updateRunnable(m_workingDir->text()); + m_saveLog->setEnabled(true); +} + +void MainWindow::updateLaunchButtonState() +{ + m_launchHtml->setEnabled(m_expert->htmlOutputPresent(m_workingDir->text())); +#if 0 + m_launchPdf->setEnabled(m_expert->pdfOutputPresent(m_workingDir->text())); +#endif +} + +void MainWindow::showHtmlOutput() +{ + QString indexFile = m_expert->getHtmlOutputIndex(m_workingDir->text()); + QFileInfo fi(indexFile); +#ifdef WIN32 + QString indexUrl(QString::fromAscii("file:///")); +#else + QString indexUrl(QString::fromAscii("file://")); +#endif + indexUrl+=fi.absoluteFilePath(); + QDesktopServices::openUrl(QUrl(indexUrl)); +} + +void MainWindow::saveLog() +{ + QString fn = QFileDialog::getSaveFileName(this, tr("Save log file"), + m_workingDir->text()+ + QString::fromAscii("/doxygen_log.txt")); + if (!fn.isEmpty()) + { + QFile f(fn); + if (f.open(QIODevice::WriteOnly)) + { + QTextStream t(&f); + t << m_outputLog->toPlainText(); + statusBar()->showMessage(tr("Output log saved"),messageTimeout); + } + else + { + QMessageBox::warning(0,tr("Warning"), + tr("Cannot open file ")+fn+tr(" for writing. Nothing saved!"),tr("ok")); + } + } +} + +void MainWindow::showSettings() +{ + QString text; + QTextStream t(&text); + m_expert->writeConfig(t,true); + m_outputLog->clear(); + m_outputLog->append(text); + m_outputLog->ensureCursorVisible(); + m_saveLog->setEnabled(true); +} + +void MainWindow::configChanged() +{ + m_modified = true; + updateTitle(); +} + +void MainWindow::updateTitle() +{ + QString title = tr("Doxygen GUI frontend"); + if (m_modified) + { + title+=QString::fromAscii(" +"); + } + if (!m_fileName.isEmpty()) + { + title+=QString::fromAscii(" (")+m_fileName+QString::fromAscii(")"); + } + setWindowTitle(title); +} + +bool MainWindow::discardUnsavedChanges(bool saveOption) +{ + if (m_modified) + { + QMessageBox::StandardButton button; + if (saveOption) + { + button = QMessageBox::question(this, + tr("Unsaved changes"), + tr("Unsaved changes will be lost! Do you want to save the configuration file?"), + QMessageBox::Save | + QMessageBox::Discard | + QMessageBox::Cancel + ); + if (button==QMessageBox::Save) + { + return saveConfig(); + } + } + else + { + button = QMessageBox::question(this, + tr("Unsaved changes"), + tr("Unsaved changes will be lost! Do you want to continue?"), + QMessageBox::Discard | + QMessageBox::Cancel + ); + } + return button==QMessageBox::Discard; + } + return true; +} + +//----------------------------------------------------------------------- + +int main(int argc,char **argv) +{ + QApplication a(argc,argv); + MainWindow &main = MainWindow::instance(); + if (argc==2 && argv[1][0]!='-') // name of config file as an argument + { + main.loadConfigFromFile(QString::fromLocal8Bit(argv[1])); + } + else if (argc>1) + { + printf("Usage: %s [config file]\n",argv[0]); + exit(1); + } + main.show(); + return a.exec(); +} diff --git a/trunk/addon/doxywizard/doxywizard.h b/trunk/addon/doxywizard/doxywizard.h new file mode 100644 index 0000000..49e13cc --- /dev/null +++ b/trunk/addon/doxywizard/doxywizard.h @@ -0,0 +1,83 @@ +#ifndef DOXYWIZARD_H +#define DOXYWIZARD_H + +#include <QMainWindow> +#include <QSettings> +#include <QStringList> + +class Expert; +class Wizard; +class QLabel; +class QLineEdit; +class QPushButton; +class QTextEdit; +class QMenu; +class QProcess; +class QTimer; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + static MainWindow &instance(); + void loadConfigFromFile(const QString &fileName); + void loadSettings(); + void saveSettings(); + void closeEvent(QCloseEvent *event); + QString configFileName() const { return m_fileName; } + void updateTitle(); + + public slots: + void manual(); + void about(); + void openConfig(); + bool saveConfig(); + bool saveConfigAs(); + void makeDefaults(); + void resetToDefaults(); + void selectTab(int); + void quit(); + + private slots: + void openRecent(QAction *action); + void selectWorkingDir(); + void updateWorkingDir(); + void runDoxygen(); + void readStdout(); + void runComplete(); + void showHtmlOutput(); + void saveLog(); + void showSettings(); + void configChanged(); + + private: + MainWindow(); + void saveConfig(const QString &fileName); + void addRecentFile(const QString &fileName); + void updateConfigFileName(const QString &fileName); + void setWorkingDir(const QString &dirName); + void updateLaunchButtonState(); + bool discardUnsavedChanges(bool saveOption=true); + + QLineEdit *m_workingDir; + QPushButton *m_selWorkingDir; + QPushButton *m_run; + QPushButton *m_saveLog; + QPushButton *m_launchHtml; + QPushButton *m_launchPdf; + QTextEdit *m_outputLog; + QLabel *m_runStatus; + Expert *m_expert; + Wizard *m_wizard; + QString m_fileName; + QSettings m_settings; + QMenu *m_recentMenu; + QStringList m_recentFiles; + QProcess *m_runProcess; + QTimer *m_timer; + bool m_running; + bool m_modified; +}; + +#endif diff --git a/trunk/addon/doxywizard/doxywizard.pro.in b/trunk/addon/doxywizard/doxywizard.pro.in new file mode 100644 index 0000000..b9f8f70 --- /dev/null +++ b/trunk/addon/doxywizard/doxywizard.pro.in @@ -0,0 +1,27 @@ +###################################################################### +# Automatically generated by qmake (2.01a) zo okt 19 12:50:02 2008 +###################################################################### + +TEMPLATE = app +DESTDIR = ../../bin +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT += xml +CONFIG += $extraopts +OBJECTS_DIR = obj +MOC_DIR = moc +RCC_DIR = rcc +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII + +macx-g++ { + CONFIG += x86 ppc +} + +# Input +HEADERS += doxywizard.h version.h expert.h config.h helplabel.h \ + inputbool.h inputstring.h inputint.h inputstrlist.h wizard.h +SOURCES += doxywizard.cpp ../../src/version.cpp expert.cpp wizard.cpp \ + inputbool.cpp inputstring.cpp inputint.cpp inputstrlist.cpp +LEXSOURCES += config.l +RESOURCES += doxywizard.qrc diff --git a/trunk/addon/doxywizard/doxywizard.qrc b/trunk/addon/doxywizard/doxywizard.qrc new file mode 100644 index 0000000..dd23c5d --- /dev/null +++ b/trunk/addon/doxywizard/doxywizard.qrc @@ -0,0 +1,10 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file alias="config.xml">../../src/config.xml</file> + <file>images/add.png</file> + <file>images/del.png</file> + <file>images/file.png</file> + <file>images/folder.png</file> + <file>images/refresh.png</file> +</qresource> +</RCC> diff --git a/trunk/addon/doxywizard/expert.cpp b/trunk/addon/doxywizard/expert.cpp new file mode 100644 index 0000000..7c16c28 --- /dev/null +++ b/trunk/addon/doxywizard/expert.cpp @@ -0,0 +1,553 @@ +#include "expert.h" +#include "inputbool.h" +#include "inputstring.h" +#include "inputint.h" +#include "inputstring.h" +#include "inputstrlist.h" +#include <QtGui> +#include <QtXml> +#include "config.h" +#include "version.h" + +#undef SA +#define SA(x) QString::fromAscii(x) + +static QString convertToComment(const QString &s) +{ + if (s.isEmpty()) + { + return QString(); + } + else + { + return SA("# ")+ + s.trimmed().replace(SA("\n"),SA("\n# "))+ + SA("\n"); + } +} + +//------------------------------------------------------------------------------------ + +Expert::Expert() +{ + m_treeWidget = new QTreeWidget; + m_treeWidget->setColumnCount(1); + m_topicStack = new QStackedWidget; + + QFile file(SA(":/config.xml")); + QString err; + int errLine,errCol; + QDomDocument configXml; + if (file.open(QIODevice::ReadOnly)) + { + if (!configXml.setContent(&file,false,&err,&errLine,&errCol)) + { + QString msg = tr("Error parsing internal config.xml at line %1 column %2.\n%3"). + arg(errLine).arg(errCol).arg(err); + QMessageBox::warning(this, tr("Error"), msg); + exit(1); + } + } + m_rootElement = configXml.documentElement(); + + createTopics(m_rootElement); + m_helper = new QTextEdit; + m_helper->setReadOnly(true); + m_splitter = new QSplitter(Qt::Vertical); + m_splitter->addWidget(m_treeWidget); + m_splitter->addWidget(m_helper); + + QWidget *rightSide = new QWidget; + QGridLayout *grid = new QGridLayout(rightSide); + m_prev = new QPushButton(tr("Previous")); + m_prev->setEnabled(false); + m_next = new QPushButton(tr("Next")); + grid->addWidget(m_topicStack,0,0,1,2); + grid->addWidget(m_prev,1,0,Qt::AlignLeft); + grid->addWidget(m_next,1,1,Qt::AlignRight); + grid->setColumnStretch(0,1); + grid->setRowStretch(0,1); + + addWidget(m_splitter); + addWidget(rightSide); + connect(m_next,SIGNAL(clicked()),SLOT(nextTopic())); + + connect(m_prev,SIGNAL(clicked()),SLOT(prevTopic())); +} + +Expert::~Expert() +{ + QHashIterator<QString,Input*> i(m_options); + while (i.hasNext()) + { + i.next(); + delete i.value(); + } +} + +void Expert::createTopics(const QDomElement &rootElem) +{ + QList<QTreeWidgetItem*> items; + QDomElement childElem = rootElem.firstChildElement(); + while (!childElem.isNull()) + { + if (childElem.tagName()==SA("group")) + { + QString name = childElem.attribute(SA("name")); + items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(name))); + QWidget *widget = createTopicWidget(childElem); + m_topics[name] = widget; + m_topicStack->addWidget(widget); + } + childElem = childElem.nextSiblingElement(); + } + m_treeWidget->setHeaderLabels(QStringList() << SA("Topics")); + m_treeWidget->insertTopLevelItems(0,items); + connect(m_treeWidget, + SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)), + this, + SLOT(activateTopic(QTreeWidgetItem *,QTreeWidgetItem *))); +} + + +QWidget *Expert::createTopicWidget(QDomElement &elem) +{ + QScrollArea *area = new QScrollArea; + QWidget *topic = new QWidget; + QGridLayout *layout = new QGridLayout(topic); + QDomElement child = elem.firstChildElement(); + int row=0; + while (!child.isNull()) + { + QString type = child.attribute(SA("type")); + if (type==SA("bool")) + { + InputBool *boolOption = + new InputBool( + layout,row, + child.attribute(SA("id")), + child.attribute(SA("defval"))==SA("1"), + child.attribute(SA("docs")) + ); + m_options.insert( + child.attribute(SA("id")), + boolOption + ); + connect(boolOption,SIGNAL(showHelp(Input*)),SLOT(showHelp(Input*))); + connect(boolOption,SIGNAL(changed()),SIGNAL(changed())); + } + else if (type==SA("string")) + { + InputString::StringMode mode; + QString format = child.attribute(SA("format")); + if (format==SA("dir")) + { + mode = InputString::StringDir; + } + else if (format==SA("file")) + { + mode = InputString::StringFile; + } + else // format=="string" + { + mode = InputString::StringFree; + } + InputString *stringOption = + new InputString( + layout,row, + child.attribute(SA("id")), + child.attribute(SA("defval")), + mode, + child.attribute(SA("docs")) + ); + m_options.insert( + child.attribute(SA("id")), + stringOption + ); + connect(stringOption,SIGNAL(showHelp(Input*)),SLOT(showHelp(Input*))); + connect(stringOption,SIGNAL(changed()),SIGNAL(changed())); + } + else if (type==SA("enum")) + { + InputString *enumList = new InputString( + layout,row, + child.attribute(SA("id")), + child.attribute(SA("defval")), + InputString::StringFixed, + child.attribute(SA("docs")) + ); + QDomElement enumVal = child.firstChildElement(); + while (!enumVal.isNull()) + { + enumList->addValue(enumVal.attribute(SA("name"))); + enumVal = enumVal.nextSiblingElement(); + } + enumList->setDefault(); + + m_options.insert(child.attribute(SA("id")),enumList); + connect(enumList,SIGNAL(showHelp(Input*)),SLOT(showHelp(Input*))); + connect(enumList,SIGNAL(changed()),SIGNAL(changed())); + } + else if (type==SA("int")) + { + InputInt *intOption = + new InputInt( + layout,row, + child.attribute(SA("id")), + child.attribute(SA("defval")).toInt(), + child.attribute(SA("minval")).toInt(), + child.attribute(SA("maxval")).toInt(), + child.attribute(SA("docs")) + ); + m_options.insert( + child.attribute(SA("id")), + intOption + ); + connect(intOption,SIGNAL(showHelp(Input*)),SLOT(showHelp(Input*))); + connect(intOption,SIGNAL(changed()),SIGNAL(changed())); + } + else if (type==SA("list")) + { + InputStrList::ListMode mode; + QString format = child.attribute(SA("format")); + if (format==SA("dir")) + { + mode = InputStrList::ListDir; + } + else if (format==SA("file")) + { + mode = InputStrList::ListFile; + } + else if (format==SA("filedir")) + { + mode = InputStrList::ListFileDir; + } + else // format=="string" + { + mode = InputStrList::ListString; + } + QStringList sl; + QDomElement listVal = child.firstChildElement(); + while (!listVal.isNull()) + { + sl.append(listVal.attribute(SA("name"))); + listVal = listVal.nextSiblingElement(); + } + InputStrList *listOption = + new InputStrList( + layout,row, + child.attribute(SA("id")), + sl, + mode, + child.attribute(SA("docs")) + ); + m_options.insert( + child.attribute(SA("id")), + listOption + ); + connect(listOption,SIGNAL(showHelp(Input*)),SLOT(showHelp(Input*))); + connect(listOption,SIGNAL(changed()),SIGNAL(changed())); + } + else if (type==SA("obsolete")) + { + // ignore + } + else // should not happen + { + printf("Unsupported type %s\n",qPrintable(child.attribute(SA("type")))); + } + child = child.nextSiblingElement(); + } + + // compute dependencies between options + child = elem.firstChildElement(); + while (!child.isNull()) + { + QString dependsOn = child.attribute(SA("depends")); + QString id = child.attribute(SA("id")); + if (!dependsOn.isEmpty()) + { + Input *parentOption = m_options[dependsOn]; + Input *thisOption = m_options[id]; + Q_ASSERT(parentOption); + Q_ASSERT(thisOption); + if (parentOption && thisOption) + { + //printf("Adding dependency '%s' (%p)->'%s' (%p)\n", + // qPrintable(dependsOn),parentOption, + // qPrintable(id),thisOption); + parentOption->addDependency(thisOption); + } + } + child = child.nextSiblingElement(); + } + + // set initial dependencies + QHashIterator<QString,Input*> i(m_options); + while (i.hasNext()) + { + i.next(); + if (i.value()) + { + i.value()->updateDependencies(); + } + } + + layout->setRowStretch(row,1); + layout->setColumnStretch(1,2); + layout->setSpacing(5); + topic->setLayout(layout); + area->setWidget(topic); + area->setWidgetResizable(true); + return area; +} + +void Expert::activateTopic(QTreeWidgetItem *item,QTreeWidgetItem *) +{ + if (item) + { + QWidget *w = m_topics[item->text(0)]; + m_topicStack->setCurrentWidget(w); + m_prev->setEnabled(m_topicStack->currentIndex()!=0); + m_next->setEnabled(m_topicStack->currentIndex()!=m_topicStack->count()-1); + } +} + +void Expert::loadSettings(QSettings *s) +{ + QHashIterator<QString,Input*> i(m_options); + while (i.hasNext()) + { + i.next(); + QVariant var = s->value(SA("config/")+i.key()); + //printf("Loading key %s: type=%d\n",qPrintable(i.key()),var.type()); + if (i.value()) + { + i.value()->value() = var; + i.value()->update(); + } + } +} + +void Expert::saveSettings(QSettings *s) +{ + QHashIterator<QString,Input*> i(m_options); + while (i.hasNext()) + { + i.next(); + if (i.value()) + { + s->value(SA("config/")+i.key(),i.value()->value()); + } + } +} + +void Expert::loadConfig(const QString &fileName) +{ + //printf("Expert::loadConfig(%s)\n",qPrintable(fileName)); + parseConfig(fileName,m_options); +} + +void Expert::saveTopic(QTextStream &t,QDomElement &elem,QTextCodec *codec, + bool brief) +{ + // write group header + t << endl; + t << "#---------------------------------------------------------------------------" << endl; + t << "# " << elem.attribute(SA("docs")) << endl; + t << "#---------------------------------------------------------------------------" << endl; + + // write options... + QDomElement childElem = elem.firstChildElement(); + while (!childElem.isNull()) + { + QString type = childElem.attribute(SA("type")); + QString name = childElem.attribute(SA("id")); + QHash<QString,Input*>::const_iterator i = m_options.find(name); + if (i!=m_options.end()) + { + Input *option = i.value(); + if (!brief) + { + t << endl; + t << convertToComment(childElem.attribute(SA("docs"))); + t << endl; + } + t << name.leftJustified(23) << "= "; + if (option) + { + option->writeValue(t,codec); + } + t << endl; + } + childElem = childElem.nextSiblingElement(); + } + +} + +bool Expert::writeConfig(QTextStream &t,bool brief) +{ + if (!brief) + { + // write global header + t << "# Doxyfile " << versionString << endl << endl; // TODO: add version + t << "# This file describes the settings to be used by the documentation system\n"; + t << "# doxygen (www.doxygen.org) for a project\n"; + t << "#\n"; + t << "# All text after a hash (#) is considered a comment and will be ignored\n"; + t << "# The format is:\n"; + t << "# TAG = value [value, ...]\n"; + t << "# For lists items can also be appended using:\n"; + t << "# TAG += value [value, ...]\n"; + t << "# Values that contain spaces should be placed between quotes (\" \")\n"; + } + + QTextCodec *codec = 0; + Input *option = m_options[QString::fromAscii("DOXYFILE_ENCODING")]; + if (option) + { + codec = QTextCodec::codecForName(option->value().toString().toAscii()); + if (codec==0) // fallback: use UTF-8 + { + codec = QTextCodec::codecForName("UTF-8"); + } + } + QDomElement childElem = m_rootElement.firstChildElement(); + while (!childElem.isNull()) + { + saveTopic(t,childElem,codec,brief); + childElem = childElem.nextSiblingElement(); + } + return true; +} + +QByteArray Expert::saveInnerState () const +{ + return m_splitter->saveState(); +} + +bool Expert::restoreInnerState ( const QByteArray & state ) +{ + return m_splitter->restoreState(state); +} + +void Expert::showHelp(Input *option) +{ + m_helper->setText( + QString::fromAscii("<qt><b>")+option->id()+ + QString::fromAscii("</b><br>")+ + option->docs(). + replace(QChar::fromAscii('\n'),QChar::fromAscii(' '))+ + QString::fromAscii("<qt>") + ); +} + +void Expert::nextTopic() +{ + m_topicStack->setCurrentIndex(m_topicStack->currentIndex()+1); + m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1); + m_prev->setEnabled(m_topicStack->currentIndex()!=0); + m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex())); +} + +void Expert::prevTopic() +{ + m_topicStack->setCurrentIndex(m_topicStack->currentIndex()-1); + m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1); + m_prev->setEnabled(m_topicStack->currentIndex()!=0); + m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex())); +} + +void Expert::resetToDefaults() +{ + //printf("Expert::makeDefaults()\n"); + QHashIterator<QString,Input*> i(m_options); + while (i.hasNext()) + { + i.next(); + if (i.value()) + { + i.value()->reset(); + } + } +} + +static bool stringVariantToBool(const QVariant &v) +{ + QString s = v.toString().toLower(); + return s==QString::fromAscii("yes") || s==QString::fromAscii("true") || s==QString::fromAscii("1"); +} + +static bool getBoolOption( + const QHash<QString,Input*>&model,const QString &name) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + return stringVariantToBool(option->value()); +} + +static QString getStringOption( + const QHash<QString,Input*>&model,const QString &name) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + return option->value().toString(); +} + + +bool Expert::htmlOutputPresent(const QString &workingDir) const +{ + bool generateHtml = getBoolOption(m_options,QString::fromAscii("GENERATE_HTML")); + if (!generateHtml || workingDir.isEmpty()) return false; + QString indexFile = getHtmlOutputIndex(workingDir); + QFileInfo fi(indexFile); + return fi.exists() && fi.isFile(); +} + +QString Expert::getHtmlOutputIndex(const QString &workingDir) const +{ + QString outputDir = getStringOption(m_options,QString::fromAscii("OUTPUT_DIRECTORY")); + QString htmlOutputDir = getStringOption(m_options,QString::fromAscii("HTML_OUTPUT")); + //printf("outputDir=%s\n",qPrintable(outputDir)); + //printf("htmlOutputDir=%s\n",qPrintable(htmlOutputDir)); + QString indexFile = workingDir; + if (QFileInfo(outputDir).isAbsolute()) // override + { + indexFile = outputDir; + } + else // append + { + indexFile += QString::fromAscii("/")+outputDir; + } + if (QFileInfo(htmlOutputDir).isAbsolute()) // override + { + indexFile = htmlOutputDir; + } + else // append + { + indexFile += QString::fromAscii("/")+htmlOutputDir; + } + indexFile+=QString::fromAscii("/index.html"); + return indexFile; +} + +bool Expert::pdfOutputPresent(const QString &workingDir) const +{ + bool generateLatex = getBoolOption(m_options,QString::fromAscii("GENERATE_LATEX")); + bool pdfLatex = getBoolOption(m_options,QString::fromAscii("USE_PDFLATEX")); + if (!generateLatex || !pdfLatex) return false; + QString latexOutput = getStringOption(m_options,QString::fromAscii("LATEX_OUTPUT")); + QString indexFile; + if (QFileInfo(latexOutput).isAbsolute()) + { + indexFile = latexOutput+QString::fromAscii("/refman.pdf"); + } + else + { + indexFile = workingDir+QString::fromAscii("/")+ + latexOutput+QString::fromAscii("/refman.pdf"); + } + QFileInfo fi(indexFile); + return fi.exists() && fi.isFile(); +} + diff --git a/trunk/addon/doxywizard/expert.h b/trunk/addon/doxywizard/expert.h new file mode 100644 index 0000000..3372ae6 --- /dev/null +++ b/trunk/addon/doxywizard/expert.h @@ -0,0 +1,64 @@ +#ifndef EXPERT_H +#define EXPERT_H + +#include <QSplitter> +#include <QDomElement> +#include <QHash> + +class QTreeWidget; +class QTreeWidgetItem; +class QStackedWidget; +class QSettings; +class QTextEdit; +class QTextCodec; +class QPushButton; +class Input; + +class Expert : public QSplitter +{ + Q_OBJECT + + public: + Expert(); + ~Expert(); + void loadSettings(QSettings *); + void saveSettings(QSettings *); + void loadConfig(const QString &fileName); + bool writeConfig(QTextStream &t,bool brief); + QByteArray saveInnerState () const; + bool restoreInnerState ( const QByteArray & state ); + const QHash<QString,Input*> &modelData() const { return m_options; } + void resetToDefaults(); + bool htmlOutputPresent(const QString &workingDir) const; + bool pdfOutputPresent(const QString &workingDir) const; + QString getHtmlOutputIndex(const QString &workingDir) const; + + public slots: + void activateTopic(QTreeWidgetItem *,QTreeWidgetItem *); + QWidget *createTopicWidget(QDomElement &elem); + + private slots: + void showHelp(Input *); + void nextTopic(); + void prevTopic(); + + signals: + void changed(); + + private: + void createTopics(const QDomElement &); + void saveTopic(QTextStream &t,QDomElement &elem,QTextCodec *codec,bool brief); + + QSplitter *m_splitter; + QTextEdit *m_helper; + QTreeWidget *m_treeWidget; + QStackedWidget *m_topicStack; + QHash<QString,QWidget *> m_topics; + QHash<QString,QObject *> m_optionWidgets; + QHash<QString,Input *> m_options; + QPushButton *m_next; + QPushButton *m_prev; + QDomElement m_rootElement; +}; + +#endif diff --git a/trunk/addon/doxywizard/helplabel.h b/trunk/addon/doxywizard/helplabel.h new file mode 100644 index 0000000..07e2932 --- /dev/null +++ b/trunk/addon/doxywizard/helplabel.h @@ -0,0 +1,33 @@ +#ifndef HELPLABEL_H +#define HELPLABEL_H + +#include <QLabel> +#include <QMenu> + +class HelpLabel : public QLabel +{ + Q_OBJECT + public: + HelpLabel(const QString &text) : QLabel(text) + { setContextMenuPolicy(Qt::CustomContextMenu); + connect(this,SIGNAL(customContextMenuRequested(const QPoint&)), + this,SLOT(showMenu(const QPoint&))); + } + signals: + void enter(); + void reset(); + private slots: + void showMenu(const QPoint &p) + { + QMenu menu(this); + QAction *a = menu.addAction(tr("Reset to default")); + if (menu.exec(mapToGlobal(p))==a) + { + reset(); + } + } + protected: + void enterEvent( QEvent * event ) { enter(); QLabel::enterEvent(event); } +}; + +#endif diff --git a/trunk/addon/doxywizard/images/add.png b/trunk/addon/doxywizard/images/add.png Binary files differnew file mode 100644 index 0000000..30a7090 --- /dev/null +++ b/trunk/addon/doxywizard/images/add.png diff --git a/trunk/addon/doxywizard/images/del.png b/trunk/addon/doxywizard/images/del.png Binary files differnew file mode 100644 index 0000000..ceb6a60 --- /dev/null +++ b/trunk/addon/doxywizard/images/del.png diff --git a/trunk/addon/doxywizard/images/file.png b/trunk/addon/doxywizard/images/file.png Binary files differnew file mode 100644 index 0000000..e204f67 --- /dev/null +++ b/trunk/addon/doxywizard/images/file.png diff --git a/trunk/addon/doxywizard/images/folder.png b/trunk/addon/doxywizard/images/folder.png Binary files differnew file mode 100644 index 0000000..2e420e0 --- /dev/null +++ b/trunk/addon/doxywizard/images/folder.png diff --git a/trunk/addon/doxywizard/images/refresh.png b/trunk/addon/doxywizard/images/refresh.png Binary files differnew file mode 100644 index 0000000..fd6d565 --- /dev/null +++ b/trunk/addon/doxywizard/images/refresh.png diff --git a/trunk/addon/doxywizard/input.h b/trunk/addon/doxywizard/input.h new file mode 100644 index 0000000..dd1773c --- /dev/null +++ b/trunk/addon/doxywizard/input.h @@ -0,0 +1,34 @@ +#ifndef INPUT_H +#define INPUT_H + +#include <QVariant> + +class QTextStream; +class QTextCodec; + +class Input +{ + public: + enum Kind + { + Bool, + Int, + String, + StrList, + Obsolete + }; + virtual ~Input() {} + virtual QVariant &value() = 0; + virtual void update() = 0; + virtual Kind kind() const = 0; + virtual QString docs() const = 0; + virtual QString id() const = 0; + virtual void addDependency(Input *option) = 0; + virtual void setEnabled(bool) = 0; + virtual void updateDependencies() = 0; + virtual void reset() = 0; + virtual void writeValue(QTextStream &t,QTextCodec *codec) = 0; +}; + + +#endif diff --git a/trunk/addon/doxywizard/inputbool.cpp b/trunk/addon/doxywizard/inputbool.cpp new file mode 100644 index 0000000..8dbedb1 --- /dev/null +++ b/trunk/addon/doxywizard/inputbool.cpp @@ -0,0 +1,110 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "inputbool.h" +#include "helplabel.h" +#include <QtGui> + +InputBool::InputBool( QGridLayout *layout, int &row, + const QString &id, bool checked, + const QString &docs ) + : m_default(checked), m_docs(docs), m_id(id) +{ + m_lab = new HelpLabel(id); + m_cb = new QCheckBox; + layout->addWidget(m_lab,row, 0); + layout->addWidget(m_cb,row, 1); + m_enabled = true; + m_state=!checked; // force update + setValue(checked); + connect( m_cb, SIGNAL(toggled(bool)), SLOT(setValue(bool)) ); + connect( m_lab, SIGNAL(enter()), SLOT(help()) ); + connect( m_lab, SIGNAL(reset()), SLOT(reset()) ); + row++; +} + +void InputBool::help() +{ + showHelp(this); +} + +void InputBool::setEnabled(bool b) +{ + m_enabled = b; + m_cb->setEnabled(b); + updateDependencies(); +} + +void InputBool::updateDependencies() +{ + for (int i=0;i<m_dependencies.count();i++) + { + m_dependencies[i]->setEnabled(m_enabled && m_state); + } +} + +void InputBool::setValue( bool s ) +{ + if (m_state!=s) + { + m_state=s; + updateDefault(); + updateDependencies(); + m_cb->setChecked( s ); + m_value = m_state; + emit changed(); + } +} + +void InputBool::updateDefault() +{ + if (m_state==m_default) + { + m_lab->setText(QString::fromAscii("<qt>")+m_id+QString::fromAscii("</qt")); + } + else + { + m_lab->setText(QString::fromAscii("<qt><font color='red'>")+m_id+QString::fromAscii("</font></qt>")); + } +} + +QVariant &InputBool::value() +{ + return m_value; +} + +void InputBool::update() +{ + QString v = m_value.toString().toLower(); + m_state = (v==QString::fromAscii("yes") || + v==QString::fromAscii("true") || + v==QString::fromAscii("1")); + m_cb->setChecked( m_state ); + updateDefault(); + updateDependencies(); +} + +void InputBool::reset() +{ + setValue(m_default); +} + +void InputBool::writeValue(QTextStream &t,QTextCodec *codec) +{ + if (m_state) + t << codec->fromUnicode(QString::fromAscii("YES")); + else + t << codec->fromUnicode(QString::fromAscii("NO")); +} + diff --git a/trunk/addon/doxywizard/inputbool.h b/trunk/addon/doxywizard/inputbool.h new file mode 100644 index 0000000..5ec8998 --- /dev/null +++ b/trunk/addon/doxywizard/inputbool.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _INPUTBOOL_H +#define _INPUTBOOL_H + +#include "input.h" +#include <QObject> + +class QCheckBox; +class QGridLayout; +class QLabel; + +class InputBool : public QObject, public Input +{ + Q_OBJECT + + public: + InputBool(QGridLayout *layout,int &row,const QString &id, + bool enabled, const QString &docs ); + + // Input + QVariant &value(); + void update(); + Kind kind() const { return Bool; } + QString docs() const { return m_docs; } + QString id() const { return m_id; } + void addDependency(Input *option) { m_dependencies+=option; } + void setEnabled(bool); + void updateDependencies(); + void writeValue(QTextStream &t,QTextCodec *codec); + + public slots: + void reset(); + void setValue(bool); + + signals: + void changed(); + void toggle(QString,bool); + void showHelp(Input *); + + private slots: + void help(); + + private: + void updateDefault(); + bool m_state; + bool m_default; + bool m_enabled; + QVariant m_value; + QCheckBox *m_cb; + QString m_docs; + QList<Input*> m_dependencies; + QString m_id; + QLabel *m_lab; + +}; + +#endif diff --git a/trunk/addon/doxywizard/inputint.cpp b/trunk/addon/doxywizard/inputint.cpp new file mode 100644 index 0000000..cb9846b --- /dev/null +++ b/trunk/addon/doxywizard/inputint.cpp @@ -0,0 +1,96 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "inputint.h" +#include "helplabel.h" + +#include <QtGui> + +InputInt::InputInt( QGridLayout *layout,int &row, + const QString & id, + int defVal, int minVal,int maxVal, + const QString & docs ) + : m_default(defVal), m_minVal(minVal), m_maxVal(maxVal), m_docs(docs), m_id(id) +{ + m_lab = new HelpLabel(id); + m_sp = new QSpinBox; + m_sp->setMinimum(minVal); + m_sp->setMaximum(maxVal); + m_sp->setSingleStep(1); + m_val=defVal-1; // force update + setValue(defVal); + + layout->addWidget( m_lab, row, 0 ); + layout->addWidget( m_sp, row, 1 ); + + connect(m_sp, SIGNAL(valueChanged(int)), + this, SLOT(setValue(int)) ); + connect( m_lab, SIGNAL(enter()), SLOT(help()) ); + connect( m_lab, SIGNAL(reset()), SLOT(reset()) ); + row++; +} + +void InputInt::help() +{ + showHelp(this); +} + + +void InputInt::setValue(int val) +{ + val = qMax(m_minVal,val); + val = qMin(m_maxVal,val); + if (val!=m_val) + { + m_val = val; + m_sp->setValue(val); + m_value = m_val; + if (m_val==m_default) + { + m_lab->setText(QString::fromAscii("<qt>")+m_id+QString::fromAscii("</qt")); + } + else + { + m_lab->setText(QString::fromAscii("<qt><font color='red'>")+m_id+QString::fromAscii("</font></qt>")); + } + emit changed(); + } +} + +void InputInt::setEnabled(bool state) +{ + m_lab->setEnabled(state); + m_sp->setEnabled(state); +} + +QVariant &InputInt::value() +{ + return m_value; +} + +void InputInt::update() +{ + setValue(m_value.toInt()); +} + +void InputInt::reset() +{ + setValue(m_default); +} + +void InputInt::writeValue(QTextStream &t,QTextCodec *) +{ + t << m_val; +} + diff --git a/trunk/addon/doxywizard/inputint.h b/trunk/addon/doxywizard/inputint.h new file mode 100644 index 0000000..73100ae --- /dev/null +++ b/trunk/addon/doxywizard/inputint.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _INPUTINT_H +#define _INPUTINT_H + +#include "input.h" +#include <QObject> + +class QGridLayout; +class QLabel; +class QSpinBox; + +class InputInt : public QObject, public Input +{ + Q_OBJECT + + public: + InputInt( QGridLayout *layout,int &row, + const QString &id, int defVal, + int minVal, int maxVal, + const QString &docs ); + ~InputInt(){}; + + // Input + QVariant &value(); + void update(); + Kind kind() const { return Int; } + QString docs() const { return m_docs; } + QString id() const { return m_id; } + void addDependency(Input *) { Q_ASSERT(false); } + void setEnabled(bool); + void updateDependencies() {} + void writeValue(QTextStream &t,QTextCodec *codec); + + public slots: + void reset(); + void setValue(int val); + + private slots: + void help(); + + signals: + void changed(); + void showHelp(Input *); + + private: + QLabel *m_lab; + QSpinBox *m_sp; + int m_val; + int m_default; + int m_minVal; + int m_maxVal; + QVariant m_value; + QString m_docs; + QString m_id; +}; + +#endif diff --git a/trunk/addon/doxywizard/inputstring.cpp b/trunk/addon/doxywizard/inputstring.cpp new file mode 100644 index 0000000..7b0aea0 --- /dev/null +++ b/trunk/addon/doxywizard/inputstring.cpp @@ -0,0 +1,191 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "inputstring.h" +#include "helplabel.h" +#include "doxywizard.h" +#include "config.h" + +#include <QtGui> + +InputString::InputString( QGridLayout *layout,int &row, + const QString & id, const QString &s, + StringMode m, const QString &docs ) + : m_default(s), m_sm(m), m_index(0), m_docs(docs), m_id(id) +{ + m_lab = new HelpLabel(id); + if (m==StringFixed) + { + layout->addWidget( m_lab, row, 0 ); + m_com = new QComboBox; + layout->addWidget( m_com, row, 1, 1, 3, Qt::AlignLeft ); + m_le=0; + m_br=0; + row++; + } + else + { + layout->addWidget( m_lab, row, 0 ); + m_le = new QLineEdit; + m_le->setText( s ); + //layout->setColumnMinimumWidth(2,150); + if (m==StringFile || m==StringDir) + { + layout->addWidget( m_le, row, 1 ); + m_br = new QToolBar; + m_br->setIconSize(QSize(24,24)); + if (m==StringFile) + { + QAction *file = m_br->addAction(QIcon(QString::fromAscii(":/images/file.png")),QString(),this,SLOT(browse())); + file->setToolTip(tr("Browse to a file")); + } + else + { + QAction *dir = m_br->addAction(QIcon(QString::fromAscii(":/images/folder.png")),QString(),this,SLOT(browse())); + dir->setToolTip(tr("Browse to a folder")); + } + layout->addWidget( m_br,row,2 ); + } + else + { + layout->addWidget( m_le, row, 1, 1, 2 ); + m_br=0; + } + m_com=0; + row++; + } + + if (m_le) connect( m_le, SIGNAL(textChanged(const QString&)), + this, SLOT(setValue(const QString&)) ); + if (m_com) connect( m_com, SIGNAL(activated(const QString &)), + this, SLOT(setValue(const QString &)) ); + m_str = s+QChar::fromAscii('!'); // force update + setValue(s); + connect( m_lab, SIGNAL(enter()), SLOT(help()) ); + connect( m_lab, SIGNAL(reset()), SLOT(reset()) ); +} + +void InputString::help() +{ + showHelp(this); +} + + +InputString::~InputString() +{ +} + + +void InputString::setValue(const QString &s) +{ + if (m_str!=s) + { + m_str = s; + m_value = m_str; + if (m_str==m_default) + { + m_lab->setText(QString::fromAscii("<qt>")+m_id+QString::fromAscii("</qt")); + } + else + { + m_lab->setText(QString::fromAscii("<qt><font color='red'>")+m_id+QString::fromAscii("</font></qt>")); + } + if (m_le && m_le->text()!=m_str) m_le->setText( m_str ); + emit changed(); + } +} + +void InputString::setEnabled(bool state) +{ + m_lab->setEnabled(state); + if (m_le) m_le->setEnabled(state); + if (m_br) m_br->setEnabled(state); + if (m_com) m_com->setEnabled(state); +} + +void InputString::browse() +{ + QString path = QFileInfo(MainWindow::instance().configFileName()).path(); + if (m_sm==StringFile) + { + QString fileName = QFileDialog::getOpenFileName(&MainWindow::instance(), + tr("Select file"),path); + if (!fileName.isNull()) + { + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + fileName = dir.relativeFilePath(fileName); + } + setValue(fileName); + } + } + else // sm==StringDir + { + QString dirName = QFileDialog::getExistingDirectory(&MainWindow::instance(), + tr("Select directory"),path); + if (!dirName.isNull()) + { + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + dirName = dir.relativeFilePath(dirName); + } + setValue(dirName); + } + } +} + +void InputString::clear() +{ + setValue(QString()); +} + +void InputString::addValue(QString s) +{ + if (m_sm==StringFixed) + { + m_values.append(s); + m_com->addItem(s); + } +} + +void InputString::setDefault() +{ + int index = m_values.indexOf(m_str); + if (index!=-1 && m_com) m_com->setCurrentIndex(index); +} + +QVariant &InputString::value() +{ + return m_value; +} + +void InputString::update() +{ + setValue(m_value.toString().trimmed()); + setDefault(); +} + +void InputString::reset() +{ + setValue(m_default); + setDefault(); +} + +void InputString::writeValue(QTextStream &t,QTextCodec *codec) +{ + writeStringValue(t,codec,m_str); +} + diff --git a/trunk/addon/doxywizard/inputstring.h b/trunk/addon/doxywizard/inputstring.h new file mode 100644 index 0000000..13efb44 --- /dev/null +++ b/trunk/addon/doxywizard/inputstring.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _INPUTSTRING_H +#define _INPUTSTRING_H + +#include "input.h" + +#include <QObject> +#include <QMap> +#include <QStringList> + +class QLabel; +class QLineEdit; +class QToolBar; +class QComboBox; +class QGridLayout; + +class InputString : public QObject, public Input +{ + Q_OBJECT + + public: + enum StringMode { StringFree=0, + StringFile=1, + StringDir=2, + StringFixed=3 + }; + + InputString( QGridLayout *layout,int &row, + const QString &id, const QString &s, + StringMode m, + const QString &docs ); + ~InputString(); + void addValue(QString s); + void setDefault(); + + // Input + QVariant &value(); + void update(); + Kind kind() const { return String; } + QString docs() const { return m_docs; } + QString id() const { return m_id; } + void addDependency(Input *) { Q_ASSERT(false); } + void setEnabled(bool); + void updateDependencies() {} + void writeValue(QTextStream &t,QTextCodec *codec); + + public slots: + void reset(); + void setValue(const QString&); + + signals: + void changed(); + void showHelp(Input *); + + private slots: + void browse(); + void clear(); + void help(); + + private: + QLabel *m_lab; + QLineEdit *m_le; + QToolBar *m_br; + QComboBox *m_com; + QString m_str; + QString m_default; + StringMode m_sm; + QStringList m_values; + int m_index; + QVariant m_value; + QString m_docs; + QString m_id; +}; + +#endif diff --git a/trunk/addon/doxywizard/inputstrlist.cpp b/trunk/addon/doxywizard/inputstrlist.cpp new file mode 100644 index 0000000..d0ebdc7 --- /dev/null +++ b/trunk/addon/doxywizard/inputstrlist.cpp @@ -0,0 +1,254 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#include "inputstrlist.h" +#include "helplabel.h" +#include "doxywizard.h" +#include "config.h" + +#include <QtGui> + +InputStrList::InputStrList( QGridLayout *layout,int &row, + const QString & id, + const QStringList &sl, ListMode lm, + const QString & docs) + : m_default(sl), m_strList(sl), m_docs(docs), m_id(id) +{ + m_lab = new HelpLabel( id ); + + m_le = new QLineEdit; + m_le->clear(); + + QToolBar *toolBar = new QToolBar; + toolBar->setIconSize(QSize(24,24)); + m_add = toolBar->addAction(QIcon(QString::fromAscii(":/images/add.png")),QString(), + this,SLOT(addString())); + m_add->setToolTip(tr("Add item")); + m_del = toolBar->addAction(QIcon(QString::fromAscii(":/images/del.png")),QString(), + this,SLOT(delString())); + m_del->setToolTip(tr("Delete selected item")); + m_upd = toolBar->addAction(QIcon(QString::fromAscii(":/images/refresh.png")),QString(), + this,SLOT(updateString())); + m_upd->setToolTip(tr("Update selected item")); + + m_lb = new QListWidget; + //m_lb->setMinimumSize(400,100); + foreach (QString s, m_strList) m_lb->addItem(s); + + m_brFile=0; + m_brDir=0; + if (lm!=ListString) + { + if (lm&ListFile) + { + m_brFile = toolBar->addAction(QIcon(QString::fromAscii(":/images/file.png")),QString(), + this,SLOT(browseFiles())); + m_brFile->setToolTip(tr("Browse to a file")); + } + if (lm&ListDir) + { + m_brDir = toolBar->addAction(QIcon(QString::fromAscii(":/images/folder.png")),QString(), + this,SLOT(browseDir())); + m_brDir->setToolTip(tr("Browse to a folder")); + } + } + QHBoxLayout *rowLayout = new QHBoxLayout; + rowLayout->addWidget( m_le ); + rowLayout->addWidget( toolBar ); + layout->addWidget( m_lab, row,0 ); + layout->addLayout( rowLayout, row,1,1,2 ); + layout->addWidget( m_lb, row+1,1,1,2 ); + row+=2; + + m_value = m_strList; + + connect(m_le, SIGNAL(returnPressed()), + this, SLOT(addString()) ); + connect(m_lb, SIGNAL(currentTextChanged(const QString &)), + this, SLOT(selectText(const QString &))); + connect( m_lab, SIGNAL(enter()), SLOT(help()) ); + connect( m_lab, SIGNAL(reset()), SLOT(reset()) ); +} + +void InputStrList::help() +{ + showHelp(this); +} + + +void InputStrList::addString() +{ + if (!m_le->text().isEmpty()) + { + m_lb->addItem(m_le->text()); + m_strList.append(m_le->text()); + m_value = m_strList; + updateDefault(); + emit changed(); + m_le->clear(); + } +} + +void InputStrList::delString() +{ + if (m_lb->currentRow()!=-1) + { + int itemIndex = m_lb->currentRow(); + delete m_lb->currentItem(); + m_strList.removeAt(itemIndex); + m_value = m_strList; + updateDefault(); + emit changed(); + } +} + +void InputStrList::updateString() +{ + if (m_lb->currentRow()!=-1 && !m_le->text().isEmpty()) + { + m_lb->currentItem()->setText(m_le->text()); + m_strList.insert(m_lb->currentRow(),m_le->text()); + m_strList.removeAt(m_lb->currentRow()+1); + m_value = m_strList; + updateDefault(); + emit changed(); + } +} + +void InputStrList::selectText(const QString &s) +{ + m_le->setText(s); +} + +void InputStrList::setEnabled(bool state) +{ + m_lab->setEnabled(state); + m_le->setEnabled(state); + m_add->setEnabled(state); + m_del->setEnabled(state); + m_upd->setEnabled(state); + m_lb->setEnabled(state); + if (m_brFile) m_brFile->setEnabled(state); + if (m_brDir) m_brDir->setEnabled(state); +} + +void InputStrList::browseFiles() +{ + QString path = QFileInfo(MainWindow::instance().configFileName()).path(); + QStringList fileNames = QFileDialog::getOpenFileNames(); + + if (!fileNames.isEmpty()) + { + QStringList::Iterator it; + for ( it= fileNames.begin(); it != fileNames.end(); ++it ) + { + QString fileName; + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + fileName = dir.relativeFilePath(*it); + } + if (fileName.isEmpty()) + { + fileName = *it; + } + m_lb->addItem(fileName); + m_strList.append(fileName); + m_value = m_strList; + updateDefault(); + emit changed(); + } + m_le->setText(m_strList[0]); + } +} + +void InputStrList::browseDir() +{ + QString path = QFileInfo(MainWindow::instance().configFileName()).path(); + QString dirName = QFileDialog::getExistingDirectory(); + + if (!dirName.isNull()) + { + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + dirName = dir.relativeFilePath(dirName); + } + if (dirName.isEmpty()) + { + dirName=QString::fromAscii("."); + } + m_lb->addItem(dirName); + m_strList.append(dirName); + m_value = m_strList; + updateDefault(); + emit changed(); + m_le->setText(dirName); + } +} + +void InputStrList::setValue(const QStringList &sl) +{ + m_le->clear(); + m_lb->clear(); + m_strList = sl; + for (int i=0;i<m_strList.size();i++) + { + m_lb->addItem(m_strList[i].trimmed()); + } + updateDefault(); +} + +QVariant &InputStrList::value() +{ + return m_value; +} + +void InputStrList::update() +{ + setValue(m_value.toStringList()); +} + +void InputStrList::updateDefault() +{ + if (m_strList==m_default) + { + m_lab->setText(QString::fromAscii("<qt>")+m_id+QString::fromAscii("</qt")); + } + else + { + m_lab->setText(QString::fromAscii("<qt><font color='red'>")+m_id+QString::fromAscii("</font></qt>")); + } +} + +void InputStrList::reset() +{ + setValue(m_default); +} + +void InputStrList::writeValue(QTextStream &t,QTextCodec *codec) +{ + bool first=TRUE; + foreach (QString s, m_strList) + { + if (!first) + { + t << " \\" << endl; + t << " "; + } + first=FALSE; + writeStringValue(t,codec,s); + } +} + diff --git a/trunk/addon/doxywizard/inputstrlist.h b/trunk/addon/doxywizard/inputstrlist.h new file mode 100644 index 0000000..912f441 --- /dev/null +++ b/trunk/addon/doxywizard/inputstrlist.h @@ -0,0 +1,91 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef _INPUTSTRLIST_H +#define _INPUTSTRLIST_H + +#include "input.h" + +#include <QObject> +#include <QStringList> + +class QLabel; +class QLineEdit; +class QPushButton; +class QListWidget; +class QStringList; +class QGridLayout; +class QAction; + +class InputStrList : public QObject, public Input +{ + Q_OBJECT + + public: + enum ListMode { ListString = 0, + ListFile = 1, + ListDir = 2, + ListFileDir = ListFile | ListDir + }; + + InputStrList( QGridLayout *layout,int &row, + const QString &id, const QStringList &sl, + ListMode v, const QString &docs); + void setValue(const QStringList &sl); + + QVariant &value(); + void update(); + Kind kind() const { return StrList; } + QString docs() const { return m_docs; } + QString id() const { return m_id; } + void addDependency(Input *) { Q_ASSERT(false); } + void setEnabled(bool); + void updateDependencies() {} + void writeValue(QTextStream &t,QTextCodec *codec); + + public slots: + void reset(); + + signals: + void changed(); + void showHelp(Input *); + + private slots: + void addString(); + void delString(); + void updateString(); + void selectText(const QString &s); + void browseFiles(); + void browseDir(); + void help(); + + private: + void updateDefault(); + QLabel *m_lab; + QLineEdit *m_le; + QAction *m_add; + QAction *m_del; + QAction *m_upd; + QAction *m_brFile; + QAction *m_brDir; + QListWidget *m_lb; + QStringList m_default; + QStringList m_strList; + QVariant m_value; + QString m_docs; + QString m_id; + +}; + +#endif diff --git a/trunk/addon/doxywizard/version.h b/trunk/addon/doxywizard/version.h new file mode 100644 index 0000000..a040af7 --- /dev/null +++ b/trunk/addon/doxywizard/version.h @@ -0,0 +1,23 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + * Documents produced by Doxygen are derivative works derived from the + * input used in their production; they are not affected by this license. + * + */ + +#ifndef VERSION_H +#define VERSION_H + +extern char versionString[]; + +#endif diff --git a/trunk/addon/doxywizard/wizard.cpp b/trunk/addon/doxywizard/wizard.cpp new file mode 100644 index 0000000..7346bd2 --- /dev/null +++ b/trunk/addon/doxywizard/wizard.cpp @@ -0,0 +1,896 @@ +#include "wizard.h" +#include "input.h" +#include "doxywizard.h" + +#include <QtGui> + +// step1 options +#define STR_PROJECT_NAME QString::fromAscii("PROJECT_NAME") +#define STR_INPUT QString::fromAscii("INPUT") +#define STR_OUTPUT_DIRECTORY QString::fromAscii("OUTPUT_DIRECTORY") +#define STR_PROJECT_NUMBER QString::fromAscii("PROJECT_NUMBER") +#define STR_RECURSIVE QString::fromAscii("RECURSIVE") +#define STR_OPTIMIZE_OUTPUT_FOR_C QString::fromAscii("OPTIMIZE_OUTPUT_FOR_C") +#define STR_OPTIMIZE_OUTPUT_JAVA QString::fromAscii("OPTIMIZE_OUTPUT_JAVA") +#define STR_OPTIMIZE_FOR_FORTRAN QString::fromAscii("OPTIMIZE_FOR_FORTRAN") +#define STR_OPTIMIZE_OUTPUT_VHDL QString::fromAscii("OPTIMIZE_OUTPUT_VHDL") +#define STR_CPP_CLI_SUPPORT QString::fromAscii("CPP_CLI_SUPPORT") +#define STR_HIDE_SCOPE_NAMES QString::fromAscii("HIDE_SCOPE_NAMES") +#define STR_EXTRACT_ALL QString::fromAscii("EXTRACT_ALL") +#define STR_SOURCE_BROWSER QString::fromAscii("SOURCE_BROWSER") +#define STR_GENERATE_HTML QString::fromAscii("GENERATE_HTML") +#define STR_GENERATE_LATEX QString::fromAscii("GENERATE_LATEX") +#define STR_GENERATE_MAN QString::fromAscii("GENERATE_MAN") +#define STR_GENERATE_RTF QString::fromAscii("GENERATE_RTF") +#define STR_GENERATE_XML QString::fromAscii("GENERATE_XML") +#define STR_GENERATE_HTMLHELP QString::fromAscii("GENERATE_HTMLHELP") +#define STR_GENERATE_TREEVIEW QString::fromAscii("GENERATE_TREEVIEW") +#define STR_USE_PDFLATEX QString::fromAscii("USE_PDFLATEX") +#define STR_PDF_HYPERLINKS QString::fromAscii("PDF_HYPERLINKS") +#define STR_SEARCHENGINE QString::fromAscii("SEARCHENGINE") +#define STR_HAVE_DOT QString::fromAscii("HAVE_DOT") +#define STR_CLASS_DIAGRAMS QString::fromAscii("CLASS_DIAGRAMS") +#define STR_CLASS_GRAPH QString::fromAscii("CLASS_GRAPH") +#define STR_COLLABORATION_GRAPH QString::fromAscii("COLLABORATION_GRAPH") +#define STR_GRAPHICAL_HIERARCHY QString::fromAscii("GRAPHICAL_HIERARCHY") +#define STR_INCLUDE_GRAPH QString::fromAscii("INCLUDE_GRAPH") +#define STR_INCLUDED_BY_GRAPH QString::fromAscii("INCLUDED_BY_GRAPH") +#define STR_CALL_GRAPH QString::fromAscii("CALL_GRAPH") +#define STR_CALLER_GRAPH QString::fromAscii("CALLER_GRAPH") + + +static bool g_optimizeMapping[6][6] = +{ + // A: OPTIMIZE_OUTPUT_FOR_C + // B: OPTIMIZE_OUTPUT_JAVA + // C: OPTIMIZE_FOR_FORTRAN + // D: OPTIMIZE_OUTPUT_VHDL + // E: CPP_CLI_SUPPORT + // F: HIDE_SCOPE_NAMES + // A B C D E F + { false,false,false,false,false,false }, // 0: C++ + { false,false,false,false,true, false }, // 1: C++/CLI + { false,true, false,false,false,false }, // 2: C#/Java + { true, false,false,false,false,true }, // 3: C/PHP + { false,false,true, false,false,false }, // 4: Fortran + { false,false,false,true, false,false }, // 5: VHDL +}; + +static QString g_optimizeOptionNames[6] = +{ + STR_OPTIMIZE_OUTPUT_FOR_C, + STR_OPTIMIZE_OUTPUT_JAVA, + STR_OPTIMIZE_FOR_FORTRAN, + STR_OPTIMIZE_OUTPUT_VHDL, + STR_CPP_CLI_SUPPORT, + STR_HIDE_SCOPE_NAMES +}; + +//========================================================================== + +static bool stringVariantToBool(const QVariant &v) +{ + QString s = v.toString().toLower(); + return s==QString::fromAscii("yes") || s==QString::fromAscii("true") || s==QString::fromAscii("1"); +} + +static bool getBoolOption( + const QHash<QString,Input*>&model,const QString &name) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + return stringVariantToBool(option->value()); +} + +static QString getStringOption( + const QHash<QString,Input*>&model,const QString &name) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + return option->value().toString(); +} + +static void updateBoolOption( + const QHash<QString,Input*>&model,const QString &name,bool bNew) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + bool bOld = stringVariantToBool(option->value()); + if (bOld!=bNew) + { + option->value()=QString::fromAscii(bNew ? "true" : "false"); + option->update(); + } +} + +static void updateStringOption( + const QHash<QString,Input*>&model,const QString &name,const QString &s) +{ + Input *option = model[name]; + Q_ASSERT(option!=0); + if (option->value().toString()!=s) + { + option->value() = s; + option->update(); + } +} + +//========================================================================== + +Step1::Step1(Wizard *wizard,const QHash<QString,Input*> &modelData) : m_wizard(wizard), m_modelData(modelData) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(4); + layout->setSpacing(8); + QLabel *l = new QLabel(this); + l->setText(tr("Provide some information " + "about the project you are documenting")); + layout->addWidget(l); + QWidget *w = new QWidget( this ); + QHBoxLayout *bl = new QHBoxLayout(w); + bl->setSpacing(10); + + QWidget *col1 = new QWidget; + QVBoxLayout *col1Layout = new QVBoxLayout(col1); + col1Layout->setSpacing(8); + QLabel *projName = new QLabel(this); + projName->setText(tr("Project name:")); + projName->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + QLabel *projVersion = new QLabel(this); + projVersion->setText(tr("Project version or id:")); + projVersion->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + col1Layout->addWidget(projName); + col1Layout->addWidget(projVersion); + + QWidget *col2 = new QWidget; + QVBoxLayout *col2Layout = new QVBoxLayout(col2); + col2Layout->setSpacing(8); + m_projName = new QLineEdit; + m_projNumber = new QLineEdit; + col2Layout->addWidget(m_projName); + col2Layout->addWidget(m_projNumber); + + bl->addWidget(col1); + bl->addWidget(col2); + w->setLayout(bl); + + layout->addWidget(w); + + //--------------------------------------------------- + QFrame *f = new QFrame( this ); + f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + layout->addWidget(f); + + l = new QLabel(this); + l->setText(tr("Specify the directory to scan for source code")); + layout->addWidget(l); + QWidget *row = new QWidget; + QHBoxLayout *rowLayout = new QHBoxLayout(row); + rowLayout->setSpacing(10); + l = new QLabel(this); + l->setText(tr("Source code directory:")); + rowLayout->addWidget(l); + m_sourceDir = new QLineEdit; + m_srcSelectDir = new QPushButton(this); + m_srcSelectDir->setText(tr("Select...")); + rowLayout->addWidget(m_sourceDir); + rowLayout->addWidget(m_srcSelectDir); + layout->addWidget(row); + + m_recursive = new QCheckBox(this); + m_recursive->setText(tr("Scan recursively")); + m_recursive->setChecked(TRUE); + layout->addWidget(m_recursive); + + //--------------------------------------------------- + f = new QFrame( this ); + f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + layout->addWidget(f); + + l = new QLabel(this); + l->setText(tr("Specify the directory where doxygen should " + "put the generated documentation")); + layout->addWidget(l); + row = new QWidget; + rowLayout = new QHBoxLayout(row); + rowLayout->setSpacing(10); + l = new QLabel(this); + l->setText(tr("Destination directory:")); + rowLayout->addWidget(l); + m_destDir = new QLineEdit; + m_dstSelectDir = new QPushButton(this); + m_dstSelectDir->setText(tr("Select...")); + rowLayout->addWidget(m_destDir); + rowLayout->addWidget(m_dstSelectDir); + layout->addWidget(row); + layout->addStretch(1); + setLayout(layout); + + connect(m_srcSelectDir,SIGNAL(clicked()), + this,SLOT(selectSourceDir())); + connect(m_dstSelectDir,SIGNAL(clicked()), + this,SLOT(selectDestinationDir())); + connect(m_projName,SIGNAL(textChanged(const QString &)),SLOT(setProjectName(const QString &))); + connect(m_projNumber,SIGNAL(textChanged(const QString &)),SLOT(setProjectNumber(const QString &))); + connect(m_sourceDir,SIGNAL(textChanged(const QString &)),SLOT(setSourceDir(const QString &))); + connect(m_recursive,SIGNAL(stateChanged(int)),SLOT(setRecursiveScan(int))); + connect(m_destDir,SIGNAL(textChanged(const QString &)),SLOT(setDestinationDir(const QString &))); +} + +void Step1::selectSourceDir() +{ + QString path = QFileInfo(MainWindow::instance().configFileName()).path(); + QString dirName = QFileDialog::getExistingDirectory(this, + tr("Select source directory"),path); + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + dirName = dir.relativeFilePath(dirName); + } + if (dirName.isEmpty()) + { + dirName=QString::fromAscii("."); + } + m_sourceDir->setText(dirName); +} + +void Step1::selectDestinationDir() +{ + QString path = QFileInfo(MainWindow::instance().configFileName()).path(); + QString dirName = QFileDialog::getExistingDirectory(this, + tr("Select destination directory"),path); + QDir dir(path); + if (!MainWindow::instance().configFileName().isEmpty() && dir.exists()) + { + dirName = dir.relativeFilePath(dirName); + } + if (dirName.isEmpty()) + { + dirName=QString::fromAscii("."); + } + m_destDir->setText(dirName); +} + +void Step1::setProjectName(const QString &name) +{ + updateStringOption(m_modelData,STR_PROJECT_NAME,name); +} + +void Step1::setProjectNumber(const QString &num) +{ + updateStringOption(m_modelData,STR_PROJECT_NUMBER,num); +} + +void Step1::setSourceDir(const QString &dir) +{ + Input *option = m_modelData[STR_INPUT]; + if (option->value().toStringList().count()>0) + { + QStringList sl = option->value().toStringList(); + if (sl[0]!=dir) + { + sl[0] = dir; + option->value() = sl; + option->update(); + } + } + else + { + option->value() = QStringList() << dir; + option->update(); + } +} + +void Step1::setDestinationDir(const QString &dir) +{ + updateStringOption(m_modelData,STR_OUTPUT_DIRECTORY,dir); +} + +void Step1::setRecursiveScan(int s) +{ + updateBoolOption(m_modelData,STR_RECURSIVE,s==Qt::Checked); +} + +void Step1::init() +{ + Input *option; + m_projName->setText(getStringOption(m_modelData,STR_PROJECT_NAME)); + m_projNumber->setText(getStringOption(m_modelData,STR_PROJECT_NUMBER)); + option = m_modelData[STR_INPUT]; + if (option->value().toStringList().count()>0) + { + m_sourceDir->setText(option->value().toStringList().first()); + } + m_recursive->setChecked( + getBoolOption(m_modelData,STR_RECURSIVE) ? Qt::Checked : Qt::Unchecked); + m_destDir->setText(getStringOption(m_modelData,STR_OUTPUT_DIRECTORY)); +} + + +//========================================================================== + +Step2::Step2(Wizard *wizard,const QHash<QString,Input*> &modelData) + : m_wizard(wizard), m_modelData(modelData) +{ + QRadioButton *r; + QVBoxLayout *layout = new QVBoxLayout(this); + + //--------------------------------------------------- + m_extractModeGroup = new QButtonGroup(this); + m_extractMode = new QGroupBox(this); + m_extractMode->setTitle(tr("Select the desired extraction mode:")); + QGridLayout *gbox = new QGridLayout( m_extractMode ); + r = new QRadioButton(tr("Documented entities only")); + r->setChecked(true); + m_extractModeGroup->addButton(r, 0); + gbox->addWidget(r,1,0); + // 1 -> EXTRACT_ALL = NO + r = new QRadioButton(tr("All Entities")); + m_extractModeGroup->addButton(r, 1); + gbox->addWidget(r,2,0); + // 2 -> EXTRACT_ALL = YES + m_crossRef = new QCheckBox(m_extractMode); + m_crossRef->setText(tr("Include cross-referenced source code in the output")); + // m_crossRef -> SOURCE_BROWSER = YES/NO + gbox->addWidget(m_crossRef,3,0); + layout->addWidget(m_extractMode); + + //--------------------------------------------------- + QFrame *f = new QFrame( this ); + f->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + layout->addWidget(f); + + m_optimizeLangGroup = new QButtonGroup(this); + m_optimizeLang = new QGroupBox(this); + m_optimizeLang->setTitle(tr("Select programming language to optimize the results for")); + gbox = new QGridLayout( m_optimizeLang ); + + r = new QRadioButton(m_optimizeLang); + r->setText(tr("Optimize for C++ output")); + r->setChecked(true); + m_optimizeLangGroup->addButton(r, 0); + // 0 -> OPTIMIZE_OUTPUT_FOR_C = NO + // OPTIMIZE_OUTPUT_JAVA = NO + // OPTIMIZE_FOR_FORTRAN = NO + // OPTIMIZE_OUTPUT_VHDL = NO + // CPP_CLI_SUPPORT = NO + // HIDE_SCOPE_NAMES = NO + gbox->addWidget(r,0,0); + r = new QRadioButton(tr("Optimize for C++/CLI output")); + gbox->addWidget(r,1,0); + m_optimizeLangGroup->addButton(r, 1); + // 1 -> OPTIMIZE_OUTPUT_FOR_C = NO + // OPTIMIZE_OUTPUT_JAVA = NO + // OPTIMIZE_FOR_FORTRAN = NO + // OPTIMIZE_OUTPUT_VHDL = NO + // CPP_CLI_SUPPORT = YES + // HIDE_SCOPE_NAMES = NO + r = new QRadioButton(tr("Optimize for Java or C# output")); + m_optimizeLangGroup->addButton(r, 2); + // 2 -> OPTIMIZE_OUTPUT_FOR_C = NO + // OPTIMIZE_OUTPUT_JAVA = YES + // OPTIMIZE_FOR_FORTRAN = NO + // OPTIMIZE_OUTPUT_VHDL = NO + // CPP_CLI_SUPPORT = NO + // HIDE_SCOPE_NAMES = NO + gbox->addWidget(r,2,0); + r = new QRadioButton(tr("Optimize for C or PHP output")); + m_optimizeLangGroup->addButton(r, 3); + // 3 -> OPTIMIZE_OUTPUT_FOR_C = YES + // OPTIMIZE_OUTPUT_JAVA = NO + // OPTIMIZE_FOR_FORTRAN = NO + // OPTIMIZE_OUTPUT_VHDL = NO + // CPP_CLI_SUPPORT = NO + // HIDE_SCOPE_NAMES = YES + gbox->addWidget(r,3,0); + r = new QRadioButton(tr("Optimize for Fortran output")); + m_optimizeLangGroup->addButton(r, 4); + // 4 -> OPTIMIZE_OUTPUT_FOR_C = NO + // OPTIMIZE_OUTPUT_JAVA = NO + // OPTIMIZE_FOR_FORTRAN = YES + // OPTIMIZE_OUTPUT_VHDL = NO + // CPP_CLI_SUPPORT = NO + // HIDE_SCOPE_NAMES = NO + gbox->addWidget(r,4,0); + r = new QRadioButton(tr("Optimize for VHDL output")); + m_optimizeLangGroup->addButton(r, 5); + // 5 -> OPTIMIZE_OUTPUT_FOR_C = NO + // OPTIMIZE_OUTPUT_JAVA = NO + // OPTIMIZE_FOR_FORTRAN = NO + // OPTIMIZE_OUTPUT_VHDL = YES + // CPP_CLI_SUPPORT = NO + // HIDE_SCOPE_NAMES = NO + gbox->addWidget(r,5,0); + + layout->addWidget(m_optimizeLang); + layout->addStretch(1); + + connect(m_crossRef,SIGNAL(stateChanged(int)), + SLOT(changeCrossRefState(int))); + connect(m_optimizeLangGroup,SIGNAL(buttonClicked(int)), + SLOT(optimizeFor(int))); + connect(m_extractModeGroup,SIGNAL(buttonClicked(int)), + SLOT(extractMode(int))); +} + + +void Step2::optimizeFor(int choice) +{ + for (int i=0;i<6;i++) + { + updateBoolOption(m_modelData, + g_optimizeOptionNames[i], + g_optimizeMapping[choice][i]); + } +} + +void Step2::extractMode(int choice) +{ + updateBoolOption(m_modelData,STR_EXTRACT_ALL,choice==1); +} + +void Step2::changeCrossRefState(int choice) +{ + updateBoolOption(m_modelData,STR_SOURCE_BROWSER,choice==Qt::Checked); +} + +void Step2::init() +{ + m_extractModeGroup->button( + getBoolOption(m_modelData,STR_EXTRACT_ALL) ? 1 : 0)->setChecked(true); + m_crossRef->setChecked(getBoolOption(m_modelData,STR_SOURCE_BROWSER)); + + int x=0; + if (getBoolOption(m_modelData,STR_CPP_CLI_SUPPORT)) x=1; + else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_JAVA)) x=2; + else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_FOR_C)) x=3; + else if (getBoolOption(m_modelData,STR_OPTIMIZE_FOR_FORTRAN)) x=4; + else if (getBoolOption(m_modelData,STR_OPTIMIZE_OUTPUT_VHDL)) x=5; + m_optimizeLangGroup->button(x)->setChecked(true); +} + +//========================================================================== + +Step3::Step3(Wizard *wizard,const QHash<QString,Input*> &modelData) + : m_wizard(wizard), m_modelData(modelData) +{ + QVBoxLayout *vbox = 0; + QRadioButton *r = 0; + + QGridLayout *gbox = new QGridLayout( this ); + gbox->addWidget(new QLabel(tr("Select the output format(s) to generate")),0,0); + { + m_htmlOptions = new QGroupBox(tr("HTML")); + m_htmlOptions->setCheckable(true); + // GENERATE_HTML + m_htmlOptionsGroup = new QButtonGroup(m_htmlOptions); + QRadioButton *r = new QRadioButton(tr("plain HTML")); + r->setChecked(true); + m_htmlOptionsGroup->addButton(r, 0); + vbox = new QVBoxLayout; + vbox->addWidget(r); + r = new QRadioButton(tr("with frames and a navigation tree")); + m_htmlOptionsGroup->addButton(r, 1); + // GENERATE_TREEVIEW + vbox->addWidget(r); + r = new QRadioButton(tr("prepare for compressed HTML (.chm)")); + m_htmlOptionsGroup->addButton(r, 2); + // GENERATE_HTMLHELP + vbox->addWidget(r); + m_searchEnabled=new QCheckBox(tr("With search function (requires PHP enabled web server)")); + vbox->addWidget(m_searchEnabled); + // SEARCH_ENGINE + m_htmlOptions->setLayout(vbox); + m_htmlOptions->setChecked(true); + } + gbox->addWidget(m_htmlOptions,1,0); + + { + m_texOptions = new QGroupBox(tr("LaTeX")); + m_texOptions->setCheckable(true); + // GENERATE_LATEX + m_texOptionsGroup = new QButtonGroup(m_texOptions); + vbox = new QVBoxLayout; + r = new QRadioButton(tr("as intermediate format for hyperlinked PDF")); + m_texOptionsGroup->addButton(r, 0); + // PDF_HYPERLINKS = YES + r->setChecked(true); + vbox->addWidget(r); + r = new QRadioButton(tr("as intermediate format for PDF")); + m_texOptionsGroup->addButton(r, 1); + // PDF_HYPERLINKS = NO, USE_PDFLATEX = YES + vbox->addWidget(r); + r = new QRadioButton(tr("as intermediate format for PostScript")); + m_texOptionsGroup->addButton(r, 2); + // USE_PDFLATEX = NO + vbox->addWidget(r); + vbox->addStretch(1); + m_texOptions->setLayout(vbox); + m_texOptions->setChecked(true); + } + gbox->addWidget(m_texOptions,2,0); + + m_manEnabled=new QCheckBox(tr("Man pages")); + // GENERATE_MAN + m_rtfEnabled=new QCheckBox(tr("Rich Text Format (RTF)")); + // GENERATE_RTF + m_xmlEnabled=new QCheckBox(tr("XML")); + // GENERATE_XML + gbox->addWidget(m_manEnabled,3,0); + gbox->addWidget(m_rtfEnabled,4,0); + gbox->addWidget(m_xmlEnabled,5,0); + + gbox->setRowStretch(6,1); + connect(m_htmlOptions,SIGNAL(toggled(bool)),SLOT(setHtmlEnabled(bool))); + connect(m_texOptions,SIGNAL(toggled(bool)),SLOT(setLatexEnabled(bool))); + connect(m_manEnabled,SIGNAL(stateChanged(int)),SLOT(setManEnabled(int))); + connect(m_rtfEnabled,SIGNAL(stateChanged(int)),SLOT(setRtfEnabled(int))); + connect(m_xmlEnabled,SIGNAL(stateChanged(int)),SLOT(setXmlEnabled(int))); + connect(m_searchEnabled,SIGNAL(stateChanged(int)),SLOT(setSearchEnabled(int))); + connect(m_htmlOptionsGroup,SIGNAL(buttonClicked(int)), + SLOT(setHtmlOptions(int))); + connect(m_texOptionsGroup,SIGNAL(buttonClicked(int)), + SLOT(setLatexOptions(int))); +} + +void Step3::setHtmlEnabled(bool b) +{ + updateBoolOption(m_modelData,STR_GENERATE_HTML,b); +} + +void Step3::setLatexEnabled(bool b) +{ + updateBoolOption(m_modelData,STR_GENERATE_LATEX,b); +} + +void Step3::setManEnabled(int state) +{ + updateBoolOption(m_modelData,STR_GENERATE_MAN,state==Qt::Checked); +} + +void Step3::setRtfEnabled(int state) +{ + updateBoolOption(m_modelData,STR_GENERATE_RTF,state==Qt::Checked); +} + +void Step3::setXmlEnabled(int state) +{ + updateBoolOption(m_modelData,STR_GENERATE_XML,state==Qt::Checked); +} + +void Step3::setSearchEnabled(int state) +{ + updateBoolOption(m_modelData,STR_SEARCHENGINE,state==Qt::Checked); +} + +void Step3::setHtmlOptions(int id) +{ + if (id==0) // plain HTML + { + updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,false); + updateStringOption(m_modelData,STR_GENERATE_TREEVIEW,QString::fromAscii("NONE")); + } + else if (id==1) // with navigation tree + { + updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,false); + updateStringOption(m_modelData,STR_GENERATE_TREEVIEW,QString::fromAscii("ALL")); + } + else if (id==2) // with compiled help + { + updateBoolOption(m_modelData,STR_GENERATE_HTMLHELP,true); + updateStringOption(m_modelData,STR_GENERATE_TREEVIEW,QString::fromAscii("NONE")); + } +} + +void Step3::setLatexOptions(int id) +{ + if (id==0) // hyperlinked PDF + { + updateBoolOption(m_modelData,STR_USE_PDFLATEX,true); + updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,true); + } + else if (id==1) // PDF + { + updateBoolOption(m_modelData,STR_USE_PDFLATEX,true); + updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,false); + } + else if (id==2) // PostScript + { + updateBoolOption(m_modelData,STR_USE_PDFLATEX,false); + updateBoolOption(m_modelData,STR_PDF_HYPERLINKS,false); + } +} + +void Step3::init() +{ + m_htmlOptions->setChecked(getBoolOption(m_modelData,STR_GENERATE_HTML)); + m_texOptions->setChecked(getBoolOption(m_modelData,STR_GENERATE_LATEX)); + m_manEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_MAN)); + m_rtfEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_RTF)); + m_xmlEnabled->setChecked(getBoolOption(m_modelData,STR_GENERATE_XML)); + m_searchEnabled->setChecked(getBoolOption(m_modelData,STR_SEARCHENGINE)); + if (getBoolOption(m_modelData,STR_GENERATE_HTMLHELP)) + { + m_htmlOptionsGroup->button(2)->setChecked(true); // compiled help + } + else if (getBoolOption(m_modelData,STR_GENERATE_TREEVIEW)) + { + m_htmlOptionsGroup->button(1)->setChecked(true); // navigation tree + } + else + { + m_htmlOptionsGroup->button(0)->setChecked(true); // plain HTML + } + if (!getBoolOption(m_modelData,STR_USE_PDFLATEX)) + { + m_texOptionsGroup->button(2)->setChecked(true); // PostScript + } + else if (!getBoolOption(m_modelData,STR_PDF_HYPERLINKS)) + { + m_texOptionsGroup->button(1)->setChecked(true); // Plain PDF + } + else + { + m_texOptionsGroup->button(0)->setChecked(true); // PDF with hyperlinks + } +} + +//========================================================================== + +Step4::Step4(Wizard *wizard,const QHash<QString,Input*> &modelData) + : m_wizard(wizard), m_modelData(modelData) +{ + m_diagramModeGroup = new QButtonGroup(this); + QGridLayout *gbox = new QGridLayout( this ); + gbox->addWidget(new QLabel(tr("Diagrams to generate")),0,0); + + QRadioButton *rb = new QRadioButton(tr("No diagrams")); + m_diagramModeGroup->addButton(rb, 0); + gbox->addWidget(rb,1,0); + // CLASS_DIAGRAMS = NO, HAVE_DOT = NO + rb->setChecked(true); + rb = new QRadioButton(tr("Use built-in class diagram generator")); + m_diagramModeGroup->addButton(rb, 1); + // CLASS_DIAGRAMS = YES, HAVE_DOT = NO + gbox->addWidget(rb,2,0); + rb = new QRadioButton(tr("Use dot tool from the GraphViz package")); + m_diagramModeGroup->addButton(rb, 2); + gbox->addWidget(rb,3,0); + // CLASS_DIAGRAMS = NO, HAVE_DOT = YES + + m_dotGroup = new QGroupBox(tr("Dot graphs to generate")); + QVBoxLayout *vbox = new QVBoxLayout; + m_dotClass=new QCheckBox(tr("Class diagrams")); + // CLASS_GRAPH + m_dotCollaboration=new QCheckBox(tr("Collaboration diagrams")); + // COLLABORATION_GRAPH + m_dotInheritance=new QCheckBox(tr("Overall Class hierarchy")); + // GRAPHICAL_HIERARCHY + m_dotInclude=new QCheckBox(tr("Include dependency graphs")); + // INCLUDE_GRAPH + m_dotIncludedBy=new QCheckBox(tr("Included by dependency graphs")); + // INCLUDED_BY_GRAPH + m_dotCall=new QCheckBox(tr("Call graphs")); + // CALL_GRAPH + m_dotCaller=new QCheckBox(tr("Called by graphs")); + // CALLER_GRAPH + vbox->addWidget(m_dotClass); + vbox->addWidget(m_dotCollaboration); + vbox->addWidget(m_dotInheritance); + vbox->addWidget(m_dotInclude); + vbox->addWidget(m_dotIncludedBy); + vbox->addWidget(m_dotCall); + vbox->addWidget(m_dotCaller); + vbox->addStretch(1); + m_dotGroup->setLayout(vbox); + m_dotClass->setChecked(true); + m_dotGroup->setEnabled(false); + gbox->addWidget(m_dotGroup,4,0); + + m_dotInclude->setChecked(true); + m_dotCollaboration->setChecked(true); + gbox->setRowStretch(5,1); + + connect(m_diagramModeGroup,SIGNAL(buttonClicked(int)), + this,SLOT(diagramModeChanged(int))); + connect(m_dotClass,SIGNAL(stateChanged(int)), + this,SLOT(setClassGraphEnabled(int))); + connect(m_dotCollaboration,SIGNAL(stateChanged(int)), + this,SLOT(setCollaborationGraphEnabled(int))); + connect(m_dotInheritance,SIGNAL(stateChanged(int)), + this,SLOT(setGraphicalHierarchyEnabled(int))); + connect(m_dotInclude,SIGNAL(stateChanged(int)), + this,SLOT(setIncludeGraphEnabled(int))); + connect(m_dotIncludedBy,SIGNAL(stateChanged(int)), + this,SLOT(setIncludedByGraphEnabled(int))); + connect(m_dotCall,SIGNAL(stateChanged(int)), + this,SLOT(setCallGraphEnabled(int))); + connect(m_dotCaller,SIGNAL(stateChanged(int)), + this,SLOT(setCallerGraphEnabled(int))); +} + +void Step4::diagramModeChanged(int id) +{ + if (id==0) // no diagrams + { + updateBoolOption(m_modelData,STR_HAVE_DOT,false); + updateBoolOption(m_modelData,STR_CLASS_DIAGRAMS,false); + } + else if (id==1) // builtin diagrams + { + updateBoolOption(m_modelData,STR_HAVE_DOT,false); + updateBoolOption(m_modelData,STR_CLASS_DIAGRAMS,true); + } + else if (id==2) // dot diagrams + { + updateBoolOption(m_modelData,STR_HAVE_DOT,true); + updateBoolOption(m_modelData,STR_CLASS_DIAGRAMS,false); + } + m_dotGroup->setEnabled(id==2); +} + +void Step4::setClassGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_CLASS_GRAPH,state==Qt::Checked); +} + +void Step4::setCollaborationGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_COLLABORATION_GRAPH,state==Qt::Checked); +} + +void Step4::setGraphicalHierarchyEnabled(int state) +{ + updateBoolOption(m_modelData,STR_GRAPHICAL_HIERARCHY,state==Qt::Checked); +} + +void Step4::setIncludeGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_INCLUDE_GRAPH,state==Qt::Checked); +} + +void Step4::setIncludedByGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_INCLUDED_BY_GRAPH,state==Qt::Checked); +} + +void Step4::setCallGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_CALL_GRAPH,state==Qt::Checked); +} + +void Step4::setCallerGraphEnabled(int state) +{ + updateBoolOption(m_modelData,STR_CALLER_GRAPH,state==Qt::Checked); +} + +void Step4::init() +{ + if (getBoolOption(m_modelData,STR_HAVE_DOT)) + { + m_diagramModeGroup->button(2)->setChecked(true); // Dot + } + else if (getBoolOption(m_modelData,STR_CLASS_DIAGRAMS)) + { + m_diagramModeGroup->button(1)->setChecked(true); // Builtin diagrams + } + else + { + m_diagramModeGroup->button(0)->setChecked(true); // no diagrams + } + m_dotClass->setChecked(getBoolOption(m_modelData,STR_CLASS_GRAPH)); + m_dotCollaboration->setChecked(getBoolOption(m_modelData,STR_COLLABORATION_GRAPH)); + m_dotInheritance->setChecked(getBoolOption(m_modelData,STR_GRAPHICAL_HIERARCHY)); + m_dotInclude->setChecked(getBoolOption(m_modelData,STR_INCLUDE_GRAPH)); + m_dotIncludedBy->setChecked(getBoolOption(m_modelData,STR_INCLUDED_BY_GRAPH)); + m_dotCall->setChecked(getBoolOption(m_modelData,STR_CALL_GRAPH)); + m_dotCaller->setChecked(getBoolOption(m_modelData,STR_CALLER_GRAPH)); +} + +//========================================================================== + +Wizard::Wizard(const QHash<QString,Input*> &modelData, QWidget *parent) : + QSplitter(parent), m_modelData(modelData) +{ + m_treeWidget = new QTreeWidget; + m_treeWidget->setColumnCount(1); + m_treeWidget->setHeaderLabels(QStringList() << QString::fromAscii("Topics")); + QList<QTreeWidgetItem*> items; + items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(tr("Project")))); + items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(tr("Mode")))); + items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(tr("Output")))); + items.append(new QTreeWidgetItem((QTreeWidget*)0,QStringList(tr("Diagrams")))); + m_treeWidget->insertTopLevelItems(0,items); + + m_topicStack = new QStackedWidget; + m_step1 = new Step1(this,modelData); + m_step2 = new Step2(this,modelData); + m_step3 = new Step3(this,modelData); + m_step4 = new Step4(this,modelData); + m_topicStack->addWidget(m_step1); + m_topicStack->addWidget(m_step2); + m_topicStack->addWidget(m_step3); + m_topicStack->addWidget(m_step4); + + QWidget *rightSide = new QWidget; + QGridLayout *grid = new QGridLayout(rightSide); + m_prev = new QPushButton(tr("Previous")); + m_prev->setEnabled(false); + m_next = new QPushButton(tr("Next")); + grid->addWidget(m_topicStack,0,0,1,2); + grid->addWidget(m_prev,1,0,Qt::AlignLeft); + grid->addWidget(m_next,1,1,Qt::AlignRight); + grid->setColumnStretch(0,1); + grid->setRowStretch(0,1); + addWidget(m_treeWidget); + addWidget(rightSide); + + connect(m_treeWidget, + SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)), + SLOT(activateTopic(QTreeWidgetItem *,QTreeWidgetItem *))); + connect(m_next,SIGNAL(clicked()),SLOT(nextTopic())); + connect(m_prev,SIGNAL(clicked()),SLOT(prevTopic())); + + refresh(); +} + +Wizard::~Wizard() +{ +} + +void Wizard::activateTopic(QTreeWidgetItem *item,QTreeWidgetItem *) +{ + if (item) + { + + QString label = item->text(0); + if (label==tr("Project")) + { + m_topicStack->setCurrentWidget(m_step1); + m_prev->setEnabled(false); + m_next->setEnabled(true); + } + else if (label==tr("Mode")) + { + m_topicStack->setCurrentWidget(m_step2); + m_prev->setEnabled(true); + m_next->setEnabled(true); + } + else if (label==tr("Output")) + { + m_topicStack->setCurrentWidget(m_step3); + m_prev->setEnabled(true); + m_next->setEnabled(true); + } + else if (label==tr("Diagrams")) + { + m_topicStack->setCurrentWidget(m_step4); + m_prev->setEnabled(true); + m_next->setEnabled(false); + } + } +} + +void Wizard::nextTopic() +{ + m_topicStack->setCurrentIndex(m_topicStack->currentIndex()+1); + m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1); + m_prev->setEnabled(m_topicStack->currentIndex()!=0); + m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex())); +} + +void Wizard::prevTopic() +{ + m_topicStack->setCurrentIndex(m_topicStack->currentIndex()-1); + m_next->setEnabled(m_topicStack->count()!=m_topicStack->currentIndex()+1); + m_prev->setEnabled(m_topicStack->currentIndex()!=0); + m_treeWidget->setCurrentItem(m_treeWidget->invisibleRootItem()->child(m_topicStack->currentIndex())); +} + +void Wizard::refresh() +{ + m_step1->init(); + m_step2->init(); + m_step3->init(); + m_step4->init(); +} diff --git a/trunk/addon/doxywizard/wizard.h b/trunk/addon/doxywizard/wizard.h new file mode 100644 index 0000000..d482db9 --- /dev/null +++ b/trunk/addon/doxywizard/wizard.h @@ -0,0 +1,182 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2007 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 + * for any purpose. It is provided "as is" without express or implied warranty. + * See the GNU General Public License for more details. + * + */ + +#ifndef WIZARD_H +#define WIZARD_H + +#include <QSplitter> +#include <QHash> + +class Input; +class QTreeWidget; +class QTreeWidgetItem; +class QStackedWidget; +class QCheckBox; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QGroupBox; +class QButtonGroup; +class Wizard; + +enum OptLang { Lang_Cpp, Lang_C, Lang_Java, Lang_CS }; +enum HtmlStyle { HS_Plain, HS_TreeView, HS_CHM }; +enum TexStyle { TS_PDFHyper, TS_PDF, TS_PS }; +enum DiagramMode { DM_None, DM_Builtin, DM_Dot }; + +class Step1 : public QWidget +{ + Q_OBJECT + + public: + Step1(Wizard *parent,const QHash<QString,Input*> &modelData); + void init(); + + private slots: + void selectSourceDir(); + void selectDestinationDir(); + void setProjectName(const QString &name); + void setProjectNumber(const QString &num); + void setSourceDir(const QString &dir); + void setDestinationDir(const QString &dir); + void setRecursiveScan(int); + + private: + QLineEdit *m_projName; + QLineEdit *m_projNumber; + QLineEdit *m_sourceDir; + QLineEdit *m_destDir; + QCheckBox *m_recursive; + QPushButton *m_srcSelectDir; + QPushButton *m_dstSelectDir; + Wizard *m_wizard; + const QHash<QString,Input *> &m_modelData; +}; + +class Step2 : public QWidget +{ + Q_OBJECT + public: + Step2(Wizard *parent,const QHash<QString,Input*> &modelData); + void init(); + + private slots: + void optimizeFor(int choice); + void extractMode(int choice); + void changeCrossRefState(int choice); + + private: + QGroupBox *m_extractMode; + QGroupBox *m_optimizeLang; + QButtonGroup *m_extractModeGroup; + QButtonGroup *m_optimizeLangGroup; + QCheckBox *m_crossRef; + Wizard *m_wizard; + const QHash<QString,Input *> &m_modelData; +}; + +class Step3 : public QWidget +{ + Q_OBJECT + + public: + Step3(Wizard *parent,const QHash<QString,Input*> &modelData); + void init(); + + private slots: + void setHtmlEnabled(bool); + void setLatexEnabled(bool); + void setManEnabled(int); + void setRtfEnabled(int); + void setXmlEnabled(int); + void setSearchEnabled(int); + void setHtmlOptions(int); + void setLatexOptions(int); + + private: + QGroupBox *m_texOptions; + QButtonGroup *m_texOptionsGroup; + QGroupBox *m_htmlOptions; + QButtonGroup *m_htmlOptionsGroup; + QCheckBox *m_htmlEnabled; + QCheckBox *m_latexEnabled; + QCheckBox *m_manEnabled; + QCheckBox *m_rtfEnabled; + QCheckBox *m_xmlEnabled; + QCheckBox *m_searchEnabled; + Wizard *m_wizard; + const QHash<QString,Input *> &m_modelData; +}; + +class Step4 : public QWidget +{ + Q_OBJECT + + public: + Step4(Wizard *parent,const QHash<QString,Input*> &modelData); + void init(); + + private slots: + void diagramModeChanged(int); + void setClassGraphEnabled(int state); + void setCollaborationGraphEnabled(int state); + void setGraphicalHierarchyEnabled(int state); + void setIncludeGraphEnabled(int state); + void setIncludedByGraphEnabled(int state); + void setCallGraphEnabled(int state); + void setCallerGraphEnabled(int state); + + private: + QGroupBox *m_diagramMode; + QButtonGroup *m_diagramModeGroup; + QGroupBox *m_dotGroup; + QCheckBox *m_dotClass; + QCheckBox *m_dotCollaboration; + QCheckBox *m_dotInclude; + QCheckBox *m_dotIncludedBy; + QCheckBox *m_dotInheritance; + QCheckBox *m_dotCall; + QCheckBox *m_dotCaller; + Wizard *m_wizard; + const QHash<QString,Input *> &m_modelData; +}; + +class Wizard : public QSplitter +{ + Q_OBJECT + public: + Wizard(const QHash<QString,Input*> &modelData, QWidget *parent=0); + ~Wizard(); + + public slots: + void refresh(); + + private slots: + void activateTopic(QTreeWidgetItem *item,QTreeWidgetItem *); + void nextTopic(); + void prevTopic(); + + private: + const QHash<QString,Input *> &m_modelData; + QTreeWidget *m_treeWidget; + QStackedWidget *m_topicStack; + Step1 *m_step1; + Step2 *m_step2; + Step3 *m_step3; + Step4 *m_step4; + QPushButton *m_next; + QPushButton *m_prev; +}; + +#endif |