Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
yaml_util.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
15#pragma once
16
17#include <ryml.hpp>
18#include <c4/std/string.hpp>
19#include <filesystem>
20#include <optional>
21#include <string>
22#include <unordered_map>
23#include <vector>
24
25namespace entropic::config {
26
35bool extract(ryml::ConstNodeRef node, c4::csubstr key, std::string& out);
36
45bool extract(ryml::ConstNodeRef node, c4::csubstr key, int& out);
46
55bool extract(ryml::ConstNodeRef node, c4::csubstr key, float& out);
56
65bool extract(ryml::ConstNodeRef node, c4::csubstr key, double& out);
66
75bool extract(ryml::ConstNodeRef node, c4::csubstr key, bool& out);
76
85bool extract_path(ryml::ConstNodeRef node, c4::csubstr key,
86 std::filesystem::path& out);
87
104 ryml::ConstNodeRef node, c4::csubstr key,
105 std::optional<std::filesystem::path>& out, bool& disabled);
106
115bool extract_string_list(ryml::ConstNodeRef node, c4::csubstr key,
116 std::vector<std::string>& out);
117
131bool extract_string_list_opt(ryml::ConstNodeRef node, c4::csubstr key,
132 std::optional<std::vector<std::string>>& out);
133
142bool extract_string_map(ryml::ConstNodeRef node, c4::csubstr key,
143 std::unordered_map<std::string, std::string>& out);
144
154 ryml::ConstNodeRef node, c4::csubstr key,
155 std::unordered_map<std::string, std::vector<std::string>>& out);
156
163std::filesystem::path expand_home(const std::filesystem::path& p);
164
171std::string to_string(c4::csubstr s);
172
179std::string read_file(const std::filesystem::path& path);
180
181} // namespace entropic::config
std::filesystem::path expand_home(const std::filesystem::path &p)
Expand ~ to home directory in a path.
Definition yaml_util.cpp:61
bool extract_string_list_map(ryml::ConstNodeRef node, c4::csubstr key, std::unordered_map< std::string, std::vector< std::string > > &out)
Extract a map of string to list of strings from a YAML mapping.
std::string read_file(const std::filesystem::path &path)
Read a file into a string.
Definition yaml_util.cpp:39
bool extract_path(ryml::ConstNodeRef node, c4::csubstr key, std::filesystem::path &out)
Extract a filesystem path with ~ expansion.
bool extract_string_list(ryml::ConstNodeRef node, c4::csubstr key, std::vector< std::string > &out)
Extract a vector of strings from a YAML sequence node.
bool extract_string_map(ryml::ConstNodeRef node, c4::csubstr key, std::unordered_map< std::string, std::string > &out)
Extract a map of string to string from a YAML mapping node.
bool extract_string_list_opt(ryml::ConstNodeRef node, c4::csubstr key, std::optional< std::vector< std::string > > &out)
Extract an optional vector of strings.
bool extract_tri_state_path(ryml::ConstNodeRef node, c4::csubstr key, std::optional< std::filesystem::path > &out, bool &disabled)
Extract a tri-state path (null = default, false = disabled, string = path).
std::string to_string(c4::csubstr s)
Convert ryml csubstr to std::string.
Definition yaml_util.cpp:27
bool extract(ryml::ConstNodeRef node, c4::csubstr key, std::string &out)
Extract a string value from a YAML node.
Definition yaml_util.cpp:85