flatbuf.cpp | Qbs Manual
Description: Provides support for flatbuf for the C++ language.

- Qbs Manual
- QbsModules
- flatbuf.cpp
- Qbs 3.1.1

# flatbuf.cpp

Provides support for flatbuf for the C++ language. More...

Since: | Qbs 2.4

- List of all members, including inherited members

## Properties

- compilerName : string
- compilerPath : string
- filenameExtension : string
- filenameSuffix : string
- importPaths : pathList
- includePrefix : string
- keepPrefix : bool

## Detailed Description

The `flatbuf.cpp` module provides support for generating C++ headers and sources from flatbuf definition files using the `flatc` tool.

A simple qbs file that uses flatbuf can be written as follows:

     CppApplication {
         Depends { name: "flatbuf.cpp" }
         files: ["foo.fbs", "main.cpp"]
     }

A generated header now can be included in the C++ sources:

     #include <foo_generated.h>

     int main(int argc, char* argv[]) {
         flatbuf::FlatBufferBuilder builder;

         auto foo = QbsTest::CreateFoo(builder, 42);
         return 0;
     }

### Relevant File Tags

Tag | Auto-tagged File Names | Since | Description
--- | --- | --- | ---
`"flatbuf.input"` | `*.fbs` | 2.4.0 | Source files with this tag are considered inputs to the `flatc` compiler.

### Dependencies

This module depends on the `flatbuffers` module which can be created via the Conan module provider.

## Property Documentation

compilerName : string

The name of the `flatc` binary.

Default: `"flatc"`

compilerPath : string

The path to the `flatc` binary.

Use this property to override the auto-detected location.

Default: `auto-detected`

filenameExtension : string

The extension appended to the generated file names. If not specified, the default extension (`".h"`) is used.

This property corresponds to the `--filename-ext` option of the `flatc` tool.

Default: Undefined

filenameSuffix : string

The suffix appended to the generated file names. If not specified, the default suffix (`"_generated"`) is used.

This property corresponds to the `--filename-suffix` option of the `flatc` tool.

Default: Undefined

importPaths : pathList

The list of import paths that are passed to the `flatc` tool via the `-I` option.

Default: `[]`

includePrefix : string

Prefix path prepended to any generated include statements.

This property corresponds to the `--include-prefix` option of the `flatc` tool.

Default: Undefined

keepPrefix : bool

Whether to keep original prefix of schema include statement.

This property corresponds to the `--keep-prefix` option of the `flatc` tool.

Default: `false`