1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cunooptions.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_codemaker.hxx"
35 #include "cunooptions.hxx"
39 sal_Bool
CunoOptions::initOptions(int ac
, char* av
[], sal_Bool bCmdFile
)
40 throw( IllegalArgument
)
42 sal_Bool ret
= sal_True
;
53 fprintf(stderr
, "%s", prepareHelp().getStr());
75 if (i
< ac
- 1 && av
[i
+1][0] != '-')
81 OString
tmp("'-OC', please check");
84 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
87 throw IllegalArgument(tmp
);
94 m_options
["-OC"] = OString(s
);
99 if (i
< ac
- 1 && av
[i
+1][0] != '-')
105 OString
tmp("'-O', please check");
108 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
111 throw IllegalArgument(tmp
);
118 m_options
["-O"] = OString(s
);
121 if (av
[i
][2] == '\0')
123 if (i
< ac
- 1 && av
[i
+1][0] != '-')
129 OString
tmp("'-B', please check");
132 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
135 throw IllegalArgument(tmp
);
142 m_options
["-B"] = OString(s
);
145 if (av
[i
][2] == '\0')
147 if (i
< ac
- 1 && av
[i
+1][0] != '-')
153 OString
tmp("'-T', please check");
156 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
159 throw IllegalArgument(tmp
);
166 if (m_options
.count("-T") > 0)
168 OString
tmp(m_options
["-T"]);
170 m_options
["-T"] = tmp
;
173 m_options
["-T"] = OString(s
);
177 if (av
[i
][2] != '\0')
179 OString
tmp("'-U', please check");
182 tmp
+= " your input '" + OString(av
[i
]) + "'";
185 throw IllegalArgument(tmp
);
188 m_options
["-U"] = OString("");
192 if (av[i][2] != '\0')
194 OString tmp("'-L', please check");
197 tmp += " your input '" + OString(av[i]) + "'";
200 throw IllegalArgument(tmp);
203 if (isValid("-C") || isValid("-CS"))
205 OString tmp("'-L' could not be combined with '-C' or '-CS' option");
206 throw IllegalArgument(tmp);
208 m_options["-L"] = OString("");
212 if (av
[i
][2] != '\0')
214 OString
tmp("'-C', please check");
217 tmp
+= " your input '" + OString(av
[i
]) + "'";
220 throw IllegalArgument(tmp
);
223 if (isValid("-L") || isValid("-CS"))
225 OString
tmp("'-C' could not be combined with '-L' or '-CS' option");
226 throw IllegalArgument(tmp
);
228 m_options
["-C"] = OString("");
233 if (av
[i
][3] != '\0')
235 OString
tmp("'-Gc', please check");
238 tmp
+= " your input '" + OString(av
[i
]) + "'";
241 throw IllegalArgument(tmp
);
244 m_options
["-Gc"] = OString("");
247 if (av
[i
][2] != '\0')
249 OString
tmp("'-G', please check");
252 tmp
+= " your input '" + OString(av
[i
]) + "'";
255 throw IllegalArgument(tmp
);
258 m_options
["-G"] = OString("");
261 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
268 FILE* cmdFile
= fopen(av
[i
]+1, "r");
269 if( cmdFile
== NULL
)
271 fprintf(stderr
, "%s", prepareHelp().getStr());
279 while ( fscanf(cmdFile
, "%s", buffer
) != EOF
)
281 rargv
[rargc
]= strdup(buffer
);
286 ret
= initOptions(rargc
, rargv
, bCmdFile
);
288 for (long i
=0; i
< rargc
; i
++)
295 m_inputFiles
.push_back(av
[i
]);
303 OString
CunoOptions::prepareHelp()
305 OString
help("\nusing: ");
306 help
+= m_program
+ " [-options] file_1 ... file_n\nOptions:\n";
307 help
+= " -O<path> = path describes the root directory for the generated output.\n";
308 help
+= " The output directory tree is generated under this directory.\n";
309 help
+= " -T<name> = name specifies a type or a list of types. The output for this\n";
310 help
+= " [t1;...] type is generated. If no '-T' option is specified,\n";
311 help
+= " then output for all types is generated.\n";
312 help
+= " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
313 help
+= " -B<name> = name specifies the base node. All types are searched under this\n";
314 help
+= " node. Default is the root '/' of the registry files.\n";
315 help
+= " -U = activate the generating of a getCppuType_<name> function.\n";
316 // help += " -L = getCppuType function with a known leak.\n";
317 help
+= " -C = getCppuType_<name> function keeps comprehensive type information.\n";
318 help
+= " -G = generate only target files which does not exists.\n";
319 help
+= " -Gc = generate only target files which content will be changed.\n";
320 help
+= prepareVersion();
325 OString
CunoOptions::prepareVersion()
327 OString
version("\nSun Microsystems (R) ");
328 version
+= m_program
+ " Version 1.0\n\n";