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