1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_codemaker.hxx"
30 
31 #include "dumputils.hxx"
32 
33 #include "codemaker/global.hxx"
34 #include "codemaker/commoncpp.hxx"
35 
36 #include "rtl/ustring.hxx"
37 #include "sal/types.h"
38 
39 
40 namespace codemaker { namespace cppumaker {
41 
42 bool dumpNamespaceOpen(
43     FileStream & out, rtl::OString const & registryType, bool fullModuleType)
44 {
45     bool output = false;
46     if (registryType != "/") {
47         bool first = true;
48         for (sal_Int32 i = 0; i >= 0;) {
49             rtl::OString id(registryType.getToken(0, '/', i));
50             if (fullModuleType || i >= 0) {
51                 if (!first) {
52                     out << " ";
53                 }
54                 out << "namespace " << id << " {";
55                 first = false;
56                 output = true;
57             }
58         }
59     }
60     return output;
61 }
62 
63 bool dumpNamespaceClose(
64     FileStream & out, rtl::OString const & registryType, bool fullModuleType)
65 {
66     bool output = false;
67     if (registryType != "/") {
68         bool first = true;
69         for (sal_Int32 i = 0; i >= 0;) {
70             i = registryType.indexOf('/', i);
71             if (i >= 0) {
72                 ++i;
73             }
74             if (fullModuleType || i >= 0) {
75                 if (!first) {
76                     out << " ";
77                 }
78                 out << "}";
79                 first = false;
80                 output = true;
81             }
82         }
83     }
84     return output;
85 }
86 
87 void dumpTypeIdentifier(FileStream & out, rtl::OString const & registryType) {
88     out << registryType.copy(registryType.lastIndexOf('/') + 1);
89 }
90 
91 } }
92