GridFire 0.6.0
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::io::SimpleReactionListFileParser Class Referencefinal

A parser for simple text files containing a list of reactions. More...

#include <network_file.h>

Inheritance diagram for gridfire::io::SimpleReactionListFileParser:
gridfire::io::NetworkFileParser

Public Member Functions

 SimpleReactionListFileParser ()
 Constructs a SimpleReactionListFileParser.
 
ParsedNetworkData parse (const std::string &filename) const override
 Parses a simple reaction list file.
 
- Public Member Functions inherited from gridfire::io::NetworkFileParser
virtual ~NetworkFileParser ()=default
 Virtual destructor for the base class.
 

Private Types

using Config = fourdst::config::Config
 
using LogManager = fourdst::logging::LogManager
 

Private Attributes

Configm_config = Config::getInstance()
 
quill::Logger * m_logger = LogManager::getInstance().getLogger("log")
 

Detailed Description

A parser for simple text files containing a list of reactions.

This parser reads a file where each line contains a single reaction name. It supports comments (lines starting with '#') and ignores empty lines.

Member Typedef Documentation

◆ Config

using gridfire::io::SimpleReactionListFileParser::Config = fourdst::config::Config
private

◆ LogManager

using gridfire::io::SimpleReactionListFileParser::LogManager = fourdst::logging::LogManager
private

Constructor & Destructor Documentation

◆ SimpleReactionListFileParser()

gridfire::io::SimpleReactionListFileParser::SimpleReactionListFileParser ( )
explicit

Constructs a SimpleReactionListFileParser.

Postcondition
The parser is initialized and ready to parse files.

Member Function Documentation

◆ parse()

ParsedNetworkData gridfire::io::SimpleReactionListFileParser::parse ( const std::string & filename) const
overridevirtual

Parses a simple reaction list file.

This method reads the specified file line by line. It trims whitespace from each line, ignores lines that are empty or start with a '#' comment character, and stores the remaining lines as reaction names.

Parameters
filenameThe path to the simple reaction list file.
Returns
A ParsedNetworkData struct containing the list of reaction names.
Exceptions
std::runtime_errorIf the file cannot be opened for reading.

Algorithm

  1. Opens the specified file.
  2. Reads the file line by line.
  3. For each line, it removes any trailing comments (starting with '#').
  4. Trims leading and trailing whitespace.
  5. If the line is not empty, it is added to the list of reaction names.
  6. Returns the populated ParsedNetworkData struct.

Usage

ParsedNetworkData data = parser.parse("reactions.txt");
ParsedNetworkData parse(const std::string &filename) const override
Parses a simple reaction list file.
Definition network_file.cpp:44
SimpleReactionListFileParser()
Constructs a SimpleReactionListFileParser.
Definition network_file.cpp:42
std::vector< std::string > ParsedNetworkData
Definition network_file.h:12

Implements gridfire::io::NetworkFileParser.

Member Data Documentation

◆ m_config

Config& gridfire::io::SimpleReactionListFileParser::m_config = Config::getInstance()
private

◆ m_logger

quill::Logger* gridfire::io::SimpleReactionListFileParser::m_logger = LogManager::getInstance().getLogger("log")
private

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