Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
yaml_util.cpp File Reference

ryml extraction helper implementations. More...

#include "yaml_util.h"
#include <entropic/types/logging.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
Include dependency graph for yaml_util.cpp:

Go to the source code of this file.

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Functions

std::string entropic::config::to_string (c4::csubstr s)
 Convert ryml csubstr to std::string.
 
std::string entropic::config::read_file (const std::filesystem::path &path)
 Read a file into a string.
 
std::filesystem::path entropic::config::expand_home (const std::filesystem::path &p)
 Expand ~ to home directory in a path.
 
bool entropic::config::extract (ryml::ConstNodeRef node, c4::csubstr key, std::string &out)
 Extract a string value from a YAML node.
 
bool entropic::config::extract (ryml::ConstNodeRef node, c4::csubstr key, int &out)
 Extract an int value from a YAML node.
 
bool entropic::config::extract (ryml::ConstNodeRef node, c4::csubstr key, float &out)
 Extract a float value from a YAML node.
 
bool entropic::config::extract (ryml::ConstNodeRef node, c4::csubstr key, double &out)
 Extract a double value from a YAML node.
 
bool entropic::config::extract (ryml::ConstNodeRef node, c4::csubstr key, bool &out)
 Extract a bool value from a YAML node.
 
bool entropic::config::extract_path (ryml::ConstNodeRef node, c4::csubstr key, std::filesystem::path &out)
 Extract a filesystem path with ~ expansion.
 
bool entropic::config::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).
 
bool entropic::config::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 entropic::config::extract_string_list_opt (ryml::ConstNodeRef node, c4::csubstr key, std::optional< std::vector< std::string > > &out)
 Extract an optional vector of strings.
 
bool entropic::config::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 entropic::config::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.
 

Variables

static auto s_log = entropic::log::get("config")
 

Detailed Description

ryml extraction helper implementations.

Version
1.8.2 @utility

Definition in file yaml_util.cpp.

Function Documentation

◆ expand_home()

std::filesystem::path entropic::config::expand_home ( const std::filesystem::path &  p)

Expand ~ to home directory in a path.

Parameters
pInput path (may start with ~).
Returns
Expanded path. If p doesn't start with ~, returns p unchanged.
Version
1.8.2 @utility
Parameters
pInput path (may start with ~).
Returns
Expanded path. If p doesn't start with ~, returns p unchanged.
Version
1.8.1

Definition at line 61 of file yaml_util.cpp.

◆ extract() [1/5]

bool entropic::config::extract ( ryml::ConstNodeRef  node,
c4::csubstr  key,
bool &  out 
)

Extract a bool value from a YAML node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput bool. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput bool. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 176 of file yaml_util.cpp.

◆ extract() [2/5]

bool entropic::config::extract ( ryml::ConstNodeRef  node,
c4::csubstr  key,
double &  out 
)

Extract a double value from a YAML node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput double. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput double. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 153 of file yaml_util.cpp.

◆ extract() [3/5]

bool entropic::config::extract ( ryml::ConstNodeRef  node,
c4::csubstr  key,
float &  out 
)

Extract a float value from a YAML node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput float. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput float. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 130 of file yaml_util.cpp.

◆ extract() [4/5]

bool entropic::config::extract ( ryml::ConstNodeRef  node,
c4::csubstr  key,
int &  out 
)

Extract an int value from a YAML node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput int. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput int. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 107 of file yaml_util.cpp.

◆ extract() [5/5]

bool entropic::config::extract ( ryml::ConstNodeRef  node,
c4::csubstr  key,
std::string &  out 
)

Extract a string value from a YAML node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput string. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput string. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 85 of file yaml_util.cpp.

◆ extract_path()

bool entropic::config::extract_path ( ryml::ConstNodeRef  node,
c4::csubstr  key,
std::filesystem::path &  out 
)

Extract a filesystem path with ~ expansion.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput path with ~ expanded. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput path with ~ expanded. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 202 of file yaml_util.cpp.

◆ extract_string_list()

bool entropic::config::extract_string_list ( ryml::ConstNodeRef  node,
c4::csubstr  key,
std::vector< std::string > &  out 
)

Extract a vector of strings from a YAML sequence node.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput vector. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput vector. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 251 of file yaml_util.cpp.

◆ extract_string_list_map()

bool entropic::config::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.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput map. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput map. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 332 of file yaml_util.cpp.

◆ extract_string_list_opt()

bool entropic::config::extract_string_list_opt ( ryml::ConstNodeRef  node,
c4::csubstr  key,
std::optional< std::vector< std::string > > &  out 
)

Extract an optional vector of strings.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput optional vector.
Returns
true if key was found.
Version
1.8.2 @utility

If key absent: out unchanged (remains nullopt). If key present with sequence: out = vector of strings. If key present with null: out = nullopt.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput optional vector.
Returns
true if key was found.
Version
1.8.1

Definition at line 277 of file yaml_util.cpp.

◆ extract_string_map()

bool entropic::config::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.

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput map. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.2 @utility
Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput map. Unchanged if key is absent.
Returns
true if key was found and extracted.
Version
1.8.1

Definition at line 306 of file yaml_util.cpp.

◆ extract_tri_state_path()

bool entropic::config::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).

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput path. nullopt if absent/null/false.
[out]disabledSet to true if value is explicitly false.
Returns
true if key was found.
Version
1.8.2 @utility

Maps to Python's TriStatePath: None | False | Path. YAML values: absent/null = default (out=nullopt, disabled=false), false = disabled (out=nullopt, disabled=true), string = custom path (out=expanded path, disabled=false).

Parameters
nodeThe ryml node to extract from.
keyThe key to look up.
[out]outOutput path. nullopt if absent/null/false.
[out]disabledSet to true if value is explicitly false.
Returns
true if key was found.
Version
1.8.1

Definition at line 223 of file yaml_util.cpp.

◆ read_file()

std::string entropic::config::read_file ( const std::filesystem::path &  path)

Read a file into a string.

Parameters
pathFile path.
Returns
File contents, or empty string on failure.
Version
2.0.0 @utility
Parameters
pathFile path.
Returns
File contents, or empty string on failure.
Version
1.8.1

Definition at line 39 of file yaml_util.cpp.

◆ to_string()

std::string entropic::config::to_string ( c4::csubstr  s)

Convert ryml csubstr to std::string.

Parameters
sryml substring.
Returns
Equivalent std::string.
Version
1.8.2 @utility
Parameters
sryml substring.
Returns
Equivalent std::string.
Version
1.8.1

Definition at line 27 of file yaml_util.cpp.

Variable Documentation

◆ s_log

auto s_log = entropic::log::get("config")
static

Definition at line 16 of file yaml_util.cpp.