GridFire 0.0.1a
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.

Definition at line 84 of file network_file.h.

Member Typedef Documentation

◆ Config

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

Definition at line 120 of file network_file.h.

◆ LogManager

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

Definition at line 121 of file network_file.h.

Constructor & Destructor Documentation

◆ SimpleReactionListFileParser()

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

Constructs a SimpleReactionListFileParser.

Postcondition
The parser is initialized and ready to parse files.

Definition at line 42 of file network_file.cpp.

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.
SimpleReactionListFileParser()
Constructs a SimpleReactionListFileParser.
Holds the data parsed from a network file.

Implements gridfire::io::NetworkFileParser.

Definition at line 44 of file network_file.cpp.

Member Data Documentation

◆ m_config

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

Definition at line 122 of file network_file.h.

◆ m_logger

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

Definition at line 123 of file network_file.h.


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