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
)
43 sal_Int32 index
= name
.lastIndexOf(SEPARATOR
);
44 m_program
= name
.copy(index
> 0 ? index
+1 : 0);
48 fprintf(stderr
, "%s", prepareHelp().getStr());
65 if (i
< ac
- 1 && av
[i
+1][0] != '-')
71 OString
tmp("'-O', please check");
74 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
77 throw IllegalArgument(tmp
);
84 m_options
["-O"] = OString(s
);
87 if (av
[i
][2] != 'D' || av
[i
][3] != '\0')
89 OString
tmp("'-nD', please check");
90 tmp
+= " your input '" + OString(av
[i
]) + "'";
91 throw IllegalArgument(tmp
);
94 m_options
["-nD"] = OString();
99 if (i
< ac
- 1 && av
[i
+1][0] != '-')
105 OString
tmp("'-T', please check");
108 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
111 throw IllegalArgument(tmp
);
118 if (m_options
.count("-T") > 0)
120 OString
tmp(m_options
["-T"]);
122 m_options
["-T"] = tmp
;
125 m_options
["-T"] = OString(s
);
131 if (av
[i
][3] != '\0')
133 OString
tmp("'-Gc', please check");
136 tmp
+= " your input '" + OString(av
[i
]) + "'";
139 throw IllegalArgument(tmp
);
142 m_options
["-Gc"] = OString();
144 } else if (av
[i
][2] != '\0')
146 OString
tmp("'-G', please check");
149 tmp
+= " your input '" + OString(av
[i
]) + "'";
152 throw IllegalArgument(tmp
);
155 m_options
["-G"] = OString();
157 case 'X': // support for eXtra type rdbs
159 if (av
[i
][2] == '\0')
161 if (i
< ac
- 1 && av
[i
+1][0] != '-')
167 OString
tmp("'-X', please check");
170 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
173 throw IllegalArgument(tmp
);
180 m_extra_input_files
.emplace_back(s
);
185 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
191 FILE* cmdFile
= fopen(av
[i
]+1, "r");
192 if( cmdFile
== nullptr )
194 fprintf(stderr
, "%s", prepareHelp().getStr());
202 while (fscanf(cmdFile
, "%511s", buffer
) != EOF
&& rargc
< 512)
204 rargv
[rargc
]= strdup(buffer
);
209 ret
= initOptions(rargc
, rargv
, bCmdFile
);
211 for (int j
=0; j
< rargc
; j
++)
218 m_inputFiles
.emplace_back(av
[i
]);
226 OString
JavaOptions::prepareHelp()
228 OString
help("\nusing: ");
229 help
+= m_program
+ " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n"
230 " -O<path> = path describes the root directory for the generated output.\n"
231 " The output directory tree is generated under this directory.\n"
232 " -T<name> = name specifies a type or a list of types. The output for this\n"
233 " [t1;...] type and all dependent types are generated. If no '-T' option is\n"
234 " specified, then output for all types is generated.\n"
235 " Example: 'com.sun.star.uno.XInterface' is a valid type.\n"
236 " -nD = no dependent types are generated.\n"
237 " -G = generate only target files which does not exists.\n"
238 " -Gc = generate only target files which content will be changed.\n"
239 " -X<file> = extra types which will not be taken into account for generation.\n\n";
240 help
+= prepareVersion();
245 OString
JavaOptions::prepareVersion() const
247 OString
version(m_program
);
248 version
+= " Version 2.0\n\n";
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */