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