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 .
20 #include "sal/config.h"
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"
33 #include "sal/types.h"
34 #include "unoidl/unoidl.hxx"
36 #include "cppuoptions.hxx"
37 #include "cpputype.hxx"
39 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
) {
42 if (!options
.initOptions(argc
, argv
)) {
46 rtl::Reference
< TypeManager
> typeMgr(new TypeManager
);
47 for (std::vector
< OString
>::const_iterator
i(
48 options
.getExtraInputFiles().begin());
49 i
!= options
.getExtraInputFiles().end(); ++i
)
51 typeMgr
->loadProvider(convertToFileUrl(*i
), false);
53 for (std::vector
< OString
>::const_iterator
i(
54 options
.getInputFiles().begin());
55 i
!= options
.getInputFiles().end(); ++i
)
57 typeMgr
->loadProvider(convertToFileUrl(*i
), true);
59 codemaker::GeneratedTypeSet generated
;
60 if (options
.isValid("-T")) {
61 OUString
names(b2u(options
.getOption("-T")));
62 for (sal_Int32 i
= 0; i
!= -1;) {
63 OUString
name(names
.getToken(0, ';', i
));
64 if (!name
.isEmpty()) {
69 ? name
.copy(0, name
.getLength() - std::strlen(".*"))
71 typeMgr
, generated
, options
);
75 produce("", typeMgr
, generated
, options
);
77 if (!options
.isValid("-nD")) {
78 // C++ header files generated for the following UNO types are
79 // included in header files in cppu/inc/com/sun/star/uno (Any.hxx,
80 // Reference.hxx, Type.h), so it seems best to always generate those
83 "com.sun.star.uno.RuntimeException", typeMgr
, generated
,
86 "com.sun.star.uno.TypeClass", typeMgr
, generated
, options
);
88 "com.sun.star.uno.XInterface", typeMgr
, generated
, options
);
90 } catch (CannotDumpException
& e
) {
91 std::cerr
<< "ERROR: " << e
.getMessage() << '\n';
93 } catch (unoidl::NoSuchFileException
& e
) {
94 std::cerr
<< "ERROR: No such file <" << e
.getUri() << ">\n";
96 } catch (unoidl::FileFormatException
& e
) {
98 << "ERROR: Bad format of <" << e
.getUri() << ">, \""
99 << e
.getDetail() << "\"\n";
101 } catch (IllegalArgument
& e
) {
102 std::cerr
<< "Illegal option " << e
.m_message
<< '\n';
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */