Skip to content
Snippets Groups Projects
Commit 12105975 authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

add has (var_name) to ParsedExpression

parent 958384b8
Branches
No related merge requests found
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.0)
set(wccl_ver_major "0")
set(wccl_ver_minor "1")
set(wccl_ver_patch "3")
set(wccl_ver_patch "4")
set(LIBWCCL_VERSION "${wccl_ver_major}.${wccl_ver_minor}.${wccl_ver_patch}")
......
......@@ -129,6 +129,14 @@ public:
template<class T>
void set(const std::string& var_name, const T& value);
/**
* Checks if has a variable with given name and type.
* @returns if such variable exists AND is of type T.
* @param var_name Variable name.
*/
template<class T>
bool has(const std::string& var_name);
/**
* Sets all variables to their default values.
* @note Values of variables are preserved between applications
......@@ -235,6 +243,12 @@ void ParsedExpression::set(const std::string& var_name, const T& value) {
get<T>(var_name) = value;
}
template<class T>
bool ParsedExpression::has(const std::string& var_name) {
boost::shared_ptr<T> value = variables_->get<T>(var_name);
return value;
}
inline
void ParsedExpression::clean()
{
......
......@@ -42,8 +42,16 @@ namespace Wccl {
%template(get_strset) get<StrSet>;
%template(get_position) get<Position>;
%template(get_match) get<Match>;
template<class T> bool has(const std::string& var_name);
%template(has_bool) has<Bool>;
%template(has_tset) has<TSet>;
%template(has_strset) has<StrSet>;
%template(has_position) has<Position>;
%template(has_match) has<Match>;
/* --------------------------------------------------------------------- */
/* Those functions are overridden later to handle shared_ptr values,
* anyway they are needed for those overrides to work. */
template<class T> void set(const std::string& var_name, const T& value);
%template(set_bool) set<Bool>;
%template(set_tset) set<TSet>;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment