2017-07-13 22:13:40 +02:00
|
|
|
/* Helpers for configuration parsers.
|
2017-04-15 21:22:19 +02:00
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-04-15 21:22:19 +02:00
|
|
|
*/
|
2017-04-15 20:38:58 +02:00
|
|
|
|
2017-04-15 21:24:00 +02:00
|
|
|
#pragma once
|
2017-04-15 20:38:58 +02:00
|
|
|
|
|
|
|
#include <jansson.h>
|
2018-10-24 10:04:21 -04:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/node/config.hpp>
|
|
|
|
#include <villas/sample.hpp>
|
|
|
|
|
2023-09-07 14:21:24 +02:00
|
|
|
#ifdef WITH_CONFIG
|
|
|
|
#include <libconfig.h>
|
|
|
|
#endif
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
2017-04-15 20:38:58 +02:00
|
|
|
|
2019-04-05 11:01:49 +02:00
|
|
|
#ifdef WITH_CONFIG
|
2019-04-05 20:57:34 +02:00
|
|
|
|
2019-03-26 07:01:10 +01:00
|
|
|
// Convert a libconfig object to a jansson object
|
2023-09-07 11:46:39 +02:00
|
|
|
json_t *config_to_json(struct config_setting_t *cfg);
|
2017-04-15 20:38:58 +02:00
|
|
|
|
2019-03-26 07:01:10 +01:00
|
|
|
// Convert a jansson object into a libconfig object.
|
2021-08-10 10:12:48 -04:00
|
|
|
int json_to_config(json_t *json, struct config_setting_t *parent);
|
|
|
|
|
2019-04-05 11:01:49 +02:00
|
|
|
#endif // WITH_CONFIG
|
2017-04-15 20:38:58 +02:00
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
int json_object_extend_str(json_t *orig, const char *str);
|
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
void json_object_extend_key_value(json_t *obj, const char *key,
|
|
|
|
const char *value);
|
2017-08-03 00:19:27 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
void json_object_extend_key_value_token(json_t *obj, const char *key,
|
|
|
|
const char *value);
|
2019-03-26 07:01:10 +01:00
|
|
|
|
|
|
|
// Merge two JSON objects recursively.
|
2017-08-03 00:19:27 +02:00
|
|
|
int json_object_extend(json_t *orig, json_t *merge);
|
2018-06-28 13:42:50 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
json_t *json_load_cli(int argc, const char *argv[]);
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|