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 : : #include <stdio.h>
21 : : #include <rtl/alloc.h>
22 : : #include <rtl/ustring.hxx>
23 : : #include <rtl/strbuf.hxx>
24 : :
25 : : #include "rdbtype.hxx"
26 : : #include "rdboptions.hxx"
27 : :
28 : : using ::rtl::OUString;
29 : : using ::rtl::OString;
30 : : using ::rtl::OStringToOUString;
31 : 1628 : sal_Bool isBaseType(const OString& type)
32 : : {
33 [ + + + + : 25264 : if ( type.equals("long") ||
+ + + + +
+ + - + +
+ + + + +
- + - + -
+ + + + +
+ - + ]
[ + - ][ + - ]
[ + + ]
34 [ + + ][ + + ]: 3236 : type.equals("short") ||
35 [ + + ][ + + ]: 3228 : type.equals("hyper") ||
36 [ + + ][ + + ]: 3226 : type.equals("string") ||
37 [ + + ][ + + ]: 3152 : type.equals("boolean") ||
38 [ + + ][ + + ]: 3110 : type.equals("char") ||
39 [ + + ][ + + ]: 3110 : type.equals("byte") ||
40 [ + + ][ + + ]: 3102 : type.equals("any") ||
41 [ + + ][ + + ]: 3056 : type.equals("type") ||
42 [ + + ][ + + ]: 3046 : type.equals("float") ||
43 [ + + ][ + + ]: 3046 : type.equals("double") ||
44 [ + + ][ + + ]: 3046 : type.equals("octet") ||
45 [ + + ][ + + ]: 3046 : type.equals("void") ||
46 [ + + ][ + + ]: 3010 : type.equals("unsigned long") ||
47 [ + + ][ + + ]: 3008 : type.equals("unsigned short") ||
48 [ + + ][ + + ]: 3006 : type.equals("unsigned hyper") )
49 : 250 : return sal_True;
50 : :
51 : 1628 : return sal_False;
52 : : }
53 : :
54 : 222 : sal_Bool produceDependedTypes(const OString& typeName,
55 : : TypeManager& typeMgr,
56 : : TypeDependency& typeDependencies,
57 : : RdbOptions* pOptions,
58 : : FileStream& o,
59 : : RegistryKey& regKey,
60 : : StringSet& filterTypes)
61 : : throw( CannotDumpException )
62 : : {
63 : 222 : sal_Bool ret = sal_True;
64 : :
65 [ + - ]: 222 : TypeUsingSet usingSet(typeDependencies.getDependencies(typeName));
66 : :
67 : 222 : TypeUsingSet::const_iterator iter = usingSet.begin();
68 : 222 : OString sTypeName;
69 : 222 : sal_Int32 index = 0;
70 [ + + ]: 1850 : while (iter != usingSet.end())
71 : : {
72 : 1628 : sTypeName = (*iter).m_type;
73 [ + + ]: 1628 : if ((index = sTypeName.lastIndexOf(']')) > 0)
74 : 86 : sTypeName = sTypeName.copy(index + 1);
75 : :
76 [ + - ][ + + ]: 1628 : if ( !isBaseType(sTypeName) )
77 : : {
78 [ - + ]: 1378 : if (!produceType(sTypeName,
79 : : typeMgr,
80 : : typeDependencies,
81 : : pOptions,
82 : : o, regKey,
83 : : filterTypes,
84 [ + - ]: 1378 : sal_True))
85 : : {
86 : : fprintf(stderr, "%s ERROR: %s\n",
87 [ # # ]: 0 : pOptions->getProgramName().getStr(),
88 [ # # ]: 0 : OString("cannot dump Type '" + sTypeName + "'").getStr());
89 [ # # ]: 0 : cleanUp(sal_True);
90 : 0 : exit(99);
91 : : }
92 : : }
93 : 1628 : ++iter;
94 : : }
95 : :
96 : 222 : return ret;
97 : : }
98 : :
99 : : //*************************************************************************
100 : : // produceType
101 : : //*************************************************************************
102 : 1510 : sal_Bool produceType(const OString& typeName,
103 : : TypeManager& typeMgr,
104 : : TypeDependency& typeDependencies,
105 : : RdbOptions* pOptions,
106 : : FileStream& o,
107 : : RegistryKey& regKey,
108 : : StringSet& filterTypes,
109 : : sal_Bool bDepend)
110 : : throw( CannotDumpException )
111 : : {
112 [ + + ]: 1510 : if (typeDependencies.isGenerated(typeName) )
113 : 1288 : return sal_True;
114 [ - + ]: 222 : if( !checkTypeDependencies(typeMgr, typeDependencies, typeName, bDepend))
115 : 0 : return sal_False;
116 : :
117 [ + - ]: 222 : if ( !checkFilterTypes(typeName) )
118 : : {
119 [ - + ]: 222 : if ( pOptions->generateTypeList() )
120 : : {
121 : 0 : o << typeName.getStr() << "\n";
122 : : } else
123 : : {
124 [ + - ]: 222 : TypeReader reader = typeMgr.getTypeReader(typeName);
125 : :
126 [ - + ]: 222 : if (!reader.isValid())
127 : : {
128 [ # # ]: 0 : if (typeName.equals("/"))
129 : : {
130 : 0 : return sal_True;
131 : : } else
132 : : {
133 : 0 : return sal_False;
134 : : }
135 : : }
136 [ + - ]: 222 : RegistryKey typeKey;
137 [ + - ][ + - ]: 222 : if ( regKey.createKey( OStringToOUString(typeName, RTL_TEXTENCODING_UTF8), typeKey) )
[ - + ]
138 : : {
139 : 0 : return sal_False;
140 : : }
141 : :
142 [ + - ][ - + ]: 222 : if ( typeKey.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)reader.getBlop(), reader.getBlopSize()) )
143 : : {
144 : 222 : return sal_False;
145 [ + - ][ - + ]: 222 : }
[ + - ][ + - ]
146 : :
147 : : }
148 : : }
149 : :
150 : 222 : typeDependencies.setGenerated(typeName);
151 : : sal_Bool ret = produceDependedTypes(typeName, typeMgr, typeDependencies,
152 : 222 : pOptions, o, regKey, filterTypes);
153 : :
154 : 1510 : return ret;
155 : : }
156 : :
157 : :
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|