xref: /trunk/main/autodoc/source/parser/cpp/pe_vari.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
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 #ifndef ADC_CPP_PE_VARI_HXX
29 #define ADC_CPP_PE_VARI_HXX
30 
31 
32 
33 // USED SERVICES
34     // BASE CLASSES
35 #include "cpp_pe.hxx"
36     // COMPONENTS
37 #include <semantic/callf.hxx>
38 #include <semantic/sub_peu.hxx>
39 #include <ary/cpp/c_types4cpp.hxx>
40 #include <ary/cpp/c_vfflag.hxx>
41     // PARAMETERS
42 
43 
44 namespace cpp {
45 
46 class PE_Expression;
47 
48 
49 class PE_Variable : public Cpp_PE
50 {
51   public:
52     enum E_State
53     {
54         afterName,                  //
55         afterSize,                  // after ]
56         expectFinish,               // after InitExpression
57         size_of_states
58     };
59                         PE_Variable(
60                             Cpp_PE *            i_pParent );
61                         ~PE_Variable();
62 
63     /** @return
64         Bit 0x0001 != 0, if there is a size and
65         bit 0x0002 != 0, if there is an initialisation.
66     */
67     UINT16              Result_Pattern() const;
68     const String  &     Result_SizeExpression() const;
69     const String  &     Result_InitExpression() const;
70 
71     virtual void        Call_Handler(
72                             const cpp::Token &  i_rTok );
73 
74   private:
75     typedef SubPe< PE_Variable, PE_Expression >         SP_Expression;
76     typedef SubPeUse< PE_Variable, PE_Expression>       SPU_Expression;
77 
78     void                Setup_StatusFunctions();
79     virtual void        InitData();
80     virtual void        TransferData();
81     void                Hdl_SyntaxError(const char *);
82 
83     void                SpReturn_ArraySizeExpression();
84     void                SpReturn_InitExpression();
85 
86     void                On_afterName_ArrayBracket_Left(const char * i_sText);
87     void                On_afterName_Semicolon(const char * i_sText);
88     void                On_afterName_Comma(const char * i_sText);
89     void                On_afterName_Assign(const char * i_sText);
90 
91     void                On_afterSize_ArrayBracket_Right(const char * i_sText);
92 
93     void                On_expectFinish_Semicolon(const char * i_sText);
94     void                On_expectFinish_Comma(const char * i_sText);
95     void                On_expectFinish_Bracket_Right(const char * i_sText);
96 
97     // DATA
98     Dyn< PeStatusArray<PE_Variable> >
99                         pStati;
100 
101     Dyn<SP_Expression>  pSpExpression;
102     Dyn<SPU_Expression> pSpuArraySizeExpression;
103     Dyn<SPU_Expression> pSpuInitExpression;
104 
105     String              sResultSizeExpression;
106     String              sResultInitExpression;
107 };
108 
109 
110 
111 // IMPLEMENTATION
112 
113 
114 inline UINT16
115 PE_Variable::Result_Pattern() const
116     { return ( sResultSizeExpression.length() > 0 ? 1 : 0 )
117              + ( sResultInitExpression.length() > 0 ? 2 : 0 ); }
118 inline const String  &
119 PE_Variable::Result_SizeExpression() const
120     { return sResultSizeExpression; }
121 inline const String  &
122 PE_Variable::Result_InitExpression() const
123     { return sResultInitExpression; }
124 
125 
126 }   // namespace cpp
127 
128 
129 #endif
130 
131