LCOV - code coverage report
Current view: top level - libreoffice/codemaker/source/codemaker - exceptiontree.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 38 89.5 %
Date: 2012-12-27 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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             : 
      21             : #include "codemaker/exceptiontree.hxx"
      22             : #include "codemaker/typemanager.hxx"
      23             : 
      24             : #include "osl/diagnose.h"
      25             : #include "registry/reader.hxx"
      26             : #include "registry/types.h"
      27             : #include "rtl/string.hxx"
      28             : #include "rtl/textenc.h"
      29             : #include "rtl/ustring.hxx"
      30             : 
      31             : #include <memory>
      32             : #include <vector>
      33             : 
      34             : using codemaker::ExceptionTree;
      35             : using codemaker::ExceptionTreeNode;
      36             : 
      37          61 : ExceptionTreeNode * ExceptionTreeNode::add(rtl::OString const & theName) {
      38          61 :     std::auto_ptr< ExceptionTreeNode > node(new ExceptionTreeNode(theName));
      39          61 :     children.push_back(node.get());
      40          61 :     return node.release();
      41             : }
      42             : 
      43        1068 : void ExceptionTreeNode::clearChildren() {
      44        1129 :     for (Children::iterator i(children.begin()); i != children.end(); ++i) {
      45          61 :         delete *i;
      46             :     }
      47        1068 :     children.clear();
      48        1068 : }
      49             : 
      50         250 : void ExceptionTree::add(rtl::OString const & name, TypeManager const & manager)
      51             :     throw( CannotDumpException )
      52             : {
      53             :     typedef std::vector< rtl::OString > OStringList;
      54         250 :     OStringList stringlist;
      55         250 :     bool runtimeException = false;
      56         729 :     for (rtl::OString n(name); n != "com/sun/star/uno/Exception";) {
      57         399 :         if (n == "com/sun/star/uno/RuntimeException") {
      58         170 :             runtimeException = true;
      59             :             break;
      60             :         }
      61         229 :         stringlist.push_back(n);
      62         229 :         typereg::Reader reader(manager.getTypeReader(n));
      63         229 :         if (!reader.isValid())
      64             :             throw CannotDumpException(
      65           0 :                 ::rtl::OString("Unknown type '" + n.replace('/', '.')
      66           0 :                                + "', incomplete type library."));
      67             : 
      68             :         OSL_ASSERT(
      69             :             reader.getTypeClass() == RT_TYPE_EXCEPTION
      70             :             && reader.getSuperTypeCount() == 1);
      71             :         n = rtl::OUStringToOString(
      72         229 :             reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
      73         479 :     }
      74         250 :     if (!runtimeException) {
      75          80 :         ExceptionTreeNode * node = &m_root;
      76         141 :         for (OStringList::reverse_iterator i(stringlist.rbegin()); !node->present; ++i) {
      77         139 :             if (i == stringlist.rend()) {
      78          78 :                 node->setPresent();
      79          78 :                 break;
      80             :             }
      81          12 :             for (ExceptionTreeNode::Children::iterator j(
      82          61 :                      node->children.begin());;
      83             :                  ++j)
      84             :             {
      85          73 :                 if (j == node->children.end()) {
      86          61 :                     node = node->add(*i);
      87          61 :                     break;
      88             :                 }
      89          12 :                 if ((*j)->name == *i) {
      90           0 :                     node = *j;
      91           0 :                     break;
      92             :                 }
      93             :             }
      94             :         }
      95         250 :     }
      96         250 : }
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10