1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cunotype.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX_
32 #define INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX
34 #include <codemaker/typemanager.hxx>
35 #include <codemaker/dependency.hxx>
61 CUNOTYPEDECL_ALLTYPES
,
62 CUNOTYPEDECL_NOINTERFACES
,
63 CUNOTYPEDECL_ONLYINTERFACES
72 CunoType(TypeReader
& typeReader
,
73 const ::rtl::OString
& typeName
,
74 const TypeManager
& typeMgr
,
75 const TypeDependency
& typeDependencies
);
79 virtual sal_Bool
dump(CunoOptions
* pOptions
) throw( CannotDumpException
);
80 virtual sal_Bool
dumpDependedTypes(CunoOptions
* pOptions
) throw( CannotDumpException
);
81 virtual sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
) = 0;
82 virtual sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
) = 0;
84 virtual ::rtl::OString
dumpHeaderDefine(FileStream
& o
, sal_Char
* prefix
, sal_Bool bExtended
=sal_False
);
85 virtual void dumpDefaultHIncludes(FileStream
& o
);
86 virtual void dumpDefaultCIncludes(FileStream
& o
);
87 virtual void dumpInclude(FileStream
& o
, const ::rtl::OString
& typeName
, sal_Char
* prefix
, sal_Bool bExtended
=sal_False
, sal_Bool bCaseSensitive
=sal_False
);
88 virtual void dumpDepIncludes(FileStream
& o
, const ::rtl::OString
& typeName
, sal_Char
* prefix
);
90 virtual void dumpOpenExternC(FileStream
& o
);
91 virtual void dumpCloseExternC(FileStream
& o
);
93 virtual void dumpGetCunoType(FileStream
& o
);
94 virtual void dumpCGetCunoType(FileStream
& o
);
95 virtual void dumpLGetCunoType(FileStream
& o
);
97 virtual void dumpType(FileStream
& o
, const ::rtl::OString
& type
, sal_Bool bConst
=sal_False
,
98 sal_Bool bPointer
=sal_False
, sal_Bool bParam
=sal_False
)
99 throw( CannotDumpException
);
100 ::rtl::OString
getTypeClass(const ::rtl::OString
& type
="", sal_Bool bCStyle
=sal_False
);
101 ::rtl::OString
getBaseType(const ::rtl::OString
& type
);
102 void dumpCppuGetType(FileStream
& o
, const ::rtl::OString
& type
, sal_Bool bDecl
=sal_False
, CunoTypeDecl eDeclFlag
=CUNOTYPEDECL_ALLTYPES
);
103 void dumpTypeInit(FileStream
& o
, const ::rtl::OString
& type
);
104 BASETYPE
isBaseType(const ::rtl::OString
& type
);
106 ::rtl::OString
typeToIdentifier(const ::rtl::OString
& type
);
108 void dumpConstantValue(FileStream
& o
, sal_uInt16 index
);
110 virtual sal_uInt32
getMemberCount();
111 virtual sal_uInt32
getInheritedMemberCount();
112 void dumpInheritedMembers(FileStream
& o
, rtl::OString
& superType
);
114 sal_Bool
isSeqType(const ::rtl::OString
& type
, ::rtl::OString
& baseType
, ::rtl::OString
& seqPrefix
);
115 sal_Bool
isArrayType(const ::rtl::OString
& type
, ::rtl::OString
& baseType
, ::rtl::OString
& arrayPrefix
);
116 sal_Bool
isVoid(const ::rtl::OString
& type
)
117 { return type
.equals("void"); }
118 void inc(sal_uInt32 num
=4);
119 void dec(sal_uInt32 num
=4);
120 ::rtl::OString
indent();
121 ::rtl::OString
indent(sal_uInt32 num
);
123 virtual sal_uInt32
checkInheritedMemberCount(const TypeReader
* pReader
);
125 ::rtl::OString
checkSpecialCunoType(const ::rtl::OString
& type
);
126 ::rtl::OString
checkRealBaseType(const ::rtl::OString
& type
, sal_Bool bResolveTypeOnly
= sal_False
);
127 void dumpCppuGetTypeMemberDecl(FileStream
& o
, CunoTypeDecl eDeclFlag
);
129 sal_Bool
isNestedType()
130 { return m_bIsNestedType
; };
132 RegistryKeyNames
& getNestedTypeNames()
133 { return m_nestedTypeNames
; };
135 sal_Bool
isNestedTypeByName(const ::rtl::OString
& type
);
136 sal_Bool
hasNestedType(const ::rtl::OString
& type
);
139 sal_uInt32 m_inheritedMemberCount
;
141 sal_Bool m_cunoTypeLib
;
142 sal_Bool m_cunoTypeLeak
;
143 sal_Bool m_cunoTypeDynamic
;
144 sal_uInt32 m_indentLength
;
145 ::rtl::OString m_typeName
;
146 ::rtl::OString m_name
;
148 TypeManager
& m_typeMgr
;
149 TypeDependency m_dependencies
;
150 sal_Bool m_bIsNestedType
;
151 RegistryKeyNames m_nestedTypeNames
;
154 class InterfaceType
: public CunoType
157 InterfaceType(TypeReader
& typeReader
,
158 const ::rtl::OString
& typeName
,
159 const TypeManager
& typeMgr
,
160 const TypeDependency
& typeDependencies
);
162 virtual ~InterfaceType();
164 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
165 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
166 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
168 void dumpInheritedFunctions(FileStream
& o
, rtl::OString
& superType
);
169 void dumpAttributes(FileStream
& o
, const ::rtl::OString
& interfaceType
, TypeReader
& reader
);
170 void dumpMethods(FileStream
& o
, const ::rtl::OString
& interfaceType
, TypeReader
& reader
);
171 void dumpGetCunoType(FileStream
& o
);
172 void dumpCGetCunoType(FileStream
& o
);
173 void dumpCUnoAttributeTypeNames(FileStream
& o
, sal_Bool bRelease
=sal_False
);
174 void dumpCUnoMethodTypeNames(FileStream
& o
, sal_Bool bRelease
=sal_False
);
175 void dumpCUnoAttributeRefs(FileStream
& o
, sal_uInt32
& index
);
176 void dumpCUnoMethodRefs(FileStream
& o
, sal_uInt32
& index
);
177 void dumpCUnoAttributes(FileStream
& o
, sal_uInt32
& index
);
178 void dumpCUnoMethods(FileStream
& o
, sal_uInt32
& index
);
179 void dumpAttributesCppuDecl(FileStream
& o
, StringSet
* pFinishedTypes
, CunoTypeDecl eDeclFlag
);
180 void dumpMethodsCppuDecl(FileStream
& o
, StringSet
* pFinishedTypes
, CunoTypeDecl eDeclFlag
);
182 sal_uInt32
getMemberCount();
183 sal_uInt32
getInheritedMemberCount();
186 sal_uInt32
checkInheritedMemberCount(const TypeReader
* pReader
);
189 sal_uInt32 m_inheritedMemberCount
;
190 sal_Bool m_hasAttributes
;
191 sal_Bool m_hasMethods
;
194 class ModuleType
: public CunoType
197 ModuleType(TypeReader
& typeReader
,
198 const ::rtl::OString
& typeName
,
199 const TypeManager
& typeMgr
,
200 const TypeDependency
& typeDependencies
);
202 virtual ~ModuleType();
204 virtual sal_Bool
dump(CunoOptions
* pOptions
) throw( CannotDumpException
);
206 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
207 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
208 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
209 sal_Bool
hasConstants();
212 class ConstantsType
: public ModuleType
215 ConstantsType(TypeReader
& typeReader
,
216 const ::rtl::OString
& typeName
,
217 const TypeManager
& typeMgr
,
218 const TypeDependency
& typeDependencies
);
220 virtual ~ConstantsType();
222 virtual sal_Bool
dump(CunoOptions
* pOptions
) throw( CannotDumpException
);
225 class StructureType
: public CunoType
228 StructureType(TypeReader
& typeReader
,
229 const ::rtl::OString
& typeName
,
230 const TypeManager
& typeMgr
,
231 const TypeDependency
& typeDependencies
);
233 virtual ~StructureType();
235 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
236 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
237 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
240 class ExceptionType
: public CunoType
243 ExceptionType(TypeReader
& typeReader
,
244 const ::rtl::OString
& typeName
,
245 const TypeManager
& typeMgr
,
246 const TypeDependency
& typeDependencies
);
248 virtual ~ExceptionType();
250 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
251 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
252 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
255 class EnumType
: public CunoType
258 EnumType(TypeReader
& typeReader
,
259 const ::rtl::OString
& typeName
,
260 const TypeManager
& typeMgr
,
261 const TypeDependency
& typeDependencies
);
265 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
266 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
267 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
269 void dumpGetCunoType(FileStream
& o
);
270 void dumpCGetCunoType(FileStream
& o
);
273 class TypeDefType
: public CunoType
276 TypeDefType(TypeReader
& typeReader
,
277 const ::rtl::OString
& typeName
,
278 const TypeManager
& typeMgr
,
279 const TypeDependency
& typeDependencies
);
281 virtual ~TypeDefType();
283 sal_Bool
dumpDeclaration(FileStream
& o
) throw( CannotDumpException
);
284 sal_Bool
dumpHFile(FileStream
& o
) throw( CannotDumpException
);
285 sal_Bool
dumpCFile(FileStream
& o
) throw( CannotDumpException
);
287 void dumpGetCunoType(FileStream
& o
);
288 void dumpLGetCunoType(FileStream
& o
);
289 void dumpCGetCunoType(FileStream
& o
);
293 sal_Bool
produceType(const ::rtl::OString
& typeName
,
294 TypeManager
& typeMgr
,
295 TypeDependency
& typeDependencies
,
296 CunoOptions
* pOptions
)
297 throw( CannotDumpException
);
300 * This function returns a C++ scoped name, represents the namespace
301 * scoping of this type, e.g. com:.sun::star::uno::XInterface. If the scope of
302 * the type is equal scope, the relativ name will be used.
304 ::rtl::OString
scopedName(const ::rtl::OString
& scope
, const ::rtl::OString
& type
,
305 sal_Bool bNoNameSpace
=sal_False
);
307 ::rtl::OString
shortScopedName(const ::rtl::OString
& scope
, const ::rtl::OString
& type
,
308 sal_Bool bNoNameSpace
=sal_False
);
311 #endif // INCLUDED_CODEMAKER_SOURCE_CUNOMAKER_CUNOTYPE_HXX