1
/* $Id: formula.hpp 24955 2008-03-21 23:11:31Z dragonking $ */
3
Copyright (C) 2007 - 2008 by David White <dave@whitevine.net>
4
Part of the Silver Tree Project
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License version 2 or later.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY.
11
See the COPYING file for more details.
14
#ifndef FORMULA_HPP_INCLUDED
15
#define FORMULA_HPP_INCLUDED
20
#include "formula_callable_definition_fwd.hpp"
21
#include "formula_fwd.hpp"
22
#include "formula_function.hpp"
23
#include "variant.hpp"
24
#include "wml_value.hpp"
29
class formula_callable;
30
class formula_expression;
31
class function_symbol_table;
32
typedef boost::shared_ptr<formula_expression> expression_ptr;
36
static variant evaluate(const const_formula_ptr& f,
37
const formula_callable& variables,
38
variant default_res=variant(0)) {
40
return f->execute(variables);
46
// function which will create a formula that is a single string literal, 'str'.
47
// 'str' should not be enclosed in quotes.
48
static formula_ptr create_string_formula(const std::string& str);
49
static formula_ptr create_optional_formula(const wml::value& str, function_symbol_table* symbols=NULL, const formula_callable_definition* def=NULL);
50
explicit formula(const wml::value& val, function_symbol_table* symbols=NULL, const formula_callable_definition* def=NULL);
52
variant execute(const formula_callable& variables) const;
53
variant execute() const;
54
const std::string& str() const { return str_; }
56
void output_debug_info() const;
62
const std::string* filename_;