LibreOffice Module codemaker (master) 1
unotype.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
21#include <codemaker/unotype.hxx>
22
23#include <osl/diagnose.h>
24#include <rtl/string.hxx>
25#include <sal/types.h>
26
27
29 OString const & type, sal_Int32 * rank,
30 std::vector< OString > * arguments)
31{
32 sal_Int32 len = type.getLength();
33 sal_Int32 i = 0;
34 while (len - i > 1 && type[i + 1] == ']') {
35 i += 2;
36 }
37 if (rank != nullptr) {
38 *rank = i / 2;
39 }
40 sal_Int32 j = arguments == nullptr ? -1 : type.indexOf('<', i);
41 if (j < 0) {
42 return type.copy(i);
43 }
44 sal_Int32 k = j;
45 do {
46 ++k; // skip '<' or ','
47 sal_Int32 l = k;
48 for (sal_Int32 level = 0; l != len; ++l) {
49 char c = type[l];
50 if (c == ',') {
51 if (level == 0) {
52 break;
53 }
54 } else if (c == '<') {
55 ++level;
56 } else if (c == '>') {
57 if (level == 0) {
58 break;
59 }
60 --level;
61 }
62 }
63 arguments->push_back(type.copy(k, l - k));
64 k = l;
65 } while (k != len && type[k] != '>');
66 OSL_ASSERT(k == len - 1 && type[k] == '>');
67 return type.copy(i, j - i);
68}
69
70/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::OString decompose(rtl::OString const &type, sal_Int32 *rank=nullptr, std::vector< rtl::OString > *arguments=nullptr)
Decomposes a UNO type name or UNO type registry name.
int i
ResultType type