diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2000-07-30 13:58:29 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2000-07-30 13:58:29 (GMT) |
commit | 3876f92c80e9cc62af30916f0ccdeb83cdc2ff05 (patch) | |
tree | 2d71d4688e381dc8e0c968d120b25fdd0763c27e /addon | |
parent | 7295388a3c6b3a12a77dc7a56862333c97e4ccb6 (diff) | |
download | Doxygen-3876f92c80e9cc62af30916f0ccdeb83cdc2ff05.zip Doxygen-3876f92c80e9cc62af30916f0ccdeb83cdc2ff05.tar.gz Doxygen-3876f92c80e9cc62af30916f0ccdeb83cdc2ff05.tar.bz2 |
Release-1.2.0-20000730
Diffstat (limited to 'addon')
-rw-r--r-- | addon/configgen/config_templ.h | 2 | ||||
-rw-r--r-- | addon/configgen/config_templ.l | 2 | ||||
-rw-r--r-- | addon/configgen/configgen.cpp | 37 | ||||
-rw-r--r-- | addon/configgen/qtbc.h | 2 | ||||
-rw-r--r-- | addon/xmlread/Doxyfile | 142 | ||||
-rw-r--r-- | addon/xmlread/Makefile.in | 12 | ||||
-rw-r--r-- | addon/xmlread/README | 9 | ||||
-rw-r--r-- | addon/xmlread/compounddef.h | 186 | ||||
-rw-r--r-- | addon/xmlread/main.cpp | 133 | ||||
-rw-r--r-- | addon/xmlread/qtbc.h | 45 | ||||
-rw-r--r-- | addon/xmlread/saxhandlers.cpp | 185 | ||||
-rw-r--r-- | addon/xmlread/saxhandlers.h | 101 | ||||
-rw-r--r-- | addon/xmlread/strx.h | 24 | ||||
-rw-r--r-- | addon/xmlread/xmlread.pro.in | 7 |
14 files changed, 884 insertions, 3 deletions
diff --git a/addon/configgen/config_templ.h b/addon/configgen/config_templ.h index f895bab..0d5ac13 100644 --- a/addon/configgen/config_templ.h +++ b/addon/configgen/config_templ.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * $Id$ + * * * Copyright (C) 1997-2000 by Dimitri van Heesch. * diff --git a/addon/configgen/config_templ.l b/addon/configgen/config_templ.l index 6ba22a6..ff570de 100644 --- a/addon/configgen/config_templ.l +++ b/addon/configgen/config_templ.l @@ -1,6 +1,6 @@ /****************************************************************************** * - * $Id$ + * * * Copyright (C) 1997-2000 by Dimitri van Heesch. * diff --git a/addon/configgen/configgen.cpp b/addon/configgen/configgen.cpp index 6521c65..3fd3c1b 100644 --- a/addon/configgen/configgen.cpp +++ b/addon/configgen/configgen.cpp @@ -999,6 +999,22 @@ void init() "The ENABLE_SECTIONS tag can be used to enable conditional \n" "documentation sections, marked by \\if sectionname ... \\endif. \n" ); + ConfigBool::add( "generateTodoList", + "GENERATE_TODOLIST", + "TRUE", + "do we want a todo list?", + "The GENERATE_TODOLIST tag can be used to enable (YES) or \n" + "disable (NO) the todo list. This list is created by putting \\todo \n" + "commands in the documentation.\n" + ); + ConfigBool::add( "generateTestList", + "GENERATE_TESTLIST", + "TRUE", + "do we want a test list?", + "The GENERATE_TESTLIST tag can be used to enable (YES) or \n" + "disable (NO) the test list. This list is created by putting \\test \n" + "commands in the documentation.\n" + ); //----------------------------------------------------------------------------------------------- ConfigInfo::add( "Messages","configuration options related to warning and progress messages"); //----------------------------------------------------------------------------------------------- @@ -1293,6 +1309,15 @@ void init() "This makes the output suitable for online browsing using a pdf viewer. \n" ); addDependency("pdfHyperFlag","generateLatex"); + ConfigBool::add( "usePDFLatexFlag", + "USE_PDFLATEX", + "FALSE", + "use pdflatex instead of plain latex", + "If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of \n" + "plain latex in the generated Makefile. Set this option to YES to get a \n" + "higher quality PDF documentation. \n" + ); + addDependency("usePDFLatexFlag","generateLatex"); ConfigBool::add( "latexBatchModeFlag", "LATEX_BATCHMODE", "FALSE", @@ -1384,6 +1409,18 @@ void init() ); addDependency("manExtension","generateMan"); //----------------------------------------------------------------------------------------------- + ConfigInfo::add( "XML","configuration options related to the XML output"); + //----------------------------------------------------------------------------------------------- + ConfigBool::add( "generateXML", + "GENERATE_XML", + "FALSE", + "generate XML output", + "If the GENERATE_XML tag is set to YES Doxygen will \n" + "generate an XML file that captures the structure of \n" + "the code including all documentation. Warning: This feature \n" + "is still experimental and very incomplete.\n" + ); + //----------------------------------------------------------------------------------------------- ConfigInfo::add( "Preprocessor","Configuration options related to the preprocessor "); //----------------------------------------------------------------------------------------------- ConfigBool::add( "preprocessingFlag", diff --git a/addon/configgen/qtbc.h b/addon/configgen/qtbc.h index d03672f..570bf93 100644 --- a/addon/configgen/qtbc.h +++ b/addon/configgen/qtbc.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * $Id$ + * * * Copyright (C) 1997-2000 by Dimitri van Heesch. * diff --git a/addon/xmlread/Doxyfile b/addon/xmlread/Doxyfile new file mode 100644 index 0000000..fa17d6f --- /dev/null +++ b/addon/xmlread/Doxyfile @@ -0,0 +1,142 @@ +# Doxyfile 1.2.0 + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = xmlread +PROJECT_NUMBER = +OUTPUT_DIRECTORY = doc +OUTPUT_LANGUAGE = English +DISABLE_INDEX = NO +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +INTERNAL_DOCS = NO +CLASS_DIAGRAMS = YES +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +VERBATIM_HEADERS = YES +SHOW_INCLUDE_FILES = YES +JAVADOC_AUTOBRIEF = YES +INHERIT_DOCS = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +TAB_SIZE = 8 +ENABLED_SECTIONS = +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_FORMAT = "$file:$line: $text" +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = . +FILE_PATTERNS = *.h *.cpp +RECURSIVE = NO +EXCLUDE = +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +IMAGE_PATH = +INPUT_FILTER = +#--------------------------------------------------------------------------- +# 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 +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +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 = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = YES +#--------------------------------------------------------------------------- +# 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 = +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DOT_PATH = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO +CGI_NAME = search.cgi +CGI_URL = +DOC_URL = +DOC_ABSPATH = +BIN_ABSPATH = /usr/local/bin/ +EXT_DOC_PATHS = diff --git a/addon/xmlread/Makefile.in b/addon/xmlread/Makefile.in new file mode 100644 index 0000000..ae31a26 --- /dev/null +++ b/addon/xmlread/Makefile.in @@ -0,0 +1,12 @@ +all clean depend: Makefile.xmlread + $(MAKE) -f Makefile.xmlread $@ + +distclean: clean + $(RM) -f Makefile.xmlread + +tmake: + $(PERL) $(TMAKE) xmlread.pro >Makefile.xmlread + +Makefile.xmlread: xmlread.pro + $(PERL) $(TMAKE) xmlread.pro >Makefile.xmlread + diff --git a/addon/xmlread/README b/addon/xmlread/README new file mode 100644 index 0000000..104917d --- /dev/null +++ b/addon/xmlread/README @@ -0,0 +1,9 @@ +This is a small utility that is used to test and validate the +XML output generated by doxygen (when GENERATE_XML = YES). + +It uses the Xerces-C XML parser/validator (see http://xml.apache.org) +and expects the environment variable XERCES_ROOT to point to the root +of the Xerces package. + +Currently is reads an XML file, validates it, and prints the class +hierarchy contained in it. diff --git a/addon/xmlread/compounddef.h b/addon/xmlread/compounddef.h new file mode 100644 index 0000000..95f5b84 --- /dev/null +++ b/addon/xmlread/compounddef.h @@ -0,0 +1,186 @@ +#ifndef COMPOUNDDEF_H +#define COMPOUNDDEF_H + +#include "qtbc.h" +#include <qlist.h> +#include <qdict.h> +#include <qstrlist.h> + +/*! Abstract interface for a compound as presented to the user */ +class CompoundDef +{ + public: + /*! Possible compound types */ + enum Type { Unknown_t, Class_t, Struct_t, Union_t, + File_t, Namespace_t, Group_t, Interface_t }; + /*! Destructor */ + virtual ~CompoundDef() {} + + /*! Returns the name of this compound */ + virtual QCString name() const = 0; + /*! Returns the type of this compound */ + virtual Type type() const = 0; + /*! Returns the unique identifier for this compound */ + virtual QCString id() const = 0; + /*! Returns the list of base compounds from which this compound inherits */ + virtual QList<CompoundDef> *baseCompounds() const = 0; + /*! Returns the list of compounds that derive from this one */ + virtual QList<CompoundDef> *derivedCompounds() const = 0; +}; + +/*! Ordered dictionary of abstract compounds. */ +class CompoundSDict : public QList<CompoundDef> +{ + friend class CompoundSDictIterator; + + public: + /*! Create an ordered dictionary. + * \param size The size of the dictionary. Should be a prime number for + * best distribution of elements. + */ + CompoundSDict(int size) + { + m_list = new QList<CompoundDef>; + m_list->setAutoDelete(TRUE); + m_dict = new QDict<CompoundDef>(size); + } + /*! Destroys the dictionary */ + ~CompoundSDict() + { + delete m_list; + delete m_dict; + } + /*! Appends a compound to the dictionary. The element is owned by the + * dictionary. + * \param key The unique key to use to quicky find the item later on. + * \param d The compound to add. + * \sa find() + */ + void append(const char *key,CompoundDef *d) + { + m_list->append(d); + m_dict->insert(key,d); + } + /*! Looks up a compound given its key. + * \param key The key to identify this element. + * \return The requested compound or zero if it cannot be found. + * \sa append() + */ + CompoundDef *find(const char *key) + { + return m_dict->find(key); + } + + private: + QList<CompoundDef> *m_list; + QDict<CompoundDef> *m_dict; +}; + +/*! Simple iterator for CompoundSDict. It iterates in the order the + * element were appended. + */ +class CompoundSDictIterator +{ + public: + /*! Create an iterator given the dictionary. */ + CompoundSDictIterator(const CompoundSDict &dict) + { + m_li = new QListIterator<CompoundDef>(*dict.m_list); + } + /*! Destroys the dictionary */ + ~CompoundSDictIterator() + { + delete m_li; + } + /*! Set the iterator to the first element in the list. + * \return The first compound, or zero if the list was empty. + */ + CompoundDef *toFirst() const + { + return m_li->toFirst(); + } + /*! Returns the current compound */ + CompoundDef *current() const + { + return m_li->current(); + } + /*! Moves the iterator to the next element. + * \return the new "current" element, or zero if the iterator was + * already pointing at the last element. + */ + CompoundDef *operator++() + { + return m_li->operator++(); + } + + private: + QListIterator<CompoundDef> *m_li; +}; + +/*! Concrete compound implementation. Used internally by the sax handlers */ +class CompoundDef_Impl : public CompoundDef +{ + public: + /*! Create an compound implementation object */ + CompoundDef_Impl() + { + m_type = Unknown_t; + m_baseCompounds = new QList<CompoundDef>; + m_derivedCompounds = new QList<CompoundDef>; + } + /*! Destroy the implementation object */ + ~CompoundDef_Impl() + { + delete m_baseCompounds; + delete m_derivedCompounds; + } + + /* implementation of the abstract interface */ + Type type() const { return m_type; } + QCString name() const { return m_name; } + QCString id() const { return m_id; } + QList<CompoundDef> *baseCompounds() const { return m_baseCompounds; } + QList<CompoundDef> *derivedCompounds() const { return m_derivedCompounds; } + + /*! Sets the type of the compound to \a t. */ + void setType(Type t) { m_type = t; } + /*! Sets the name of the compound to \a name. */ + void setName(const char *name) { m_name=name; } + /*! Sets the Id of the compound to \a id. */ + void setId(const char *id) { m_id=id; } + /*! Adds a new reference to the internal base class reference list */ + void addBaseRef(const char *name) { m_baseRefs.append(name); } + /*! Adds a new reference to the internal derived class reference list */ + void addDerivedRef(const char *name) { m_derivedRefs.append(name); } + + /*! Resolve the base and derived compound references. */ + void resolveReferences(CompoundSDict *dict) + { + char *refId; + refId = m_baseRefs.first(); + while (refId) + { + CompoundDef *cd = dict->find(refId); + m_baseCompounds->append(cd); + refId = m_baseRefs.next(); + } + refId = m_derivedRefs.first(); + while (refId) + { + CompoundDef *cd = dict->find(refId); + m_derivedCompounds->append(cd); + refId = m_derivedRefs.next(); + } + } + + private: + Type m_type; + QCString m_name; + QCString m_id; + QStrList m_derivedRefs; + QStrList m_baseRefs; + QList<CompoundDef> *m_baseCompounds; + QList<CompoundDef> *m_derivedCompounds; +}; + +#endif diff --git a/addon/xmlread/main.cpp b/addon/xmlread/main.cpp new file mode 100644 index 0000000..3f607f4 --- /dev/null +++ b/addon/xmlread/main.cpp @@ -0,0 +1,133 @@ +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <util/PlatformUtils.hpp> +#include <parsers/SAXParser.hpp> +#include "strx.h" +#include "saxhandlers.h" +#include "compounddef.h" + +// --------------------------------------------------------------------------- +// Local data +// +// xmlFile +// The path to the file to parser. Set via command line. +// +// --------------------------------------------------------------------------- +static char* xmlFile = 0; + +// --------------------------------------------------------------------------- +// Local helper methods +// --------------------------------------------------------------------------- +static void usage() +{ + cout << "\nUsage: xmlread file.xml\n" + << " Extracts the class hierarchy from a doxygen generated XML file.\n" + << endl; +} + +// recursively display non-root compounds +static void showDerivedCompounds(QList<CompoundDef> *compoundList,int level) +{ + if (compoundList->count()>0) + { + QListIterator<CompoundDef> cli(*compoundList); + CompoundDef *cd; + for (cli.toFirst();(cd=cli.current());++cli) + { + int i; + for (i=0;i<level;i++) cout << " "; + cout << cd->name() << endl; + showDerivedCompounds(cd->derivedCompounds(),level+1); + } + } +} + +// show compound hierarchy +static void showCompoundHierarchy(CompoundSDict *compounds) +{ + CompoundSDictIterator cdi(*compounds); + CompoundDef *cd; + for (cdi.toFirst();(cd=cdi.current());++cdi) + { + if (cd->type()==CompoundDef::Class_t && + cd->baseCompounds()->count()==0) // root compound + { + cout << cd->name() << endl; + showDerivedCompounds(cd->derivedCompounds(),1); + } + } +} + +// --------------------------------------------------------------------------- +// Program entry point +// --------------------------------------------------------------------------- +int main(int argC, char* argV[]) +{ + // Initialize the XML4C2 system + try + { + XMLPlatformUtils::Initialize(); + } + catch (const XMLException& toCatch) + { + cerr << "Error during initialization! :\n" + << StrX(toCatch.getMessage()) << endl; + return 1; + } + + // Check command line and extract arguments. + if (argC!=2) + { + usage(); + return 1; + } + + // Watch for special case help request + if (strcmp(argV[1], "-?") == 0) + { + usage(); + return 0; + } + + // Assume the argument is a file name + xmlFile = argV[1]; + + // + // Create a SAX validating parser object. + // + SAXParser parser; + parser.setDoValidation(TRUE); + + // Create a compound dictionary, where the results will be stored. + // The size of the dictionary is 1009 entries (should be a prime number) + CompoundSDict compounds(1009); + + // + // Create the handler object and install it as the document and error + // handler for the parser. + // + SaxPass1Handlers handler(&compounds); + parser.setDocumentHandler(&handler); + parser.setErrorHandler(&handler); + + // Parse the file and catch any exceptions that propogate out + try + { + parser.parse(xmlFile); + } + catch (const XMLException& toCatch) + { + cerr << "\nFile not found: '" << xmlFile << "'\n" + << "Exception message is: \n" + << StrX(toCatch.getMessage()) + << "\n" << endl; + return -1; + } + + // Show the class hierarchy that we extracted + showCompoundHierarchy(&compounds); + + return 0; +} + diff --git a/addon/xmlread/qtbc.h b/addon/xmlread/qtbc.h new file mode 100644 index 0000000..0091717 --- /dev/null +++ b/addon/xmlread/qtbc.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * + * + * + * Copyright (C) 1997-2000 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 QTBC_H +#define QTBC_H + +/*! This file contains some hacks to make Doxygen work with + * Qt version 2.00 and Qt version 1.xx + */ + +#include <qglobal.h> + +#if QT_VERSION >= 200 + +#include <locale.h> + +#define GCI QCollection::Item + +#include <qcstring.h> +#include <qstring.h> +inline QCString convertToQCString(const QString &s) { return s.latin1(); } + +#else /* QT_VERSION < 200 */ + +#include <qstring.h> +#define QCString QString +inline QCString convertToQCString(const QCString &s) { return s; } + +#endif + +#endif diff --git a/addon/xmlread/saxhandlers.cpp b/addon/xmlread/saxhandlers.cpp new file mode 100644 index 0000000..de8de89 --- /dev/null +++ b/addon/xmlread/saxhandlers.cpp @@ -0,0 +1,185 @@ + +// --------------------------------------------------------------------------- +// Includes +// --------------------------------------------------------------------------- +#include <util/XMLUni.hpp> +#include <sax/AttributeList.hpp> +#include "saxhandlers.h" +#include "strx.h" +#include <iostream.h> + +static void error(const SAXParseException& e) +{ + cerr << "\nError at (file " << StrX(e.getSystemId()) + << ", line " << e.getLineNumber() + << ", char " << e.getColumnNumber() + << "): " << StrX(e.getMessage()) << endl; + exit(1); +} + +static void fatalError(const SAXParseException& e) +{ + cerr << "\nFatal Error at (file " << StrX(e.getSystemId()) + << ", line " << e.getLineNumber() + << ", char " << e.getColumnNumber() + << "): " << StrX(e.getMessage()) << endl; + exit(1); +} + +static void warning(const SAXParseException& e) +{ + cerr << "\nWarning at (file " << StrX(e.getSystemId()) + << ", line " << e.getLineNumber() + << ", char " << e.getColumnNumber() + << "): " << StrX(e.getMessage()) << endl; + exit(1); +} + +// --------------------------------------------------------------------------- +// SaxPass1Handlers: Constructors and Destructor +// --------------------------------------------------------------------------- +SaxPass1Handlers::SaxPass1Handlers(CompoundSDict *comp) : m_compounds(comp) +{ + m_currentCompound = 0; +} + +SaxPass1Handlers::~SaxPass1Handlers() +{ +} + +// --------------------------------------------------------------------------- +// SaxPass1Handlers: Overrides of the SAX ErrorHandler interface +// --------------------------------------------------------------------------- +void SaxPass1Handlers::error(const SAXParseException& e) +{ + ::error(e); +} + +void SaxPass1Handlers::fatalError(const SAXParseException& e) +{ + ::fatalError(e); +} + +void SaxPass1Handlers::warning(const SAXParseException& e) +{ + ::warning(e); +} + +// --------------------------------------------------------------------------- +// SaxPass1Handlers: Overrides of the SAX DocumentHandler interface +// --------------------------------------------------------------------------- +void SaxPass1Handlers::characters(const XMLCh* const chars, + const unsigned int /*length*/ + ) +{ + if (m_charAction==ReadCompoundName) + { + m_compoundName=StrX(chars); + m_charAction=Done; + } +} + +void SaxPass1Handlers::endDocument() +{ + // resolve all references + CompoundSDictIterator cdi(*m_compounds); + CompoundDef *cd; + for (cdi.toFirst();(cd=cdi.current());++cdi) + { + CompoundDef_Impl *impl = dynamic_cast<CompoundDef_Impl*>(cd); + impl->resolveReferences(m_compounds); + } +} + +void SaxPass1Handlers::startElement(const XMLCh* const name, + AttributeList& attributes + ) +{ + QCString sname = StrX(name); + if (sname=="compounddef") + { + m_currentCompound = new CompoundDef_Impl; + unsigned int len = attributes.getLength(),index; + for (index = 0; index < len; index++) + { + QCString attName = StrX(attributes.getName(index)); + QCString attValue = StrX(attributes.getValue(index)); + if (attName == "id") + { + m_currentCompound->setId(attValue); + } + else if (attName=="type") + { + if (attValue=="class") + { + m_currentCompound->setType(CompoundDef::Class_t); + } + else if (attValue=="struct") + { + m_currentCompound->setType(CompoundDef::Struct_t); + } + else if (attValue=="union") + { + m_currentCompound->setType(CompoundDef::Union_t); + } + else if (attValue=="interface") + { + m_currentCompound->setType(CompoundDef::Interface_t); + } + else if (attValue=="file") + { + m_currentCompound->setType(CompoundDef::File_t); + } + else + { + cerr << "Unsupported compound type: " << attValue << "\n"; + } + } + } + } + else if (sname=="compoundname") + { + m_charAction = ReadCompoundName; + } + else if (sname=="basecompoundref") + { + unsigned int len = attributes.getLength(),index; + for (index = 0; index < len; index++) + { + QCString attName = StrX(attributes.getName(index)); + QCString attValue = StrX(attributes.getValue(index)); + if (attName=="idref") + { + m_currentCompound->addBaseRef(attValue); + } + } + } + else if (sname=="derivedcompoundref") + { + unsigned int len = attributes.getLength(),index; + for (index = 0; index < len; index++) + { + QCString attName = StrX(attributes.getName(index)); + QCString attValue = StrX(attributes.getValue(index)); + if (attName=="idref") + { + m_currentCompound->addDerivedRef(attValue); + } + } + } +} + +void SaxPass1Handlers::endElement(const XMLCh* const name) +{ + QCString sname = StrX(name); + if (sname=="compounddef") + { + m_compounds->append(m_currentCompound->id(),m_currentCompound); + m_currentCompound=0; + } + else if (sname=="compoundname") + { + m_currentCompound->setName(m_compoundName); + } +} + diff --git a/addon/xmlread/saxhandlers.h b/addon/xmlread/saxhandlers.h new file mode 100644 index 0000000..c9f38b8 --- /dev/null +++ b/addon/xmlread/saxhandlers.h @@ -0,0 +1,101 @@ +#ifndef _SAXHANDLERS_H +#define _SAXHANDLERS_H + +#include "compounddef.h" +#include <sax/HandlerBase.hpp> + +/*! SAX Handlers used for pass 1. */ +class SaxPass1Handlers : public HandlerBase +{ + public: + // ----------------------------------------------------------------------- + //! @name Constructors + // ----------------------------------------------------------------------- + //@{ + /*! Constructor */ + SaxPass1Handlers(CompoundSDict *comp); + /*! Destructor */ + ~SaxPass1Handlers(); + //@} + + // ----------------------------------------------------------------------- + //! @name Implementations of the SAX DocumentHandler interface + // ----------------------------------------------------------------------- + //@{ + /*! Handler called at the start of the XML document */ + void startDocument() {} + /*! Handler called at the end of the XML document */ + void endDocument(); + /*! Handler called when an element is found in the XML file + * \param name The element's name. + * \param attributes The list of attributes for the element. + */ + void startElement(const XMLCh* const name, AttributeList& attributes); + /*! Handler called when the element of an element is found in the XML file + * \param name The element's name. + */ + void endElement(const XMLCh* const name); + /*! Handler called when a character string is found in the XML file. + * \param chars Zero terminated string of characters. + * \param length The number of characters in the string. + */ + void characters(const XMLCh* const chars, const unsigned int length); + + /*! Handler called when an amount of whitespace is found, that is not + * Part of the text. + */ + void ignorableWhitespace(const XMLCh* const /*chars*/, + const unsigned int /*length*/ + ) {} + + /*! Handler called when a preprocessing intruction is found. + */ + void processingInstruction(const XMLCh* const /*target*/, + const XMLCh* const /*data*/ + ) {} + //@} + + // ----------------------------------------------------------------------- + //! @name Implementations of the SAX ErrorHandler interface + // ----------------------------------------------------------------------- + //@{ + /*! Handler called for a parser warning. */ + void warning(const SAXParseException& exception); + /*! Handler called for a parser error. */ + void error(const SAXParseException& exception); + /*! Handler called for a parser fatal error. */ + void fatalError(const SAXParseException& exception); + //@} + + // ----------------------------------------------------------------------- + //! @name Implementation of the SAX DTDHandler interface + // ----------------------------------------------------------------------- + //@{ + /*! Handler for DTD notation declaration. */ + void notationDecl(const XMLCh* const /*name*/, + const XMLCh* const /*publicId*/, + const XMLCh* const /*systemId*/ + ) {} + + /*! Handler for DTD unparsed entity declaration. */ + void unparsedEntityDecl(const XMLCh* const /*name*/, + const XMLCh* const /*publicId*/, + const XMLCh* const /*systemId*/, + const XMLCh* const /*notationName*/ + ) {} + //@} + + private: + // ----------------------------------------------------------------------- + // Private data members + // + // ----------------------------------------------------------------------- + + enum CharActions { Done, ReadCompoundName }; + CompoundSDict *m_compounds; + CompoundDef_Impl *m_currentCompound; + QCString m_compoundName; + CharActions m_charAction; +}; + +#endif diff --git a/addon/xmlread/strx.h b/addon/xmlread/strx.h new file mode 100644 index 0000000..ee58791 --- /dev/null +++ b/addon/xmlread/strx.h @@ -0,0 +1,24 @@ +#ifndef _STRX_H +#define _STRX_H + +// --------------------------------------------------------------------------- +// Includes for all the program files to see +// --------------------------------------------------------------------------- +#include "qtbc.h" +#include <iostream.h> + +/*! + * This is a simple wrapper class around QCString that lets us do easy + * trancoding of XMLCh data to local code page for display. + */ +class StrX : public QCString +{ + public: + /*! Constructor */ + StrX(const XMLCh* const toTranscode) : + QCString(XMLString::transcode(toTranscode)) {} + /*! Destructor */ + ~StrX() {} +}; + +#endif diff --git a/addon/xmlread/xmlread.pro.in b/addon/xmlread/xmlread.pro.in new file mode 100644 index 0000000..61eec2e --- /dev/null +++ b/addon/xmlread/xmlread.pro.in @@ -0,0 +1,7 @@ +TEMPLATE = app +CONFIG = console qt warn_on debug +HEADERS = saxhandler.h strx.h compounddef.h +SOURCES = main.cpp \ + saxhandlers.cpp +LIBS = -lxerces-c1_1 -L$(XERCES_ROOT) +INCLUDEPATH = $(XERCES_ROOT)/include |