Bump version to 24.04.3.4
[LibreOffice.git] / codemaker / source / javamaker / javamaker.cxx
blob177069d5b1eafe54215bf1df3b3d3372d8cc76ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <sal/config.h>
22 #include <cstdlib>
23 #include <cstring>
24 #include <iostream>
25 #include <vector>
27 #include <codemaker/generatedtypeset.hxx>
28 #include <codemaker/typemanager.hxx>
29 #include <rtl/ref.hxx>
30 #include <rtl/string.hxx>
31 #include <rtl/ustring.hxx>
32 #include <sal/main.h>
33 #include <sal/types.h>
34 #include <unoidl/unoidl.hxx>
35 #include <o3tl/string_view.hxx>
37 #include "javaoptions.hxx"
38 #include "javatype.hxx"
40 // coverity[tainted_data] - this is a build time tool
41 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) {
42 JavaOptions options;
43 try {
44 if (!options.initOptions(argc, argv)) {
45 return EXIT_FAILURE;
48 rtl::Reference typeMgr(new TypeManager);
49 for (const OString& i : options.getExtraInputFiles())
51 typeMgr->loadProvider(convertToFileUrl(i), false);
53 for (const OString& i : options.getInputFiles())
55 typeMgr->loadProvider(convertToFileUrl(i), true);
57 codemaker::GeneratedTypeSet generated;
58 if (options.isValid("-T"_ostr)) {
59 OUString names(b2u(options.getOption("-T"_ostr)));
60 for (sal_Int32 i = 0; i != -1;) {
61 std::u16string_view name(o3tl::getToken(names, 0, ';', i));
62 if (!name.empty()) {
63 produce(
64 OUString(name == u"*"
65 ? u""
66 : o3tl::ends_with(name, u".*")
67 ? name.substr(0, name.size() - std::strlen(".*"))
68 : name),
69 typeMgr, generated, options);
72 } else {
73 produce("", typeMgr, generated, options);
76 catch (CannotDumpException & e) {
77 std::cerr << "ERROR: " << e.getMessage() << '\n';
78 return EXIT_FAILURE;
79 } catch (unoidl::NoSuchFileException & e) {
80 std::cerr << "ERROR: No such file <" << e.getUri() << ">\n";
81 return EXIT_FAILURE;
82 } catch (unoidl::FileFormatException & e) {
83 std::cerr
84 << "ERROR: Bad format of <" << e.getUri() << ">, \""
85 << e.getDetail() << "\"\n";
86 return EXIT_FAILURE;
87 } catch (IllegalArgument & e) {
88 std::cerr << "Illegal option " << e.m_message << '\n';
89 return EXIT_FAILURE;
90 } catch (std::exception & e) {
91 std::cerr << "Failure " << e.what() << '\n';
92 return EXIT_FAILURE;
95 return EXIT_SUCCESS;
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */