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: idloptions.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 "idloptions.hxx"
39 sal_Bool
IdlOptions::initOptions(int ac
, char* av
[], sal_Bool bCmdFile
)
40 throw( IllegalArgument
)
42 sal_Bool ret
= sal_True
;
53 fprintf(stderr
, "%s", prepareHelp().getStr());
73 if (i
< ac
- 1 && av
[i
+1][0] != '-')
79 OString
tmp("'-O', please check");
82 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
85 throw IllegalArgument(tmp
);
92 m_options
["-O"] = OString(s
);
97 if (i
< ac
- 1 && av
[i
+1][0] != '-')
103 OString
tmp("'-B', please check");
106 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
109 throw IllegalArgument(tmp
);
116 m_options
["-B"] = OString(s
);
119 if (av
[i
][2] == '\0')
121 if (i
< ac
- 1 && av
[i
+1][0] != '-')
127 OString
tmp("'-T', please check");
130 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
133 throw IllegalArgument(tmp
);
140 if (m_options
.count("-T") > 0)
142 OString
tmp(m_options
["-T"]);
144 m_options
["-T"] = tmp
;
147 m_options
["-T"] = OString(s
);
153 if (av
[i
][3] != '\0')
155 OString
tmp("'-Gc', please check");
158 tmp
+= " your input '" + OString(av
[i
]) + "'";
161 throw IllegalArgument(tmp
);
164 m_options
["-Gc"] = OString("");
167 if (av
[i
][2] != '\0')
169 OString
tmp("'-G', please check");
172 tmp
+= " your input '" + OString(av
[i
]) + "'";
175 throw IllegalArgument(tmp
);
178 m_options
["-G"] = OString("");
181 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
188 FILE* cmdFile
= fopen(av
[i
]+1, "r");
189 if( cmdFile
== NULL
)
191 fprintf(stderr
, "%s", prepareHelp().getStr());
199 while ( fscanf(cmdFile
, "%s", buffer
) != EOF
)
201 rargv
[rargc
]= strdup(buffer
);
206 ret
= initOptions(rargc
, rargv
, bCmdFile
);
208 for (long i
=0; i
< rargc
; i
++)
215 m_inputFiles
.push_back(av
[i
]);
223 OString
IdlOptions::prepareHelp()
225 OString
help("\nusing: ");
226 help
+= m_program
+ " [-options] file_1 ... file_n\nOptions:\n";
227 help
+= " -O<path> = path describes the root directory for the generated output.\n";
228 help
+= " The output directory tree is generated under this directory.\n";
229 help
+= " -T<name> = name specifies a type or a list of types. The output for this\n";
230 help
+= " [t1;...] type is generated. If no '-T' option is specified,\n";
231 help
+= " then output for all types is generated.\n";
232 help
+= " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
233 help
+= " -B<name> = name specifies the base node. All types are searched under this\n";
234 help
+= " node. Default is the root '/' of the registry files.\n";
235 help
+= " -G = generate only target files which does not exists.\n";
236 help
+= " -Gc = generate only target files which content will be changed.\n";
237 help
+= "IMPORTANT: You lose enum values and struct, exception inheritance!\n";
238 help
+= " Parameter name Object is translated to _Object!\n";
239 help
+= " The type type is translated to CORBA::TypeCode!\n";
240 help
+= " Sequences are expanded to a typedef name Sequence_..._\"name\"!\n";
241 help
+= prepareVersion();
246 OString
IdlOptions::prepareVersion()
248 OString
version("\nSun Microsystems (R) ");
249 version
+= m_program
+ " Version 2.0\n\n";