qtgrpc/src/tools/qtprotoccommon/options.h

64 lines
1.8 KiB
C
Raw Normal View History

// Copyright (C) 2022 The Qt Company Ltd.
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef GENERATOROPTIONS_H
#define GENERATOROPTIONS_H
#include <string>
namespace qtprotoccommon {
/*!
\ingroup generator
\private
\brief The GeneratorOptions class
*/
class Options
{
Options();
static Options &mutableInstance();
public:
enum class HeaderGuardType {
Pragma,
ProtoFilename,
};
enum GeneratorType {
QtProtobufGen = 0,
QtGrpcGen
};
~Options();
Options(const Options &) = delete;
Options &operator=(const Options &) = delete;
Options(Options &&) = delete;
Options &operator=(Options &&) = delete;
static const Options &instance();
static void setFromString(const std::string &options, GeneratorType type = QtProtobufGen);
bool hasQml() const { return m_qml; }
bool generateComments() const { return m_generateComments; }
bool isFolder() const { return m_isFolder; }
bool generateFieldEnum() const { return m_generateFieldEnum; }
const std::string &extraNamespace() const { return m_extraNamespace; }
const std::string &exportMacro() const { return m_exportMacro; }
Fix the generation of the export macro Consider the EXPORT_MACRO CMake argument of qt_add_<protobuf|grpc> calls. Add the support for the EXPORT_MACRO option extras to the qt<protobuf|grpc>gen generators. The extras now allow setting: - export file name - boolean flag that indicates if export file needs to be generated The EXPORT_MACRO option of the generators now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] If export_filename is not set, then generators fall back to the previos behavior and use the export_name as the export filename base, the file will be generated unconditionally. If export_filename is set and the follow boolean flag is not set or is set to false, generators skip the generating of the export file. [ChangeLog][Protobuf][qtprotobufgen] EXPORT_MACRO option now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] New option extras allow setting the generated export filename and control if it should be generated at the generator run. [ChangeLog][GRPC][qtgrpcgen] EXPORT_MACRO option now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] New option extras allow setting the generated export filename and control if it should be generated at the generator run. Pick-to: 6.7 Fixes: QTBUG-121854 Change-Id: Ifff6506ab363d18dc417f222e9929d7eba135d8a Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-03 10:25:33 +00:00
const std::string &exportMacroFilename() const { return m_exportMacroFilename; }
bool generateMacroExportFile() const { return m_generateMacroExportFile; }
HeaderGuardType headerGuard() const { return m_headerGuard; }
private:
bool m_generateComments;
bool m_isFolder;
bool m_generateFieldEnum;
std::string m_extraNamespace;
std::string m_exportMacro;
Fix the generation of the export macro Consider the EXPORT_MACRO CMake argument of qt_add_<protobuf|grpc> calls. Add the support for the EXPORT_MACRO option extras to the qt<protobuf|grpc>gen generators. The extras now allow setting: - export file name - boolean flag that indicates if export file needs to be generated The EXPORT_MACRO option of the generators now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] If export_filename is not set, then generators fall back to the previos behavior and use the export_name as the export filename base, the file will be generated unconditionally. If export_filename is set and the follow boolean flag is not set or is set to false, generators skip the generating of the export file. [ChangeLog][Protobuf][qtprotobufgen] EXPORT_MACRO option now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] New option extras allow setting the generated export filename and control if it should be generated at the generator run. [ChangeLog][GRPC][qtgrpcgen] EXPORT_MACRO option now has the following format: EXPORT_MACRO=<export_name>[:export_filename[:<true|false>]] New option extras allow setting the generated export filename and control if it should be generated at the generator run. Pick-to: 6.7 Fixes: QTBUG-121854 Change-Id: Ifff6506ab363d18dc417f222e9929d7eba135d8a Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-03 10:25:33 +00:00
std::string m_exportMacroFilename;
bool m_generateMacroExportFile;
bool m_qml;
HeaderGuardType m_headerGuard = Options::HeaderGuardType::ProtoFilename;
};
}
#endif // GENERATOROPTIONS_H