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: javaoptions.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 "javaoptions.hxx"
36 #include "osl/process.h"
37 #include "osl/thread.h"
41 sal_Bool
JavaOptions::initOptions(int ac
, char* av
[], sal_Bool bCmdFile
)
42 throw( IllegalArgument
)
44 sal_Bool ret
= sal_True
;
55 fprintf(stderr
, "%s", prepareHelp().getStr());
75 if (i
< ac
- 1 && av
[i
+1][0] != '-')
81 OString
tmp("'-O', please check");
84 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
87 throw IllegalArgument(tmp
);
94 m_options
["-O"] = OString(s
);
99 if (i
< ac
- 1 && av
[i
+1][0] != '-')
105 OString
tmp("'-B', please check");
108 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
111 throw IllegalArgument(tmp
);
118 m_options
["-B"] = OString(s
);
121 if (av
[i
][2] != 'D' || av
[i
][3] != '\0')
123 OString
tmp("'-nD', please check");
124 tmp
+= " your input '" + OString(av
[i
]) + "'";
125 throw IllegalArgument(tmp
);
128 m_options
["-nD"] = OString("");
131 if (av
[i
][2] == '\0')
133 if (i
< ac
- 1 && av
[i
+1][0] != '-')
139 OString
tmp("'-T', please check");
142 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
145 throw IllegalArgument(tmp
);
152 if (m_options
.count("-T") > 0)
154 OString
tmp(m_options
["-T"]);
156 m_options
["-T"] = tmp
;
159 m_options
["-T"] = OString(s
);
165 if (av
[i
][3] != '\0')
167 OString
tmp("'-Gc', please check");
170 tmp
+= " your input '" + OString(av
[i
]) + "'";
173 throw IllegalArgument(tmp
);
176 m_options
["-Gc"] = OString("");
179 if (av
[i
][2] != '\0')
181 OString
tmp("'-G', please check");
184 tmp
+= " your input '" + OString(av
[i
]) + "'";
187 throw IllegalArgument(tmp
);
190 m_options
["-G"] = OString("");
192 case 'X': // support for eXtra type rdbs
194 if (av
[i
][2] == '\0')
196 if (i
< ac
- 1 && av
[i
+1][0] != '-')
202 OString
tmp("'-X', please check");
205 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
208 throw IllegalArgument(tmp
);
215 m_extra_input_files
.push_back( s
);
220 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
226 FILE* cmdFile
= fopen(av
[i
]+1, "r");
227 if( cmdFile
== NULL
)
229 fprintf(stderr
, "%s", prepareHelp().getStr());
237 while ( fscanf(cmdFile
, "%s", buffer
) != EOF
)
239 rargv
[rargc
]= strdup(buffer
);
244 ret
= initOptions(rargc
, rargv
, bCmdFile
);
246 for (long j
=0; j
< rargc
; j
++)
255 m_inputFiles
.push_back(av
[i
]);
258 OUString system_filepath
;
259 if (osl_getCommandArg( i
-1, &system_filepath
.pData
)
260 != osl_Process_E_None
)
264 m_inputFiles
.push_back(OUStringToOString(system_filepath
, osl_getThreadTextEncoding()));
273 OString
JavaOptions::prepareHelp()
275 OString
help("\nusing: ");
276 help
+= m_program
+ " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n";
277 help
+= " -O<path> = path describes the root directory for the generated output.\n";
278 help
+= " The output directory tree is generated under this directory.\n";
279 help
+= " -T<name> = name specifies a type or a list of types. The output for this\n";
280 help
+= " [t1;...] type and all dependent types are generated. If no '-T' option is \n";
281 help
+= " specified, then output for all types is generated.\n";
282 help
+= " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
283 help
+= " -B<name> = name specifies the base node. All types are searched under this\n";
284 help
+= " node. Default is the root '/' of the registry files.\n";
285 help
+= " -nD = no dependent types are generated.\n";
286 help
+= " -G = generate only target files which does not exists.\n";
287 help
+= " -Gc = generate only target files which content will be changed.\n";
288 help
+= " -X<file> = extra types which will not be taken into account for generation.\n";
289 help
+= prepareVersion();
294 OString
JavaOptions::prepareVersion()
296 OString
version("\nSun Microsystems (R) ");
297 version
+= m_program
+ " Version 2.0\n\n";