changed the way how we get a specific field value - now we do not use expressions (BaseExpression), to get the raw value we don't need an expression object:

- removed MORM_WORK_MODE_GET_SPECIFIC_FIELD_VALUE from expression work mode
- removed: void BaseExpression::field(const wchar_t * field_name, void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env)
- removed from BaseExpression: template<typename FunInfoStreamType> void field(const wchar_t * field_name, void (Model::*fun)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
- removed: void FlatConnector::to_text(const wchar_t * flat_field_name, pt::TextStream & stream, Model & model)
- renamed/changed: Model::put_field_value(...) -> Model::get_raw_value()

added classes:
class ModelWrapper - base wrapper class for a model or a model container
class ModelWrapperModel : public ModelWrapper - wrapper for a model
template<typename VectorType> class ModelWrapperVector : public ModelWrapper - wrapper for vector of models
template<typename ListType> class ModelWrapperList : public ModelWrapper - wrapper for list of models
ModelWrapper... classes are used by ezc library for iterating through child models and for iterating in [for...] statements

added to Model:
Model * get_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool put_log_if_not_found = true);
ModelWrapper * get_model_wrapper(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool put_log_if_not_found = true);
This commit is contained in:
2021-06-16 14:01:07 +02:00
parent dd01fafa40
commit aeb02f82b1
11 changed files with 567 additions and 256 deletions

View File

@@ -122,79 +122,12 @@ public:
put_field_value_or_null(field_value, field_type, model_env);
}
}
else
if( work_mode == MORM_WORK_MODE_GET_SPECIFIC_FIELD_VALUE )
{
if( model_env && model_env->flat_field_name && pt::is_equal(model_env->flat_field_name, field_name) )
{
put_field_value_or_null(field_value, field_type, model_env);
}
}
field_after();
}
}
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 (Model::*fun)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
{
if( out_stream && can_field_be_generated(field_type) )
{
field_before();
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
{
put_field_name_and_table_if_needed(field_name, field_type, model_env);
}
else
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
{
put_field_value(fun, field_type, model_env);
}
else
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
{
if( model_env && model_env->set_field_name_helper )
{
if( (size_t)model_env->field_index < model_env->set_field_name_helper->size() )
{
put_field_name_and_table_if_needed((*model_env->set_field_name_helper)[model_env->field_index], field_type, model_env);
put_name_value_separator();
put_field_value(fun, field_type, model_env);
}
model_env->field_index += 1;
}
else
{
put_field_name_and_table_if_needed(field_name, field_type, model_env);
put_name_value_separator();
put_field_value(fun, field_type, model_env);
}
}
else
if( work_mode == MORM_WORK_MODE_GET_SPECIFIC_FIELD_VALUE )
{
if( model_env && model_env->flat_field_name && pt::is_equal(model_env->flat_field_name, field_name) )
{
put_field_value(fun, field_type, model_env);
}
}
field_after();
}
}
#endif
template<typename FieldValue>
void put_field_value_or_null(const FieldValue & field_value, const FT & field_type, ModelEnv * model_env)
{
@@ -212,28 +145,6 @@ public:
}
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 (Model::*getter_method)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env)
{
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 )
{
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);
}
}
}
#endif
template<typename FieldValue>
void field_in(pt::TextStream & stream, const wchar_t * field_name, const std::set<FieldValue> & container, ModelEnv * model_env)
{