ROOT
ROOT project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
FunctionParserBase Class Referenceabstract

Base class for function parsers. More...

#include <function_parser.hpp>

Inheritance diagram for FunctionParserBase:
Inheritance graph
Collaboration diagram for FunctionParserBase:
Collaboration graph

Public Member Functions

virtual ~FunctionParserBase ()=default
 
virtual std::function< double(double)> parse ()=0
 Pure virtual method to parse the function string.
 
 FunctionParserBase (std::string function_str)
 Constructor for FunctionParserBase.
 

Static Public Member Functions

static std::function< double(double)> parseFunction (const std::string &function_str)
 Static method to parse a function string and return a callable function.
 
static bool isPolynomial (const std::string &expression)
 Static method to check if the expression is a polynomial.
 
static bool isTrigonometric (const std::string &expression)
 Static method to check if the expression is a trigonometric function.
 

Static Protected Member Functions

static bool icontains (const std::string &hay, const std::string &needle)
 Helper static method to check if a string contains a substring (case-insensitive).
 
static std::string removeSpaces (const std::string &function_str)
 Helper static method to remove all whitespace from a string.
 
static std::vector< std::string > splitSignTokens (const std::string &expr_no_ws)
 Helper static method to split an expression into tokens based on sign characters.
 
static std::pair< double, std::string > parseOptionalCoefficient (const std::string &token)
 Helper static method to parse an optional coefficient from a token.
 

Protected Attributes

std::string function_str
 The function string to be parsed.
 

Friends

class FunctionParserBaseTester
 Friend test fixture class for unit testing.
 

Detailed Description

Base class for function parsers.

This abstract class defines the interface for parsing mathematical functions from strings. It includes static methods for dispatching to specific parser subclasses based on the type of function (e.g., polynomial, trigonometric).

Constructor & Destructor Documentation

◆ ~FunctionParserBase()

virtual FunctionParserBase::~FunctionParserBase ( )
virtualdefault

◆ FunctionParserBase()

FunctionParserBase::FunctionParserBase ( std::string  function_str)

Constructor for FunctionParserBase.

Parameters
function_strThe string representation of the function to be parsed.

Member Function Documentation

◆ icontains()

bool FunctionParserBase::icontains ( const std::string &  hay,
const std::string &  needle 
)
staticprotected

Helper static method to check if a string contains a substring (case-insensitive).

Parameters
hayThe string to search within.
needleThe substring to search for.
Returns
true if hay contains needle, false otherwise.
Here is the caller graph for this function:

◆ isPolynomial()

bool FunctionParserBase::isPolynomial ( const std::string &  expression)
inlinestatic

Static method to check if the expression is a polynomial.

Parameters
expressionThe expression string to check.
Returns
true if the expression is a polynomial, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTrigonometric()

bool FunctionParserBase::isTrigonometric ( const std::string &  expression)
inlinestatic

Static method to check if the expression is a trigonometric function.

Parameters
expressionThe expression string to check.
Returns
true if the expression is trigonometric, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse()

virtual std::function< double(double)> FunctionParserBase::parse ( )
pure virtual

Pure virtual method to parse the function string.

Returns
A std::function<double(double)> representing the parsed function.

Implemented in PolynomialParser, and TrigonometricParser.

◆ parseFunction()

std::function< double(double)> FunctionParserBase::parseFunction ( const std::string &  function_str)
static

Static method to parse a function string and return a callable function.

This method determines the type of function represented by the input string and delegates parsing to the appropriate subclass parser.

Parameters
function_strThe string representation of the function to be parsed.
Returns
A std::function<double(double)> representing the parsed function.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseOptionalCoefficient()

std::pair< double, std::string > FunctionParserBase::parseOptionalCoefficient ( const std::string &  token)
staticprotected

Helper static method to parse an optional coefficient from a token.

Parameters
tokenThe token string to parse.
Returns
A pair containing the coefficient and the remaining string.
Here is the caller graph for this function:

◆ removeSpaces()

std::string FunctionParserBase::removeSpaces ( const std::string &  function_str)
staticprotected

Helper static method to remove all whitespace from a string.

Parameters
function_strThe input string.
Returns
A new string with all whitespace removed.
Here is the caller graph for this function:

◆ splitSignTokens()

std::vector< std::string > FunctionParserBase::splitSignTokens ( const std::string &  expr_no_ws)
staticprotected

Helper static method to split an expression into tokens based on sign characters.

Parameters
expr_no_wsThe expression string with no whitespace.
Returns
A vector of tokens split by sign characters.
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ FunctionParserBaseTester

friend class FunctionParserBaseTester
friend

Friend test fixture class for unit testing.

Member Data Documentation

◆ function_str

std::string FunctionParserBase::function_str
protected

The function string to be parsed.


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