1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cppumaker.hxx"
26 
27 #include "dumputils.hxx"
28 
29 #include "codemaker/global.hxx"
30 #include "codemaker/commoncpp.hxx"
31 
32 #include "rtl/ustring.hxx"
33 #include "sal/types.h"
34 
35 
36 namespace codemaker { namespace cppumaker {
37 
dumpNamespaceOpen(FileStream & out,rtl::OString const & registryType,bool fullModuleType)38 bool dumpNamespaceOpen(
39     FileStream & out, rtl::OString const & registryType, bool fullModuleType)
40 {
41     bool output = false;
42     if (registryType != "/") {
43         bool first = true;
44         for (sal_Int32 i = 0; i >= 0;) {
45             rtl::OString id(registryType.getToken(0, '/', i));
46             if (fullModuleType || i >= 0) {
47                 if (!first) {
48                     out << " ";
49                 }
50                 out << "namespace " << id << " {";
51                 first = false;
52                 output = true;
53             }
54         }
55     }
56     return output;
57 }
58 
dumpNamespaceClose(FileStream & out,rtl::OString const & registryType,bool fullModuleType)59 bool dumpNamespaceClose(
60     FileStream & out, rtl::OString const & registryType, bool fullModuleType)
61 {
62     bool output = false;
63     if (registryType != "/") {
64         bool first = true;
65         for (sal_Int32 i = 0; i >= 0;) {
66             i = registryType.indexOf('/', i);
67             if (i >= 0) {
68                 ++i;
69             }
70             if (fullModuleType || i >= 0) {
71                 if (!first) {
72                     out << " ";
73                 }
74                 out << "}";
75                 first = false;
76                 output = true;
77             }
78         }
79     }
80     return output;
81 }
82 
dumpTypeIdentifier(FileStream & out,rtl::OString const & registryType)83 void dumpTypeIdentifier(FileStream & out, rtl::OString const & registryType) {
84     out << registryType.copy(registryType.lastIndexOf('/') + 1);
85 }
86 
87 } }
88