Entropic 2.11.1
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
123 ryml::ConstNodeRef node, c4::csubstr key, std::optional<std::string>& out);
124
133bool extract_string_list(ryml::ConstNodeRef node, c4::csubstr key,
134 std::vector<std::string>& out);
135
149bool extract_string_list_opt(ryml::ConstNodeRef node, c4::csubstr key,
150 std::optional<std::vector<std::string>>& out);
151
160bool extract_string_map(ryml::ConstNodeRef node, c4::csubstr key,
161 std::unordered_map<std::string, std::string>& out);
162
172 ryml::ConstNodeRef node, c4::csubstr key,
173 std::unordered_map<std::string, std::vector<std::string>>& out);
174
181std::filesystem::path expand_home(const std::filesystem::path& p);
182
189std::string to_string(c4::csubstr s);
190
197std::string read_file(const std::filesystem::path& path);
198
199} // 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.
bool extract_inline_content(ryml::ConstNodeRef node, c4::csubstr key, std::optional< std::string > &out)
Extract inline text from an object-form value (gh#141).
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