1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
21 #define INCLUDED_CODEMAKER_EXCEPTIONTREE_HXX
23 #include <codemaker/global.hxx>
24 #include <rtl/ref.hxx>
25 #include <rtl/string.hxx>
34 Represents a node of the hierarchy from the ExceptionTree class.
36 struct ExceptionTreeNode
{
37 typedef std::vector
< ExceptionTreeNode
* > Children
;
39 // Internally used by ExceptionTree:
40 ExceptionTreeNode(rtl::OString
const & theName
):
41 name(theName
), present(false) {}
43 // Internally used by ExceptionTree:
44 ~ExceptionTreeNode() { clearChildren(); }
46 // Internally used by ExceptionTree:
47 void setPresent() { present
= true; clearChildren(); }
49 // Internally used by ExceptionTree:
50 ExceptionTreeNode
* add(rtl::OString
const & theName
);
57 ExceptionTreeNode(ExceptionTreeNode
&) SAL_DELETED_FUNCTION
;
58 void operator =(ExceptionTreeNode
) SAL_DELETED_FUNCTION
;
64 Represents the hierarchy formed by a set of UNO exception types.
66 The hierarchy is rooted at com.sun.star.uno.Exception. For each exception E
67 from the given set S, the hierarchy from com.sun.star.uno.Exception to the
68 first supertype E' of E which is itself a member of S is represented (i.e.,
69 subtypes that are hidden by supertypes are pruned from the hierarchy). The
70 exception com.sun.star.uno.RuntimeException and its subtypes are pruned
71 completely from the hierarchy. Each node of the hierarchy is represented by
72 an instance of ExceptionTreeNode, where name gives the name of the UNO
73 exception type, present is true iff the given exception type is a member of
74 the set S, and children contains all the relevant direct subtypes of the
75 given exception type, in no particular order (for nodes other than the root
76 node it holds that children is non-empty iff present is false).
80 ExceptionTree(): m_root("com.sun.star.uno.Exception") {}
85 Builds the exception hierarchy, by adding one exception type at a time.
87 This function can be called more than once for the same exception name.
89 @param name the name of a UNO exception type; it is an error if the given
90 name does not represent a UNO exception type
92 @param manager a type manager, used to resolve type names; it is an error
93 if different calls to this member function use different, incompatible
97 rtl::OString
const & name
,
98 rtl::Reference
< TypeManager
> const & manager
);
101 Gives access to the resultant exception hierarchy.
103 @return a reference to the root of the exception hierarchy, as
104 formed by all previous calls to add; it is an error if any calls to add
105 follow the first call to getRoot
107 ExceptionTreeNode
const & getRoot() const { return m_root
; }
110 ExceptionTree(ExceptionTree
&) SAL_DELETED_FUNCTION
;
111 void operator =(const ExceptionTree
&) SAL_DELETED_FUNCTION
;
113 ExceptionTreeNode m_root
;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */