AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Tokenizer.h
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * AQUAgpusph is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
24#ifndef TOKENIZER_H_INCLUDED
25#define TOKENIZER_H_INCLUDED
26
27#include <map>
28#include <string>
29#include <muParser.h>
30
31namespace Aqua {
32
42{
43 public:
45 Tokenizer();
46
48 ~Tokenizer();
49
61 bool registerVariable(const std::string name, float value);
62
65 void clearVariables();
66
72 bool isVariable(const std::string name);
73
79 float variable(const std::string name);
80
86 float solve(const std::string eq);
87
88 protected:
95 virtual void defaultVariables();
96
97 private:
99 mu::Parser p;
100}; // class Tokenizer
101
102} // namespaces
103
104#endif // TOKENIZER_H_INCLUDED
Tool to evaluate math expressions.
Definition: Tokenizer.h:42
bool registerVariable(const std::string name, float value)
Register a variable.
Definition: Tokenizer.cpp:95
float variable(const std::string name)
Returns a variable value.
Definition: Tokenizer.cpp:130
void clearVariables()
Clear/unregister all the registered variables.
Definition: Tokenizer.cpp:108
~Tokenizer()
Destructor.
Definition: Tokenizer.cpp:89
float solve(const std::string eq)
Solve a math expression.
Definition: Tokenizer.cpp:140
bool isVariable(const std::string name)
Checks if a variable has been registered.
Definition: Tokenizer.cpp:115
virtual void defaultVariables()
Register the default variables.
Definition: Tokenizer.cpp:179
Tokenizer()
Constructor.
Definition: Tokenizer.cpp:50
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45