--- /dev/null
+/*\r
+ * \r
+ * Copyright 2001-2004 The Ant-Contrib project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package net.sf.antcontrib.cpptasks.types;\r
+\r
+import org.apache.tools.ant.types.EnumeratedAttribute;\r
+import java.io.File;\r
+/**\r
+ * An compiler/linker command line flag.\r
+ */\r
+public class CommandLineArgument {\r
+ /**\r
+ * Enumerated attribute with the values "start", "mid" and "end",\r
+ */\r
+ public static class LocationEnum extends EnumeratedAttribute {\r
+ public String[] getValues() {\r
+ return new String[]{"start", "mid", "end"};\r
+ }\r
+ }\r
+ private String ifCond;\r
+ private int location;\r
+ private String unlessCond;\r
+ private String value;\r
+ private File file;\r
+ public CommandLineArgument() {\r
+ }\r
+ public int getLocation() {\r
+ return location;\r
+ }\r
+ public String getValue() {\r
+ return value;\r
+ }\r
+ public File getFile() {\r
+ return file;\r
+ }\r
+ /**\r
+ * Returns true if the define's if and unless conditions (if any) are\r
+ * satisfied.\r
+ */\r
+ public boolean isActive(org.apache.tools.ant.Project p) {\r
+ if (value == null) {\r
+ return false;\r
+ }\r
+ if (ifCond != null && p.getProperty(ifCond) == null) {\r
+ return false;\r
+ } else if (unlessCond != null && p.getProperty(unlessCond) != null) {\r
+ return false;\r
+ }\r
+ return true;\r
+ }\r
+ /**\r
+ * Sets the property name for the 'if' condition.\r
+ * \r
+ * The argument will be ignored unless the property is defined.\r
+ * \r
+ * The value of the property is insignificant, but values that would imply\r
+ * misinterpretation ("false", "no") will throw an exception when\r
+ * evaluated.\r
+ */\r
+ public void setIf(String propName) {\r
+ ifCond = propName;\r
+ }\r
+ /**\r
+ * Specifies relative location of argument on command line. "start" will\r
+ * place argument at start of command line, "mid" will place argument after\r
+ * all "start" arguments but before filenames, "end" will place argument\r
+ * after filenames.\r
+ * \r
+ */\r
+ public void setLocation(LocationEnum location) {\r
+ this.location = location.getIndex();\r
+ }\r
+ /**\r
+ * Set the property name for the 'unless' condition.\r
+ * \r
+ * If named property is set, the argument will be ignored.\r
+ * \r
+ * The value of the property is insignificant, but values that would imply\r
+ * misinterpretation ("false", "no") of the behavior will throw an\r
+ * exception when evaluated.\r
+ * \r
+ * @param propName\r
+ * name of property\r
+ */\r
+ public void setUnless(String propName) {\r
+ unlessCond = propName;\r
+ }\r
+ /**\r
+ * Specifies the string that should appear on the command line. The\r
+ * argument will be quoted if it contains embedded blanks. Use multiple\r
+ * arguments to avoid quoting.\r
+ * \r
+ */\r
+ public void setValue(String value) {\r
+ this.value = value;\r
+ }\r
+ /**\r
+ * Specifies the file which lists many strings that should appear on \r
+ * the command line. Each line is one argument. The argument will be \r
+ * quated if it contains embedded blanks. Use multiple arguments in \r
+ * file to avoid quating. \r
+ * \r
+ * @param file\r
+ * name of the file\r
+ */\r
+ public void setFile(File file) {\r
+ this.file = file;\r
+ }\r
+}\r