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 
24 #ifndef ADC_CPP_DEFDESCR_HXX
25 #define ADC_CPP_DEFDESCR_HXX
26 
27 
28 
29 
30 namespace cpp
31 {
32 
33 /** Describes a C/C++ #define statement. May be a define or a macro, for which
34     two cases the two different constructors are to be used.
35 
36     This class is used by cpp::PreProcessor.
37 */
38 class DefineDescription
39 {
40   public:
41     enum E_DefineType
42     {
43         type_define,
44         type_macro
45     };
46     typedef StringVector str_vector;
47 
48                         DefineDescription(      /// Used for: #define DEFINE xyz
49                             const String  &     i_sName,
50                             const str_vector &  i_rDefinition );
51                         DefineDescription(      /// Used for: #define MACRO(...) abc
52                             const String  &     i_sName,
53                             const str_vector &  i_rParams,
54                             const str_vector &  i_rDefinition );
55                         ~DefineDescription();
56 
57     /// Only vaild if (eDefineType == type_define) else returns "".
58     void                GetDefineText(
59                             csv::StreamStr &    o_rText ) const;
60 
61     /// Only vaild if (eDefineType == type_macro) else returns "".
62     void                GetMacroText(
63                             csv::StreamStr &    o_rText,
64                             const StringVector &
65                                                 i_rGivenArguments ) const;
66 
67     uintt               ParamCount() const;
68     E_DefineType        DefineType() const;
69 
70   private:
71     // DATA
72     String              sName;
73     str_vector          aParams;
74     str_vector          aDefinition;
75     E_DefineType        eDefineType;
76 };
77 
78 
79 
80 
81 // IMPLEMENTATION
82 inline uintt
ParamCount() const83 DefineDescription::ParamCount() const
84     { return aParams.size(); }
85 inline DefineDescription::E_DefineType
DefineType() const86 DefineDescription::DefineType() const
87     { return eDefineType; }
88 
89 
90 
91 
92 }   // end namespace cpp
93 #endif
94