KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > task > CPPoptions


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): ________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.task;
28
29 //Package dependencies
30
import java.util.Iterator JavaDoc;
31
32
33 /**
34  * This class manages PreProcessor Options.
35  *
36  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
37  *
38  * @version 0.1
39  */

40 public class CPPoptions
41 {
42     // ==================================================================
43
//
44
// Internal states.
45
//
46
// ==================================================================
47

48     /** Inhibit generation of #-lines with line-number information if true. */
49     private boolean line_info_;
50
51     /** List of macros to define. */
52     private java.util.List JavaDoc defines_;
53
54     /** List of macros to undefine. */
55     private java.util.List JavaDoc undefines_;
56
57     /** List of pathes to include. */
58     private java.util.List JavaDoc includes_;
59
60     // ==================================================================
61
//
62
// Constructors.
63
//
64
// ==================================================================
65

66     /**
67      * The default constructor.
68      */

69     public CPPoptions()
70     {
71         // Init internal states
72
line_info_ = false;
73         defines_ = new java.util.ArrayList JavaDoc();
74         undefines_ = new java.util.ArrayList JavaDoc();
75         includes_ = new java.util.ArrayList JavaDoc();
76     }
77     
78     // ==================================================================
79
//
80
// Internal methods.
81
//
82
// ==================================================================
83

84     /**
85      * Get Launcher arguments declaration.
86      *
87      * @return Launcher arguments declaration string.
88      */

89     protected String JavaDoc
90     getCPParguments()
91     {
92         String JavaDoc args = "";
93         MacroType macro = null;
94         
95         for (Iterator JavaDoc it = defines_.iterator(); it.hasNext();)
96         {
97             macro = (MacroType) it.next();
98             args += "-D" + macro.getName();
99             if (macro.getValue() != null)
100                 args += "=" + macro.getValue();
101             args += " ";
102         }
103         for (Iterator JavaDoc it = undefines_.iterator(); it.hasNext();)
104         {
105             args += "-U" + it.next() + " ";
106         }
107         for (Iterator JavaDoc it = includes_.iterator(); it.hasNext();)
108         {
109             args += "-I" + it.next() + " ";
110         }
111         if (line_info_)
112             args += "-P ";
113         
114         return args;
115     }
116
117     // ==================================================================
118
//
119
// Public methods.
120
//
121
// ==================================================================
122

123     /**
124      * Inhibit generation of #-lines with line-number information if true (-P).
125      *
126      * @param b - The value to set.
127      */

128     public void
129     setLineinfo(boolean b)
130     {
131         line_info_ = b;
132     }
133     
134     /**
135      * Define a new macro (-D).
136      * Default is 1.
137      *
138      * @param outputdir - The output directory name.
139      */

140     public void
141     addConfiguredDefine(MacroType macro)
142     {
143         defines_.add(macro);
144     }
145     
146     /**
147      * Remove any definition for name (-U).
148      *
149      * @param str - The macro name to undefine.
150      */

151     public void
152     addConfiguredUndefine(StringType str)
153     {
154         undefines_.add(str.getName());
155     }
156     
157     /**
158      * Put dir in the include file search path(-I).
159      *
160      * @param dir - The macro name to undefine.
161      */

162     public void
163     addConfiguredIncludepath(StringType dir)
164     {
165         includes_.add(dir.getName());
166     }
167     
168 }
169
Popular Tags