1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "javaoptions.hxx"
23 #include "osl/process.h"
24 #include "osl/thread.h"
30 #define SEPARATOR '\\'
33 bool JavaOptions::initOptions(int ac
, char* av
[], bool bCmdFile
)
34 throw( IllegalArgument
)
44 sal_Int32 index
= name
.lastIndexOf(SEPARATOR
);
45 m_program
= name
.copy((index
> 0 ? index
+1 : 0));
49 fprintf(stderr
, "%s", prepareHelp().getStr());
66 if (i
< ac
- 1 && av
[i
+1][0] != '-')
72 OString
tmp("'-O', please check");
75 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
78 throw IllegalArgument(tmp
);
85 m_options
["-O"] = OString(s
);
88 if (av
[i
][2] != 'D' || av
[i
][3] != '\0')
90 OString
tmp("'-nD', please check");
91 tmp
+= " your input '" + OString(av
[i
]) + "'";
92 throw IllegalArgument(tmp
);
95 m_options
["-nD"] = OString("");
100 if (i
< ac
- 1 && av
[i
+1][0] != '-')
106 OString
tmp("'-T', please check");
109 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
112 throw IllegalArgument(tmp
);
119 if (m_options
.count("-T") > 0)
121 OString
tmp(m_options
["-T"]);
123 m_options
["-T"] = tmp
;
126 m_options
["-T"] = OString(s
);
132 if (av
[i
][3] != '\0')
134 OString
tmp("'-Gc', please check");
137 tmp
+= " your input '" + OString(av
[i
]) + "'";
140 throw IllegalArgument(tmp
);
143 m_options
["-Gc"] = OString("");
145 } else if (av
[i
][2] != '\0')
147 OString
tmp("'-G', please check");
150 tmp
+= " your input '" + OString(av
[i
]) + "'";
153 throw IllegalArgument(tmp
);
156 m_options
["-G"] = OString("");
158 case 'X': // support for eXtra type rdbs
160 if (av
[i
][2] == '\0')
162 if (i
< ac
- 1 && av
[i
+1][0] != '-')
168 OString
tmp("'-X', please check");
171 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
174 throw IllegalArgument(tmp
);
181 m_extra_input_files
.push_back( s
);
186 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
192 FILE* cmdFile
= fopen(av
[i
]+1, "r");
193 if( cmdFile
== nullptr )
195 fprintf(stderr
, "%s", prepareHelp().getStr());
203 while (fscanf(cmdFile
, "%511s", buffer
) != EOF
&& rargc
< 512)
205 rargv
[rargc
]= strdup(buffer
);
210 ret
= initOptions(rargc
, rargv
, bCmdFile
);
212 for (long j
=0; j
< rargc
; j
++)
219 m_inputFiles
.push_back(av
[i
]);
227 OString
JavaOptions::prepareHelp()
229 OString
help("\nusing: ");
230 help
+= m_program
+ " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n"
231 " -O<path> = path describes the root directory for the generated output.\n"
232 " The output directory tree is generated under this directory.\n"
233 " -T<name> = name specifies a type or a list of types. The output for this\n"
234 " [t1;...] type and all dependent types are generated. If no '-T' option is\n"
235 " specified, then output for all types is generated.\n"
236 " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"
237 " -nD = no dependent types are generated.\n"
238 " -G = generate only target files which does not exists.\n"
239 " -Gc = generate only target files which content will be changed.\n"
240 " -X<file> = extra types which will not be taken into account for generation.\n\n";
241 help
+= prepareVersion();
246 OString
JavaOptions::prepareVersion()
248 OString
version(m_program
);
249 version
+= " Version 2.0\n\n";
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */