- added support for calling member functions (setters/getters) from Models
those functions can be used with databases and flat files - removed support for calling static function - if MORM_HAS_EZC_LIBRARY macro is defined then we can call a function which has a first argument Ezc::FunInfo<>& object (only for generating flat files)
This commit is contained in:
@@ -44,8 +44,9 @@
|
||||
#include "ft.h"
|
||||
#include "convert/text.h"
|
||||
|
||||
// put some macro
|
||||
#ifdef MORM_HAS_EZC_LIBRARY
|
||||
#include "funinfo.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace morm
|
||||
@@ -135,8 +136,14 @@ public:
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void field(const wchar_t * field_name, void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
|
||||
|
||||
#ifdef MORM_HAS_EZC_LIBRARY
|
||||
template<typename FunInfoStreamType>
|
||||
void field(const wchar_t * field_name, void (*fun)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
|
||||
void field(const wchar_t * field_name, void (Model::*fun)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
{
|
||||
@@ -184,6 +191,7 @@ public:
|
||||
field_after();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -204,20 +212,26 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// not finished yet
|
||||
void put_field_value(void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env);
|
||||
|
||||
|
||||
|
||||
#ifdef MORM_HAS_EZC_LIBRARY
|
||||
template<typename FunInfoStreamType>
|
||||
void put_field_value(void (*fun)(Ezc::FunInfo<FunInfoStreamType>&), const FT & field_type, ModelEnv * model_env)
|
||||
void put_field_value(void (Model::*getter_method)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( model_env && model_env->ezc_fun_info && model_env->ezc_fun_info_typeinfo )
|
||||
if( model_env && model_env->model && model_env->ezc_fun_info && model_env->ezc_fun_info_typeinfo )
|
||||
{
|
||||
if( typeid(Ezc::FunInfo<FunInfoStreamType>) == *model_env->ezc_fun_info_typeinfo )
|
||||
{
|
||||
fun(*reinterpret_cast<Ezc::FunInfo<FunInfoStreamType>*>(model_env->ezc_fun_info));
|
||||
before_field_value_string(field_type);
|
||||
(model_env->model->*getter_method)(*reinterpret_cast<Ezc::FunInfo<FunInfoStreamType>*>(model_env->ezc_fun_info));
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
|
||||
//put_field_value(info.out, field_type);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template<typename FieldValue>
|
||||
|
Reference in New Issue
Block a user