LCOV - code coverage report
Current view: top level - codemaker/source/codemaker - exceptiontree.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 34 37 91.9 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 58 62.1 %

           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                 :            : 
      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                 :        432 : ExceptionTreeNode * ExceptionTreeNode::add(rtl::OString const & theName) {
      38 [ +  - ][ +  - ]:        432 :     std::auto_ptr< ExceptionTreeNode > node(new ExceptionTreeNode(theName));
      39         [ +  - ]:        432 :     children.push_back(node.get());
      40         [ +  - ]:        432 :     return node.release();
      41                 :            : }
      42                 :            : 
      43                 :       2538 : void ExceptionTreeNode::clearChildren() {
      44 [ +  - ][ +  + ]:       2970 :     for (Children::iterator i(children.begin()); i != children.end(); ++i) {
      45 [ +  - ][ +  - ]:        432 :         delete *i;
      46                 :            :     }
      47                 :       2538 :     children.clear();
      48                 :       2538 : }
      49                 :            : 
      50                 :        486 : void ExceptionTree::add(rtl::OString const & name, TypeManager const & manager)
      51                 :            :     throw( CannotDumpException )
      52                 :            : {
      53                 :            :     typedef std::vector< rtl::OString > OStringList;
      54         [ +  - ]:        486 :     OStringList stringlist;
      55                 :        486 :     bool runtimeException = false;
      56 [ +  - ][ +  + ]:        930 :     for (rtl::OString n(name); n != "com/sun/star/uno/Exception";) {
      57         [ +  + ]:        460 :         if (n == "com/sun/star/uno/RuntimeException") {
      58                 :         16 :             runtimeException = true;
      59                 :            :             break;
      60                 :            :         }
      61         [ +  - ]:        444 :         stringlist.push_back(n);
      62         [ +  - ]:        444 :         typereg::Reader reader(manager.getTypeReader(n));
      63         [ -  + ]:        444 :         if (!reader.isValid())
      64                 :            :             throw CannotDumpException(
      65                 :            :                 ::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 [ +  - ][ +  - ]:        444 :             reader.getSuperTypeName(0), RTL_TEXTENCODING_UTF8);
      73                 :        930 :     }
      74         [ +  + ]:        486 :     if (!runtimeException) {
      75                 :        470 :         ExceptionTreeNode * node = &m_root;
      76 [ +  - ][ +  + ]:       1368 :         for (OStringList::reverse_iterator i(stringlist.rbegin()); !node->present; ++i) {
      77 [ +  - ][ +  + ]:        898 :             if (i == stringlist.rend()) {
      78         [ +  - ]:        466 :                 node->setPresent();
      79                 :        466 :                 break;
      80                 :            :             }
      81                 :        104 :             for (ExceptionTreeNode::Children::iterator j(
      82                 :        432 :                      node->children.begin());;
      83                 :            :                  ++j)
      84                 :            :             {
      85 [ +  - ][ +  + ]:        536 :                 if (j == node->children.end()) {
      86 [ +  - ][ +  - ]:        432 :                     node = node->add(*i);
      87                 :        432 :                     break;
      88                 :            :                 }
      89 [ +  - ][ -  + ]:        104 :                 if ((*j)->name == *i) {
      90                 :          0 :                     node = *j;
      91                 :          0 :                     break;
      92                 :            :                 }
      93                 :            :             }
      94                 :            :         }
      95                 :        486 :     }
      96                 :        486 : }
      97                 :            : 
      98                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10