File reaction_parser.hxx#
Defines
-
REACTION_PARSER_H#
Enums
Functions
-
static inline std::map<std::string, int> count_species(std::string expr)#
-
class ReactionParser#
- #include <reaction_parser.hxx>
A class to parse reaction strings and extract the stoichiometric vector (net population changes for each species). Also used to retrieve the names of species in various useful subsets (reactants, products, non-electron species, etc.)
Public Functions
-
ReactionParser(const std::string &reaction_str)#
-
inline const std::string get_reaction_str() const#
Public getter for underlying reaction string.
-
inline const std::map<std::string, int> &get_stoich()#
Get the stoichiometric vector for this reaction (as a species_name=>pop_change map)
-
std::vector<std::string> get_species() const#
Get the names of all species identified by the parser.
- Returns:
std::vector<std::string> the list of species names
-
std::vector<std::string> get_species(species_filter filter) const#
Apply a filter to the list of species identified by the parser.
- Parameters:
filter – the filter to apply
- Returns:
std::vector<std::string> the filterered list of species names
-
std::vector<std::string> get_species(std::vector<std::string> species_names, species_filter filter) const#
Apply a filter to a list of species names.
- Parameters:
species_names – the list of species names to filter
filter – the filter to apply
- Returns:
std::vector<std::string> the filtered list of names
-
template<typename ...FilterTypes>
inline std::vector<std::string> get_species(std::vector<std::string> species_names, species_filter first_filter, FilterTypes... other_filters) const# Apply multiple filters to a list of species names.
Variadic so that it can be applied recursively.
- Template Parameters:
FilterTypes –
- Parameters:
species_names – the list of species names to filter
first_filter – the first filter
other_filters – other filters
- Returns:
std::vector<std::string> the filtered list of names
-
template<typename ...FilterTypes>
inline std::vector<std::string> get_species(FilterTypes... filters) const# Apply multiple filters to the list of species identified by the parser.
Variadic so that it can be applied recursively.
- Template Parameters:
FilterTypes –
- Parameters:
species_names – the list of species names to filter
first_filter – the first filter
other_filters – other filters
- Returns:
std::vector<std::string> the filtered list of names
Private Functions
-
inline void diff_reactants_products(const std::map<std::string, int> &R, const std::map<std::string, int> &P)#
Util function to compute the stoichiometric ‘vector’ (map) by taking the difference between the reactant and product population changes.
- Parameters:
R – the reactant population changes
P – the product population changes
Private Members
-
const std::string reaction_str#
The reaction string.
-
std::map<std::string, int> reactants#
Map of species name => population change for reactants.
-
std::map<std::string, int> products#
Map of species name => population change for products.
-
std::map<std::string, int> stoich#
Stoichiometric ‘vector’ (map of species name => population change)
-
ReactionParser(const std::string &reaction_str)#