/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qbs.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \qmltype protobuf.cpp
    \inqmlmodule QbsModules
    \since Qbs 1.13

    \brief Provides support for protocol buffers for the C++ language.

    The \c protobuf.cpp module provides support for generating C++ headers
    and sources from proto definition files using the \l protoc tool.

    A simple qbs file that uses protobuf can be written as follows:
    \code
    CppApplication {
        Depends { name: "protobuf.cpp" }
        files: ["foo.proto", "main.cpp"]
    }
    \endcode
    A generated header now can be included in the C++ sources:
    \code
        #include <foo.pb.h>

        int main(int argc, char* argv[]) {
            Foo bar;
            bar.set_answer(42);
            google::protobuf::ShutdownProtobufLibrary();
            return 0;
        }
    \endcode

    \section2 Relevant File Tags

    \table
    \header
        \li Tag
        \li Auto-tagged File Names
        \li Since
        \li Description
    \row
        \li \c{"protobuf.input"}
        \li \c{*.proto}
        \li 1.13.0
        \li Source files with this tag are considered inputs to the \c protoc compiler.
    \row
        \li \c{"protobuf.grpc"}
        \li
        \li 1.14.0
        \li Source files with this tag are considered as gRPC files.
    \row
        \li \c{"protobuf.hpp"}
        \li
        \li 1.18.0
        \li This tag is attached to the header files generated by \c protoc compiler.
    \endtable
*/

/*!
    \qmlproperty string protobuf.cpp::compilerName

    The name of the protoc binary.

    \since Qbs 1.17
    \defaultvalue \c "protoc"
*/

/*!
    \qmlproperty string protobuf.cpp::compilerPath

    The path to the protoc binary.

    Use this property to override the auto-detected location.

    \since Qbs 1.17
    \defaultvalue \c auto-detected
*/

/*!
    \qmlproperty string protobuf.cpp::grpcIncludePath

    The path where grpc++ headers are located. Set this property to override the
    default location.

    \defaultvalue \c auto-detected
*/

/*!
    \qmlproperty string protobuf.cpp::grpcLibraryPath

    The path where the grpc++ library is located. Set this property to override the
    default location.

    \defaultvalue \c auto-detected
*/

/*!
    \qmlproperty pathList protobuf.cpp::importPaths

    The list of imports that are passed to the \c protoc tool via the \c --proto_path option.
    These imports should contain the proto files. They are used to determine
    the relative structure of the generated files.
    \note The paths are passed to \c protoc in the same order as specified in this property and
    \c protoc output may differ depending on that order.

    \defaultvalue \c []
*/

/*!
    \qmlproperty string protobuf.cpp::includePath

    The path where protobuf C++ headers are located. Set this property to override the
    default location.

    \defaultvalue \c auto-detected
*/

/*!
    \qmlproperty string protobuf.cpp::libraryPath

    The path where the protobuf C++ library is located. Set this property to override the
    default location.

    \defaultvalue \c auto-detected
*/

/*!
    \qmlproperty string protobuf.cpp::outputDir
    \readonly

    The directory where the \c protoc compiler generated files are placed.

    The value of this property is automatically set by \QBS and cannot be
    changed by the user.
*/

/*!
    \qmlproperty bool protobuf.cpp::useGrpc

    Whether to use gRPC framework.

    Use this property to enable support for the modern open source high performance RPC
    framework by Google, gRPC (\l{https://www.grpc.io}).

    A simple qbs file that uses grpc can be written as follows:
    \code
    CppApplication {
        Depends { name: "protobuf.cpp" }
        protobuf.cpp.useGrpc: true
        files: ["main.cpp"]
        Group {
            files: "grpc.proto"
            fileTags: "protobuf.grpc"
        }
    }
    \endcode

    \note that \c protobuf.grpc tag should be assigned manually because gRPC uses same \c *.proto
    files and \QBS can't detect whether to generate gRPC or \c protobuf.

    The following \c grpc.proto file...
    \code
        syntax = "proto3";

        package Qbs;

        message Request {
            string name = 1;
        }

        message Response {
            string name = 1;
        }

        service Grpc {
            rpc doWork(Request) returns (Response) {}
        }
    \endcode

    ...can be used in the C++ sources as follows:
    \code
        #include <grpc.grpc.pb.h>

        class Service final : public Qbs::Grpc::Service
        {
            grpc::Status doWork(
                    grpc::ServerContext* context,
                    const Qbs::Request* request,
                    Qbs::Response* reply) override
            {
                (void)context;
                reply->set_name(request->name());
                return grpc::Status::OK;
            }
        };
    \endcode

    \defaultvalue \c false
*/
