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 sal_Bool
JavaOptions::initOptions(int ac
, char* av
[], sal_Bool bCmdFile
)
34 throw( IllegalArgument
)
36 sal_Bool ret
= sal_True
;
44 sal_Int32 index
= name
.lastIndexOf(SEPARATOR
);
45 m_program
= name
.copy((index
> 0 ? index
+1 : 0));
49 fprintf(stderr
, "%s", prepareHelp().getStr());
69 if (i
< ac
- 1 && av
[i
+1][0] != '-')
75 OString
tmp("'-O', please check");
78 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
81 throw IllegalArgument(tmp
);
88 m_options
["-O"] = OString(s
);
91 if (av
[i
][2] != 'D' || av
[i
][3] != '\0')
93 OString
tmp("'-nD', please check");
94 tmp
+= " your input '" + OString(av
[i
]) + "'";
95 throw IllegalArgument(tmp
);
98 m_options
["-nD"] = OString("");
101 if (av
[i
][2] == '\0')
103 if (i
< ac
- 1 && av
[i
+1][0] != '-')
109 OString
tmp("'-T', please check");
112 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
115 throw IllegalArgument(tmp
);
122 if (m_options
.count("-T") > 0)
124 OString
tmp(m_options
["-T"]);
126 m_options
["-T"] = tmp
;
129 m_options
["-T"] = OString(s
);
135 if (av
[i
][3] != '\0')
137 OString
tmp("'-Gc', please check");
140 tmp
+= " your input '" + OString(av
[i
]) + "'";
143 throw IllegalArgument(tmp
);
146 m_options
["-Gc"] = OString("");
148 } else if (av
[i
][2] != '\0')
150 OString
tmp("'-G', please check");
153 tmp
+= " your input '" + OString(av
[i
]) + "'";
156 throw IllegalArgument(tmp
);
159 m_options
["-G"] = OString("");
161 case 'X': // support for eXtra type rdbs
163 if (av
[i
][2] == '\0')
165 if (i
< ac
- 1 && av
[i
+1][0] != '-')
171 OString
tmp("'-X', please check");
174 tmp
+= " your input '" + OString(av
[i
+1]) + "'";
177 throw IllegalArgument(tmp
);
184 m_extra_input_files
.push_back( s
);
189 throw IllegalArgument("the option is unknown" + OString(av
[i
]));
195 FILE* cmdFile
= fopen(av
[i
]+1, "r");
196 if( cmdFile
== NULL
)
198 fprintf(stderr
, "%s", prepareHelp().getStr());
206 while ( fscanf(cmdFile
, "%s", buffer
) != EOF
)
208 rargv
[rargc
]= strdup(buffer
);
213 ret
= initOptions(rargc
, rargv
, bCmdFile
);
215 for (long j
=0; j
< rargc
; j
++)
224 m_inputFiles
.push_back(av
[i
]);
227 OUString system_filepath
;
228 if (osl_getCommandArg( i
-1, &system_filepath
.pData
)
229 != osl_Process_E_None
)
233 m_inputFiles
.push_back(OUStringToOString(system_filepath
, osl_getThreadTextEncoding()));
242 OString
JavaOptions::prepareHelp()
244 OString
help("\nusing: ");
245 help
+= m_program
+ " [-options] file_1 ... file_n -Xfile_n+1 -Xfile_n+2\nOptions:\n";
246 help
+= " -O<path> = path describes the root directory for the generated output.\n";
247 help
+= " The output directory tree is generated under this directory.\n";
248 help
+= " -T<name> = name specifies a type or a list of types. The output for this\n";
249 help
+= " [t1;...] type and all dependent types are generated. If no '-T' option is \n";
250 help
+= " specified, then output for all types is generated.\n";
251 help
+= " Example: 'com.sun.star.uno.XInterface' is a valid type.\n";
252 help
+= " -nD = no dependent types are generated.\n";
253 help
+= " -G = generate only target files which does not exists.\n";
254 help
+= " -Gc = generate only target files which content will be changed.\n";
255 help
+= " -X<file> = extra types which will not be taken into account for generation.\n\n";
256 help
+= prepareVersion();
261 OString
JavaOptions::prepareVersion()
263 OString
version(m_program
);
264 version
+= " Version 2.0\n\n";
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */