configtpl 0.1.1

A configuration library which uses Jinja + YAML to render the configuration values.
Documentation
#ifndef _CONFIGTPL_H
#define _CONFIGTPL_H

#pragma once

/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#define CONFIGTPL_FEATURE_SHARED_LIB

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Status of configuration building
 */
typedef enum configtpl_BuildStatus {
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_BUILD_STATUS_SUCCESS = 0,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  /**
   * An invalid handle is provided
   */
  CONFIGTPL_BUILD_STATUS_ERROR_INVALID_HANDLE = 1,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  /**
   * Indicates that an error occurred during building the config
   */
  CONFIGTPL_BUILD_STATUS_ERROR_BUILDING = 200,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  /**
   * An unknown error. Should not occur in general.
   */
  CONFIGTPL_BUILD_STATUS_ERROR_UNKNOWN = 255,
#endif
} configtpl_BuildStatus;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef enum configtpl_ConfigParamType {
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_BOOLEAN,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_MAP,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_FLOAT,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_INT,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_NULL,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_STRING,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_CONFIG_PARAM_TYPE_VEC,
#endif
} configtpl_ConfigParamType;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Simple result of function call. Used for function which don't (yet?) need to return more complex result.
 */
typedef enum configtpl_SimpleResult {
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_SIMPLE_RESULT_SUCCESS = 0,
#endif
#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
  CONFIGTPL_SIMPLE_RESULT_ERROR = 1,
#endif
} configtpl_SimpleResult;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef unsigned int configtpl_UInt;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Handle allocated for initialized Config Builder.
 * All operations which invoke the Config Builder should have this handle provided
 */
typedef configtpl_UInt configtpl_CfgBuilderHandle;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef unsigned short configtpl_Bool;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef double configtpl_LongFloat;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef const char *configtpl_ConstCharPtr;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * An item in configuration param of dicrionary type
 */
typedef struct configtpl_ConfigParamDictItem {
  configtpl_ConstCharPtr name;
  const struct configtpl_ConfigParam *value;
} configtpl_ConfigParamDictItem;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef struct configtpl_Array_ConfigParamDictItem {
  struct configtpl_ConfigParamDictItem *data;
  configtpl_UInt len;
} configtpl_Array_ConfigParamDictItem;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef long configtpl_LongInt;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef struct configtpl_Array_ConfigParam {
  struct configtpl_ConfigParam *data;
  configtpl_UInt len;
} configtpl_Array_ConfigParam;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef union configtpl_ConfigParamValue {
  configtpl_Bool boolean;
  configtpl_LongFloat float_num;
  struct configtpl_Array_ConfigParamDictItem map;
  configtpl_LongInt integer;
  configtpl_ConstCharPtr string;
  struct configtpl_Array_ConfigParam vector;
} configtpl_ConfigParamValue;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef struct configtpl_ConfigParam {
  enum configtpl_ConfigParamType param_type;
  union configtpl_ConfigParamValue value;
} configtpl_ConfigParam;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Result of configuration building
 */
typedef struct configtpl_BuildResult {
  enum configtpl_BuildStatus status;
  struct configtpl_ConfigParam output;
  configtpl_ConstCharPtr error_msg;
} configtpl_BuildResult;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef struct configtpl_Array_ConstCharPtr {
  configtpl_ConstCharPtr *data;
  configtpl_UInt len;
} configtpl_Array_ConstCharPtr;
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
typedef struct configtpl_BuildArgs {
  /**
   * Context is injected into each iteration of configuration rendering,
   * but it is not returned as part of the final configuration.
   */
  struct configtpl_ConfigParam *context;
  /**
   * Defaults for configuration parameters. Applied at the first stage of configuration building.
   */
  struct configtpl_ConfigParam *defaults;
  /**
   * If provided, environment variables with this prefix will be injected into configuration after files
   */
  configtpl_ConstCharPtr env_vars_prefix;
  /**
   * Overrides for configuration parameters. Applied at the last stage of configuration building.
   */
  struct configtpl_ConfigParam *overrides;
  /**
   * A list of paths to configuration files
   */
  struct configtpl_Array_ConstCharPtr paths;
} configtpl_BuildArgs;
#endif

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Creates a new instance of configuration builder
 */
configtpl_CfgBuilderHandle configtpl_configbuilder_new(void);
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
const struct configtpl_BuildResult *configtpl_configbuilder_build(configtpl_CfgBuilderHandle env_handle,
                                                                  struct configtpl_BuildArgs args);
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Deallocates memory of configuration builder result
 */
void configtpl_configbuilder_result_free(const struct configtpl_BuildResult *r);
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * Deallocates memory of configuration builder instance
 */
void configtpl_configbuilder_free(configtpl_CfgBuilderHandle env_handle);
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * This function should be invoked before any other library routines.
 * Right at the moment it does nothing, but some initialization might be added in the future.
 */
enum configtpl_SimpleResult configtpl_init(void);
#endif

#if defined(CONFIGTPL_FEATURE_SHARED_LIB)
/**
 * This function should be invoked after any other library routines.
 * /// Right at the moment it does nothing, but some final actions might be added in the future.
 */
enum configtpl_SimpleResult configtpl_cleanup(void);
#endif

#ifdef __cplusplus
}  // extern "C"
#endif  // __cplusplus

#endif  /* _CONFIGTPL_H */