GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Attributes | List of all members
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:

## 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
Config & | m_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 68 of file network_file.h.

## Member Typedef Documentation

## ◆ Config

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

Definition at line 104 of file network_file.h.

## ◆ LogManager

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

Definition at line 105 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
| override virtual

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

  filename | The path to the simple reaction list file.

Returns
  A `ParsedNetworkData` struct containing the list of reaction names.

Exceptions

  std::runtime_error | If 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

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

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 106 of file network_file.h.

## ◆ m_logger

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

Definition at line 107 of file network_file.h.

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

- src/include/gridfire/io/network_file.h
- src/lib/io/network_file.cpp