LCOV - code coverage report
Current view: top level - codemaker/source/codemaker - unotype.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 48 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 61 66 92.4 %

           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/unotype.hxx"
      22                 :            : 
      23                 :            : #include "osl/diagnose.h"
      24                 :            : #include "rtl/string.hxx"
      25                 :            : #include "sal/types.h"
      26                 :            : 
      27                 :            : #include <vector>
      28                 :            : 
      29                 :     380590 : codemaker::UnoType::Sort codemaker::UnoType::getSort(rtl::OString const & type)
      30                 :            : {
      31                 :     380590 :     return type == "void" ? SORT_VOID
      32                 :     349832 :         : type == "boolean" ? SORT_BOOLEAN
      33                 :     325584 :         : type == "byte" ? SORT_BYTE
      34                 :     318437 :         : type == "short" ? SORT_SHORT
      35                 :     281054 :         : type == "unsigned short" ? SORT_UNSIGNED_SHORT
      36                 :     279386 :         : type == "long" ? SORT_LONG
      37                 :     199661 :         : type == "unsigned long" ? SORT_UNSIGNED_LONG
      38                 :     197615 :         : type == "hyper" ? SORT_HYPER
      39                 :     195692 :         : type == "unsigned hyper" ? SORT_UNSIGNED_HYPER
      40                 :     195336 :         : type == "float" ? SORT_FLOAT
      41                 :     193797 :         : type == "double" ? SORT_DOUBLE
      42                 :     186722 :         : type == "char" ? SORT_CHAR
      43                 :     185832 :         : type == "string" ? SORT_STRING
      44                 :     134266 :         : type == "type" ? SORT_TYPE
      45                 :     133418 :         : type == "any" ? SORT_ANY
      46 [ +  + ][ +  + ]:    3557222 :         : SORT_COMPLEX;
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
                 [ +  + ]
      47                 :            : }
      48                 :            : 
      49                 :      40964 : bool codemaker::UnoType::isSequenceType(rtl::OString const & type) {
      50 [ +  - ][ +  + ]:      40964 :     return !type.isEmpty() && type[0] == '[';
      51                 :            : }
      52                 :            : 
      53                 :     698118 : rtl::OString codemaker::UnoType::decompose(
      54                 :            :     rtl::OString const & type, sal_Int32 * rank,
      55                 :            :     std::vector< rtl::OString > * arguments)
      56                 :            : {
      57                 :     698118 :     sal_Int32 len = type.getLength();
      58                 :     698118 :     sal_Int32 i = 0;
      59 [ +  - ][ +  + ]:     731437 :     while (len - i > 1 && type[i + 1] == ']') {
                 [ +  + ]
      60                 :      33319 :         i += 2;
      61                 :            :     }
      62         [ +  + ]:     698118 :     if (rank != 0) {
      63                 :     678266 :         *rank = i / 2;
      64                 :            :     }
      65         [ +  + ]:     698118 :     sal_Int32 j = arguments == 0 ? -1 : type.indexOf('<', i);
      66         [ +  + ]:     698118 :     if (j < 0) {
      67                 :     697284 :         return type.copy(i);
      68                 :            :     }
      69                 :        834 :     sal_Int32 k = j;
      70         [ +  + ]:       2212 :     do {
           [ +  -  +  + ]
      71                 :       1106 :         ++k; // skip '<' or ','
      72                 :       1106 :         sal_Int32 l = k;
      73         [ +  - ]:      18083 :         for (sal_Int32 level = 0; l != len; ++l) {
      74                 :      18083 :             char c = type[l];
      75         [ +  + ]:      18083 :             if (c == ',') {
      76         [ +  + ]:        404 :                 if (level == 0) {
      77                 :        272 :                     break;
      78                 :            :                 }
      79         [ +  + ]:      17679 :             } else if (c == '<') {
      80                 :        210 :                 ++level;
      81         [ +  + ]:      17469 :             } else if (c == '>') {
      82         [ +  + ]:       1044 :                 if (level == 0) {
      83                 :        834 :                     break;
      84                 :            :                 }
      85                 :        210 :                 --level;
      86                 :            :             }
      87                 :            :         }
      88         [ +  - ]:       1106 :         arguments->push_back(type.copy(k, l - k));
      89                 :       1106 :         k = l;
      90                 :       1106 :     } while (k != len && type[k] != '>');
      91                 :            :     OSL_ASSERT(k == len - 1 && type[k] == '>');
      92                 :     698118 :     return type.copy(i, j - i);
      93                 :            : }
      94                 :            : 
      95                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10