Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
YAMLParser Class Reference

YAML implementation of the IParser interface. More...

#include <YamlParser.h>

Inheritance diagram for YAMLParser:
Collaboration diagram for YAMLParser:

Public Member Functions

std::shared_ptr< DBNodeparse (const std::string &input) const override
 Parses a YAML string into a DBNode hierarchy.
 
void writeToFile (const std::string &filename, const std::shared_ptr< DBNode > &root) const override
 Writes a DBNode hierarchy to a YAML file.
 
std::shared_ptr< DBNodereadFromFile (const std::string &filename) const override
 Reads and parses YAML data from a file.
 
- Public Member Functions inherited from IParser
virtual ~IParser ()=default
 Virtual destructor to allow proper cleanup via base pointer.
 

Detailed Description

YAML implementation of the IParser interface.

YAMLParser can:

  • parse a YAML-like string into a DBNode hierarchy,
  • write a DBNode hierarchy to a YAML file,
  • read a DBNode hierarchy back from a YAML file.

The parser is intentionally minimal and focuses on the subset of YAML needed by the project (indentation-based maps and lists).

Definition at line 39 of file YamlParser.h.

Member Function Documentation

◆ parse()

std::shared_ptr< DBNode > YAMLParser::parse ( const std::string &  input) const
overridevirtual

Parses a YAML string into a DBNode hierarchy.

Parameters
inputYAML text buffer.
Returns
Shared pointer to the root DBNode of the parsed document.
Exceptions
std::runtime_erroron syntax or conversion errors.

Implements IParser.

Definition at line 21 of file YamlParser.cpp.

◆ readFromFile()

std::shared_ptr< DBNode > YAMLParser::readFromFile ( const std::string &  filename) const
overridevirtual

Reads and parses YAML data from a file.

The file contents are loaded into memory and passed to parse().

Parameters
filenameSource file name.
Returns
Shared pointer to the root DBNode of the parsed document.
Exceptions
std::runtime_errorif the file cannot be opened or parsing fails.

Implements IParser.

Definition at line 209 of file YamlParser.cpp.

◆ writeToFile()

void YAMLParser::writeToFile ( const std::string &  filename,
const std::shared_ptr< DBNode > &  root 
) const
overridevirtual

Writes a DBNode hierarchy to a YAML file.

This uses DBNode::printYAMLToStream() to serialize the tree in a readable YAML-like format.

Parameters
filenameTarget file name.
rootRoot node to serialize.
Exceptions
std::runtime_errorif the file cannot be opened or writing fails.

Implements IParser.

Definition at line 198 of file YamlParser.cpp.


The documentation for this class was generated from the following files: