LCOV - code coverage report
Current view: top level - codemaker/inc/codemaker - exceptiontree.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
      21                 :            : #define INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
      22                 :            : 
      23                 :            : #include "codemaker/global.hxx"
      24                 :            : #include "rtl/string.hxx"
      25                 :            : 
      26                 :            : #include <vector>
      27                 :            : 
      28                 :            : class TypeManager;
      29                 :            : 
      30                 :            : namespace codemaker {
      31                 :            : 
      32                 :            : /**
      33                 :            :    Represents a node of the hierarchy from the ExceptionTree class.
      34                 :            :  */
      35                 :            : struct ExceptionTreeNode {
      36                 :            :     typedef std::vector< ExceptionTreeNode * > Children;
      37                 :            : 
      38                 :            :     // Internally used by ExceptionTree:
      39                 :       2072 :     ExceptionTreeNode(rtl::OString const & theName):
      40         [ +  - ]:       2072 :         name(theName), present(false) {}
      41                 :            : 
      42                 :            :     // Internally used by ExceptionTree:
      43         [ +  - ]:       2072 :     ~ExceptionTreeNode() { clearChildren(); }
      44                 :            : 
      45                 :            :     // Internally used by ExceptionTree:
      46                 :        466 :     void setPresent() { present = true; clearChildren(); }
      47                 :            : 
      48                 :            :     // Internally used by ExceptionTree:
      49                 :            :     ExceptionTreeNode * add(rtl::OString const & theName);
      50                 :            : 
      51                 :            :     rtl::OString name;
      52                 :            :     bool present;
      53                 :            :     Children children;
      54                 :            : 
      55                 :            : private:
      56                 :            :     ExceptionTreeNode(ExceptionTreeNode &); // not implemented
      57                 :            :     void operator =(ExceptionTreeNode); // not implemented
      58                 :            : 
      59                 :            :     void clearChildren();
      60                 :            : };
      61                 :            : 
      62                 :            : /**
      63                 :            :    Represents the hierarchy formed by a set of UNO exception types.
      64                 :            : 
      65                 :            :    The hierarchy is rooted at com.sun.star.uno.Exception.  For each exception E
      66                 :            :    from the given set S, the hierarchy from com.sun.star.uno.Exception to the
      67                 :            :    first supertype E' of E which is itself a member of S is represented (i.e.,
      68                 :            :    subtypes that are hidden by supertypes are pruned from the hierarchy).  The
      69                 :            :    exception com.sun.star.uno.RuntimeException and its subtypes are pruned
      70                 :            :    completely from the hierarchy.  Each node of the hierarchy is represented by
      71                 :            :    an instance of ExceptionTreeNode, where name gives the slashified name of
      72                 :            :    the UNO exception type, present is true iff the given exception type is a
      73                 :            :    member of the set S, and children contains all the relevant direct subtypes
      74                 :            :    of the given exception type, in no particular order (for nodes other than the
      75                 :            :    root node it holds that children is non-empty iff present is false).
      76                 :            :  */
      77                 :            : class ExceptionTree {
      78                 :            : public:
      79         [ +  - ]:       1640 :     ExceptionTree(): m_root("com/sun/star/uno/Exception") {}
      80                 :            : 
      81                 :       1640 :     ~ExceptionTree() {}
      82                 :            : 
      83                 :            :     /**
      84                 :            :        Builds the exception hierarchy, by adding one exception type at a time.
      85                 :            : 
      86                 :            :        This function can be called more than once for the same exception name.
      87                 :            : 
      88                 :            :        @param name the name of a UNO exception type, in slashified form; it is
      89                 :            :        an error if the given name does not represent a UNO exception type
      90                 :            : 
      91                 :            :        @param manager a type manager, used to resolve type names; it is an error
      92                 :            :        if different calls to this member function use different, incompatible
      93                 :            :        type managers
      94                 :            :      */
      95                 :            :     void add(rtl::OString const & name, TypeManager const & manager)
      96                 :            :         throw( CannotDumpException );
      97                 :            : 
      98                 :            :     /**
      99                 :            :        Gives access to the resultant exception hierarchy.
     100                 :            : 
     101                 :            :        @return a non-null pointer to the root of the exception hierarchy, as
     102                 :            :        formed by all previous calls to add; it is an error if any calls to add
     103                 :            :        follow the first call to getRoot
     104                 :            :      */
     105                 :       3886 :     ExceptionTreeNode const * getRoot() const { return &m_root; }
     106                 :            : 
     107                 :            : private:
     108                 :            :     ExceptionTree(ExceptionTree &); // not implemented
     109                 :            :     void operator =(ExceptionTree); // not implemented
     110                 :            : 
     111                 :            :     ExceptionTreeNode m_root;
     112                 :            : };
     113                 :            : 
     114                 :            : }
     115                 :            : 
     116                 :            : #endif
     117                 :            : 
     118                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10