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 .
22 #include <rtl/ref.hxx>
23 #include <rtl/string.hxx>
34 Represents a node of the hierarchy from the ExceptionTree class.
36 struct ExceptionTreeNode
{
37 typedef std::vector
< std::unique_ptr
<ExceptionTreeNode
> > Children
;
39 // Internally used by ExceptionTree:
40 ExceptionTreeNode(rtl::OString theName
):
41 name(std::move(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
const &) = delete;
58 ExceptionTreeNode
& operator =(ExceptionTreeNode
const &) = delete;
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"_ostr
) {}
83 Builds the exception hierarchy, by adding one exception type at a time.
85 This function can be called more than once for the same exception name.
87 @param name the name of a UNO exception type; it is an error if the given
88 name does not represent a UNO exception type
90 @param manager a type manager, used to resolve type names; it is an error
91 if different calls to this member function use different, incompatible
95 rtl::OString
const & name
,
96 rtl::Reference
< TypeManager
> const & manager
);
99 Gives access to the resultant exception hierarchy.
101 @return a reference 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
105 ExceptionTreeNode
const & getRoot() const { return m_root
; }
108 ExceptionTree(ExceptionTree
const &) = delete;
109 ExceptionTree
& operator =(const ExceptionTree
&) = delete;
111 ExceptionTreeNode m_root
;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */