LCOV - code coverage report
Current view: top level - codemaker/source/codemaker - unotype.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 29 29 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 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/unotype.hxx"
      22             : 
      23             : #include "osl/diagnose.h"
      24             : #include "rtl/string.hxx"
      25             : #include "sal/types.h"
      26             : 
      27             : 
      28      274637 : OString codemaker::UnoType::decompose(
      29             :     OString const & type, sal_Int32 * rank,
      30             :     std::vector< OString > * arguments)
      31             : {
      32      274637 :     sal_Int32 len = type.getLength();
      33      274637 :     sal_Int32 i = 0;
      34      562058 :     while (len - i > 1 && type[i + 1] == ']') {
      35       12784 :         i += 2;
      36             :     }
      37      274637 :     if (rank != 0) {
      38      274037 :         *rank = i / 2;
      39             :     }
      40      274637 :     sal_Int32 j = arguments == 0 ? -1 : type.indexOf('<', i);
      41      274637 :     if (j < 0) {
      42      274141 :         return type.copy(i);
      43             :     }
      44         496 :     sal_Int32 k = j;
      45         654 :     do {
      46         654 :         ++k; // skip '<' or ','
      47         654 :         sal_Int32 l = k;
      48       11234 :         for (sal_Int32 level = 0; l != len; ++l) {
      49       11234 :             char c = type[l];
      50       11234 :             if (c == ',') {
      51         245 :                 if (level == 0) {
      52         158 :                     break;
      53             :                 }
      54       10989 :             } else if (c == '<') {
      55         136 :                 ++level;
      56       10853 :             } else if (c == '>') {
      57         632 :                 if (level == 0) {
      58         496 :                     break;
      59             :                 }
      60         136 :                 --level;
      61             :             }
      62             :         }
      63         654 :         arguments->push_back(type.copy(k, l - k));
      64         654 :         k = l;
      65         654 :     } while (k != len && type[k] != '>');
      66             :     OSL_ASSERT(k == len - 1 && type[k] == '>');
      67         496 :     return type.copy(i, j - i);
      68             : }
      69             : 
      70             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11