include/EDoc/Exception.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003    Copyright (C) 2007 by Brendon Costa
00004 
00005    This library is free software; you can redistribute it and/or modify 
00006    it under the terms of the "LGPL Like" License defined in the file COPYING 
00007    that should have been distributed along with this source.
00008 
00009    This library is distributed in the hope that it will be useful, 
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of 
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013    You should have received a copy of the "LGPL Like" License 
00014    along with this library; see the file COPYING. if not, it can be 
00015    obtained from the EDoc++ website: 
00016    http://edoc.sourceforge.net/license.html
00017 
00018 *******************************************************************************/
00019 #ifndef EDOC_EXCEPTION_H
00020 #define EDOC_EXCEPTION_H
00021 
00022 #include "EDoc/DictionarySpecific.h"
00023 #include "EDoc/TypeLoc.h"
00024 
00025 #include <list>
00026 
00027 namespace EDoc
00028 {
00029    class Function;
00030    class PropogatingException;
00031    class PStack;
00032    
00033    //===========================================================================
00034    /** \brief Represents a throw statement in C++ code.
00035     *
00036     * This exception object is generated for any code that contains a throw
00037     * statement. Rethrows are also represented with this class using a type with
00038     * name "...".
00039     *
00040     * All throw statements that generate a new exception are also called
00041     * "Originating Exceptions". Originating exceptions are the source of
00042     * propogating exceptions, this terminology is important to remember when
00043     * reading code or documentation about EDoc.
00044     *
00045     * An exception instance will include primary data about the type in a
00046     * TypeLoc instance called type. This stores a reference to the type of the
00047     * exception being thrown ("..." type for rethrow exceptions) and location
00048     * information indicating at what line and in which source file this throw
00049     * statement can be found.
00050     */
00051    class Exception : public DictionarySpecific
00052    {
00053       friend class PropogatingException;
00054    public:
00055 
00056       //------------------------------------------------------------------------
00057       /** \brief See CodeBlock::CodeBlock(Dictionary* dict_in=NULL)
00058        */
00059       Exception(Dictionary* dict_in=NULL);
00060 
00061       //------------------------------------------------------------------------
00062       /** \brief See CodeBlock::CodeBlock(const CodeBlock& right)
00063        */
00064       Exception(const Exception& right);
00065 
00066       //------------------------------------------------------------------------
00067       /** \brief See CodeBlock::CodeBlock(const CodeBlock& right, 
00068        * Dictionary& dict_in)
00069        */
00070       Exception(const Exception& right, Dictionary& dict_in);
00071 
00072       //------------------------------------------------------------------------
00073       /** \brief See CodeBlock::operator=()
00074        */
00075       Exception& operator=(const Exception& right);
00076 
00077 
00078 
00079       //------------------------------------------------------------------------
00080       /** \brief See CodeBlock::Read()
00081        */
00082       void Read(PersistenceIFace& file, IndexedDictionary& idict);
00083 
00084       //------------------------------------------------------------------------
00085       /** \brief See CodeBlock::Write()
00086        */
00087       void Write(PersistenceIFace& file) const;
00088 
00089       //------------------------------------------------------------------------
00090       /** \brief See DictionarySpecific::ReplaceReferences()
00091        */
00092       virtual size_t ReplaceReferences(PStack& stack, 
00093          void* remove, void* replace);
00094 
00095       //------------------------------------------------------------------------
00096       /** \brief See DictionarySpecific::Print()
00097        */
00098       virtual std::ostream& Print(std::ostream& out, 
00099          std::string prefix="") const;
00100 
00101       //------------------------------------------------------------------------
00102       /** \brief See DictionarySpecific::Validate()
00103        */
00104       virtual void Validate(PStack& stack, const Dictionary& dict_in) const;
00105 
00106       //------------------------------------------------------------------------
00107       /** \brief Equivilance operator (Works across dictionaries).
00108        *
00109        * \return Returns true if the type being thrown is the same and the
00110        * location it is being thrown from is also the same.
00111        */
00112       bool operator==(const Exception& right) const;
00113 
00114 
00115       //------------------------------------------------------------------------
00116       // Public Primary Data values.
00117       //------------------------------------------------------------------------
00118 
00119       //------------------------------------------------------------------------
00120       /** \brief Stores the type and location in the source from which it is
00121        * thrown.
00122        */
00123       TypeLoc type;
00124       
00125 
00126       //------------------------------------------------------------------------
00127       // Suppression Data values.
00128       //------------------------------------------------------------------------
00129 
00130       //------------------------------------------------------------------------
00131       /** \brief True if this exception is visible to the user or false if 
00132        * this exception will never be shown to the user.
00133        *
00134        * This is used for suppressions.
00135        */
00136       // @@@Brendon Add to doxygen suppressions group?
00137       bool visible;
00138 
00139       //------------------------------------------------------------------------
00140       /** \brief True if this exception was created automatically by EDoc++
00141        * as a throw spec exception.
00142        *
00143        * I.e. This is an exception that does not actually exist in the code
00144        * but represents wnat is possible based on the functions specifiers.
00145        */
00146       bool auto_throw_spec;
00147 
00148       //------------------------------------------------------------------------
00149       // Public Derived Data values.
00150       //------------------------------------------------------------------------
00151 
00152       //------------------------------------------------------------------------
00153       /** \brief Function from which exception originates.
00154        *
00155        * This is populated by Dictionary::CalculatePropogatingExceptions() but
00156        * NULL before then.
00157        */
00158       Function* function;
00159 
00160       //------------------------------------------------------------------------
00161    };
00162    //===========================================================================
00163    typedef std::list<Exception> ExcepList;
00164    typedef std::list<Exception*> ExcepPList;
00165 }
00166 
00167 #endif // EDOC_EXCEPTION_H

Generated on Tue Jan 20 18:26:07 2009 for EDoc-0.2.1 by  doxygen 1.5.1