LibreOffice Module codemaker (master) 1
exceptiontree.cxx
Go to the documentation of this file.
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
23
24#include <rtl/ref.hxx>
25#include <rtl/string.hxx>
26#include <rtl/textenc.h>
27#include <rtl/ustring.hxx>
28#include <unoidl/unoidl.hxx>
29
30#include <memory>
31#include <vector>
32
35
36ExceptionTreeNode * ExceptionTreeNode::add(OString const & theName) {
37 std::unique_ptr< ExceptionTreeNode > node(new ExceptionTreeNode(theName));
38 children.push_back(std::move(node));
39 return children.back().get();
40}
41
43 children.clear();
44}
45
47 OString const & name, rtl::Reference< TypeManager > const & manager)
48{
49 std::vector< OString > list;
50 bool bRuntimeException = false;
51 for (OString n(name); n != "com.sun.star.uno.Exception";) {
52 if (n == "com.sun.star.uno.RuntimeException") {
53 bRuntimeException = true;
54 break;
55 }
56 list.push_back(n);
58 codemaker::UnoType::Sort s = manager->getSort(b2u(n), &ent);
59 (void) s; // WaE: unused variable
61 n = u2b(
62 static_cast< unoidl::ExceptionTypeEntity * >(ent.get())->
63 getDirectBase());
64 assert(!n.isEmpty());
65 }
66 if (bRuntimeException)
67 return;
68
69 ExceptionTreeNode * node = &m_root;
70 for (std::vector< OString >::reverse_iterator i(list.rbegin());
71 !node->present; ++i)
72 {
73 if (i == list.rend()) {
74 node->setPresent();
75 break;
76 }
77 for (ExceptionTreeNode::Children::iterator j(
78 node->children.begin());;
79 ++j)
80 {
81 if (j == node->children.end()) {
82 node = node->add(*i);
83 break;
84 }
85 if ((*j)->name == *i) {
86 node = j->get();
87 break;
88 }
89 }
90 }
91}
92
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents the hierarchy formed by a set of UNO exception types.
void add(rtl::OString const &name, rtl::Reference< TypeManager > const &manager)
Builds the exception hierarchy, by adding one exception type at a time.
ExceptionTreeNode m_root
rtl::Reference< ParseManager > manager
const char * name
sal_Int64 n
Sort
An enumeration of all the sorts of relevant UNOIDL entities.
Definition: unotype.hxx:33
int i
Represents a node of the hierarchy from the ExceptionTree class.
ExceptionTreeNode * add(rtl::OString const &theName)
ExceptionTreeNode(rtl::OString theName)
OUString b2u(std::string_view s)
Definition: typemanager.hxx:71
OString u2b(std::u16string_view s)
Definition: typemanager.hxx:67