1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_IDLC_INC_ASTINTERFACE_HXX
20 #define INCLUDED_IDLC_INC_ASTINTERFACE_HXX
22 #include "asttype.hxx"
23 #include "astscope.hxx"
24 #include "inheritedinterface.hxx"
29 class AstInterface
: public AstType
33 typedef std::vector
< InheritedInterface
> InheritedInterfaces
;
35 struct DoubleMemberDeclaration
{
36 AstDeclaration
const * first
;
37 AstDeclaration
const * second
;
40 typedef std::vector
< DoubleMemberDeclaration
> DoubleMemberDeclarations
;
42 struct DoubleDeclarations
{
43 std::vector
< AstInterface
const * > interfaces
;
44 DoubleMemberDeclarations members
;
48 const OString
& name
, AstInterface
const * pInherits
,
50 virtual ~AstInterface() override
;
52 InheritedInterfaces
const & getAllInheritedInterfaces() const
53 { return m_inheritedInterfaces
; }
55 bool hasMandatoryInheritedInterfaces() const
56 { return m_mandatoryInterfaces
> 0; }
58 void setDefined() { m_bIsDefined
= true; }
59 bool isDefined() const
60 { return m_bIsDefined
; }
62 bool usesSingleInheritance() const { return m_bSingleInheritance
; }
64 DoubleDeclarations
checkInheritedInterfaceClashes(
65 AstInterface
const * ifc
, bool optional
) const;
67 void addInheritedInterface(
68 AstType
const * ifc
, bool optional
,
69 OUString
const & documentation
);
71 DoubleMemberDeclarations
checkMemberClashes(
72 AstDeclaration
const * member
) const;
74 void addMember(AstDeclaration
/*TODO: const*/ * member
);
76 void forwardDefined(AstInterface
const & def
);
78 virtual bool dump(RegistryKey
& rKey
) override
;
82 INTERFACE_INDIRECT_OPTIONAL
, INTERFACE_DIRECT_OPTIONAL
,
83 INTERFACE_INDIRECT_MANDATORY
, INTERFACE_DIRECT_MANDATORY
};
85 struct VisibleMember
{
86 explicit VisibleMember(AstDeclaration
const * theMandatory
= nullptr):
87 mandatory(theMandatory
) {}
89 typedef std::map
< OString
, AstDeclaration
const * > Optionals
;
91 AstDeclaration
const * mandatory
;
95 typedef std::map
< OString
, InterfaceKind
> VisibleInterfaces
;
96 typedef std::map
< OString
, VisibleMember
> VisibleMembers
;
98 void checkInheritedInterfaceClashes(
99 DoubleDeclarations
& doubleDeclarations
,
100 std::set
< OString
> & seenInterfaces
, AstInterface
const * ifc
,
101 bool direct
, bool optional
, bool mainOptional
) const;
103 void checkMemberClashes(
104 DoubleMemberDeclarations
& doubleMembers
, AstDeclaration
const * member
,
105 bool checkOptional
) const;
107 void addVisibleInterface(
108 AstInterface
const * ifc
, bool direct
, bool optional
);
110 void addOptionalVisibleMembers(AstInterface
const * ifc
);
112 bool increment(sal_uInt16
* counter
, char const * sort
) const;
114 InheritedInterfaces m_inheritedInterfaces
;
115 InheritedInterfaces::size_type m_mandatoryInterfaces
;
117 bool m_bSingleInheritance
;
118 VisibleInterfaces m_visibleInterfaces
;
119 VisibleMembers m_visibleMembers
;
122 #endif // INCLUDED_IDLC_INC_ASTINTERFACE_HXX
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */