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

Abstract base class for data parsers. More...

#include <IParser.h>

Inheritance diagram for IParser:

Public Member Functions

virtual ~IParser ()=default
 Virtual destructor to allow proper cleanup via base pointer.
 
virtual std::shared_ptr< DBNodeparse (const std::string &input) const =0
 Parses an input string into a DBNode hierarchy.
 
virtual void writeToFile (const std::string &filename, const std::shared_ptr< DBNode > &root) const =0
 Serializes a DBNode hierarchy to a file.
 
virtual std::shared_ptr< DBNodereadFromFile (const std::string &filename) const =0
 Reads and parses a DBNode hierarchy from a file.
 

Detailed Description

Abstract base class for data parsers.

This interface is format-agnostic. It exposes three core operations:

Definition at line 30 of file IParser.h.

Constructor & Destructor Documentation

◆ ~IParser()

virtual IParser::~IParser ( )
virtualdefault

Virtual destructor to allow proper cleanup via base pointer.

Member Function Documentation

◆ parse()

virtual std::shared_ptr< DBNode > IParser::parse ( const std::string &  input) const
pure virtual

Parses an input string into a DBNode hierarchy.

The exact syntax and semantics of the input depend on the concrete implementation (YAML, JSON, LHA, ...).

Parameters
inputText buffer to parse.
Returns
Shared pointer to the root DBNode of the parsed tree.
Exceptions
std::runtime_error(or derived) on parsing errors.

Implemented in JSONParser, YAMLParser, and LhaParser.

◆ readFromFile()

virtual std::shared_ptr< DBNode > IParser::readFromFile ( const std::string &  filename) const
pure virtual

Reads and parses a DBNode hierarchy from a file.

Typical implementations:

  • read the entire file into a string,
  • call parse() on that string.
Parameters
filenamePath of the file to read.
Returns
Shared pointer to the root DBNode of the parsed tree.
Exceptions
std::runtime_errorif the file cannot be opened or if parsing fails.

Implemented in JSONParser, YAMLParser, and LhaParser.

◆ writeToFile()

virtual void IParser::writeToFile ( const std::string &  filename,
const std::shared_ptr< DBNode > &  root 
) const
pure virtual

Serializes a DBNode hierarchy to a file.

Implementations are free to choose their own textual encoding (YAML, JSON, etc.) but should be compatible with readFromFile() for round-trip usage.

Parameters
filenamePath of the target file.
rootRoot DBNode to serialize.
Exceptions
std::runtime_errorif the file cannot be opened or a write error occurs.

Implemented in LhaParser, JSONParser, and YAMLParser.


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