xref: /aoo4110/main/idlc/inc/idlc/astattribute.hxx (revision b1cdbd2c)
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 #ifndef _IDLC_ASTATTRIBUTE_HXX_
24 #define _IDLC_ASTATTRIBUTE_HXX_
25 
26 #include <idlc/astdeclaration.hxx>
27 #include "idlc/astscope.hxx"
28 
29 #include "registry/types.h"
30 #include "rtl/ustring.hxx"
31 
32 namespace typereg { class Writer; }
33 
34 class AstAttribute: public AstDeclaration, public AstScope {
35 public:
AstAttribute(sal_uInt32 flags,AstType const * type,rtl::OString const & name,AstScope * scope)36     AstAttribute(
37         sal_uInt32 flags, AstType const * type, rtl::OString const & name,
38         AstScope * scope):
39         AstDeclaration(NT_attribute, name, scope),
40         AstScope(NT_attribute), m_flags(flags), m_pType(type)
41     {}
42 
AstAttribute(NodeType nodeType,sal_uInt32 flags,AstType const * pType,const::rtl::OString & name,AstScope * pScope)43     AstAttribute(NodeType nodeType, sal_uInt32 flags, AstType const * pType, const ::rtl::OString& name, AstScope* pScope)
44 		: AstDeclaration(nodeType, name, pScope), AstScope(nodeType)
45 		, m_flags(flags)
46 		, m_pType(pType)
47 		{}
~AstAttribute()48 	virtual ~AstAttribute() {}
49 
setExceptions(rtl::OUString const * getDoc,DeclList const * getExc,rtl::OUString const * setDoc,DeclList const * setExc)50     void setExceptions(
51         rtl::OUString const * getDoc, DeclList const * getExc,
52         rtl::OUString const * setDoc, DeclList const * setExc)
53     {
54         if (getDoc != 0) {
55             m_getDocumentation = *getDoc;
56         }
57         if (getExc != 0) {
58             m_getExceptions = *getExc;
59         }
60         if (setDoc != 0) {
61             m_setDocumentation = *setDoc;
62         }
63         if (setExc != 0) {
64             m_setExceptions = *setExc;
65         }
66     }
67 
getGetExceptionCount() const68     DeclList::size_type getGetExceptionCount() const
69     { return m_getExceptions.size(); }
70 
getSetExceptionCount() const71     DeclList::size_type getSetExceptionCount() const
72     { return m_setExceptions.size(); }
73 
getType() const74     AstType const * getType() const
75 		{ return m_pType; }
isReadonly() const76 	sal_Bool isReadonly() const
77 		{ return ((m_flags & AF_READONLY) == AF_READONLY); }
isOptional() const78 	sal_Bool isOptional() const
79 		{ return ((m_flags & AF_OPTIONAL) == AF_OPTIONAL); }
isAttribute() const80 	sal_Bool isAttribute() const
81 		{ return ((m_flags & AF_ATTRIBUTE) == AF_ATTRIBUTE); }
isProperty() const82 	sal_Bool isProperty() const
83 		{ return ((m_flags & AF_PROPERTY) == AF_PROPERTY); }
isBound() const84 	sal_Bool isBound() const
85 		{ return ((m_flags & AF_BOUND) == AF_BOUND); }
isMayBeVoid() const86 	sal_Bool isMayBeVoid() const
87 		{ return ((m_flags & AF_MAYBEVOID) == AF_MAYBEVOID); }
isConstrained() const88 	sal_Bool isConstrained() const
89 		{ return ((m_flags & AF_CONSTRAINED) == AF_CONSTRAINED); }
isTransient() const90 	sal_Bool isTransient() const
91 		{ return ((m_flags & AF_TRANSIENT) == AF_TRANSIENT); }
isMayBeAmbiguous() const92 	sal_Bool isMayBeAmbiguous() const
93 		{ return ((m_flags & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS); }
isMayBeDefault() const94 	sal_Bool isMayBeDefault() const
95 		{ return ((m_flags & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT); }
isRemoveable() const96 	sal_Bool isRemoveable() const
97 		{ return ((m_flags & AF_REMOVEABLE) == AF_REMOVEABLE); }
98 
99 	sal_Bool dumpBlob(
100         typereg::Writer & rBlob, sal_uInt16 index, sal_uInt16 * methodIndex);
101 
102 private:
103     void dumpExceptions(
104         typereg::Writer & writer, rtl::OUString const & documentation,
105         DeclList const & exceptions, RTMethodMode flags,
106         sal_uInt16 * methodIndex);
107 
108 	const sal_uInt32 	m_flags;
109     AstType const * m_pType;
110     rtl::OUString m_getDocumentation;
111     DeclList m_getExceptions;
112     rtl::OUString m_setDocumentation;
113     DeclList m_setExceptions;
114 };
115 
116 #endif // _IDLC_ASTATTRIBUTE_HXX_
117 
118