Configuration
-
class Config : public zenoh::Owned<::z_owned_config_t>
A Zenoh Session config.
Constructors
-
static inline Config create_default(ZResult *err = nullptr)
Create a default configuration.
- Parameters:
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
-
static inline Config from_file(const std::string &path, ZResult *err = nullptr)
Create the configuration from the JSON file.
- Parameters:
path – path to the config file (see config file documentation for more information).
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
the
Configobject.
Note
Zenoh-c only.
-
static inline Config from_str(const std::string &s, ZResult *err = nullptr)
Create the configuration from the JSON string.
- Parameters:
s – config in JSON format.
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
the
Configobject.
Note
Zenoh-c only.
-
static inline Config from_env(ZResult *err = nullptr)
Create a configuration by parsing a file with path stored in ZENOH_CONFIG environment variable.
- Parameters:
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
the
Configobject.
Note
Zenoh-pico only.
Methods
-
inline std::string get(std::string_view key, ZResult *err = nullptr) const
Get config parameter by the string key.
- Parameters:
key – the key.
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
value of the config parameter in JSON format.
Note
Zenoh-c only.
-
inline std::string to_string() const
Get the whole config as a JSON string.
- Returns:
string with config in json format.
Note
Zenoh-c only.
-
inline void insert_json5(const std::string &key, const std::string &value, ZResult *err = nullptr)
Insert a config parameter by the string key.
- Parameters:
key – the key.
value – the JSON string value,
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
trueif the parameter was inserted, false otherwise.
Note
Zenoh-c only.
-
inline const char *get(uint8_t key, ZResult *err = nullptr) const
Get config parameter by it’s numeric ID.
- Parameters:
key – the key.
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
- Returns:
pointer to the null-terminated string value of the config parameter.
Note
Zenoh-pico only.
-
inline void insert(uint8_t key, const char *value, ZResult *err = nullptr)
Insert a config parameter by it’s numeric ID.
- Parameters:
key – the key.
value – the null-terminated string value.
err – if not null, the result code will be written to this location, otherwise ZException exception will be thrown in case of error.
Note
Zenoh-pico only.
-
static inline Config create_default(ZResult *err = nullptr)