Elektra  0.9.3
kdb-gen-highlevel(1) -- High-level API code-generator template

kdb gen highlevel <parentKey> <outputName> [parameters...]

This command invokes the code-generator with the template for the high-level API.

The input for this template is a specification. Keys below the parentKey which have a type metakey are considered part of this specification. Every such key must also either have a default metadata or alternatively must be marked with the require metakey. Keys marked with require must be set by the user, otherwise the initialization of the Elektra handle will fail.

The type metakey may only have one of the following values: enum, string, boolean, char, octet, short, unsigned_short, long, unsigned_long, long_long, unsigned_long_long, float, double, long_double, struct, struct_ref and discriminator. Most of these values correspond to the values supported by the high-level API, the remaining values (enum, struct, struct_ref, discriminator) are treated specially and are part of advanced concepts. For more information on these concepts take a look at elektra-highlevel-gen(7). If one of the advanced type values is used, you should also set check/type = any; otherwise the type plugin may produce an error.

The template produces at least three output files: <outputName>.c, <outputName>.h and <outputName>.mount.sh. The .c file only contains implementations, therefore its precise content will not be documented.

The header (.h) file contains the following parts:

  1. Generated enums and structs
  2. Declarations for generated accessor functions
  3. Tags for accessing keys
  4. static inline accessor functions for all tags
  5. Declarations of initialization functions
  6. Convenience accessor macros

Anything else that may be part of the header file is not considered public API and may be subject to change at any point in time. There is also no guarantee of full compatibility between Elektra version for the documented parts of the header, however, we try to have as little breaking changes as possible for the six parts listed above.

The .mount.sh file is a shell script that can be used to mount the specification for the application. You can either use it as a basis for your own script, or wrap it in another script that correctly sets APP_PATH or SPEC_FILE (depending on your configuration). If the generated script happens to use the correct paths already, you can of course use it directly as well.

For detailed information about the contents of the header file see elektra-highlevel-gen(7).

The simplest invocation is:

kdb gen highlevel /sw/org/app/#0/current config

However, it is not recommended to have the code-generator read from the KDB, so one should instead use:

kdb gen -F ni=spec.ini highlevel /sw/org/app/#0/current config

If you don't want to embed the full specification in your binary, we recommend:

kdb gen -F ni=spec.ini highlevel /sw/org/app/#0/current config embeddedSpec=defaults specValidation=minimal

For the minimal binary size you may use (this comes with its own drawbacks, see elektra-highlevel-gen(7)):

kdb gen -F ni=spec.ini highlevel /sw/org/app/#0/current config embeddedSpec=none specValidation=minimal