From aba454a4bfab663c128e60fa5122adcf161e387b Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Sat, 19 Jun 2021 20:25:38 +0200 Subject: [PATCH] methods Model::get_raw_value(...) now returns boolean - true if a field was found --- src/model.cpp | 9 ++++++--- src/model.h | 13 ++++++++++--- src/modelenv.h | 11 +++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/model.cpp b/src/model.cpp index 9b34b72..ac0e95f 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -317,13 +317,13 @@ ModelWrapper * Model::get_model_wrapper(const wchar_t * db_field_name, const wch -void Model::get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, pt::TextStream & stream, bool clear_stream, bool put_log_if_not_found) +bool Model::get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, pt::TextStream & stream, bool clear_stream, bool put_log_if_not_found) { - get_raw_value(db_field_name, flat_field_name, nullptr, stream, clear_stream, put_log_if_not_found); + return get_raw_value(db_field_name, flat_field_name, nullptr, stream, clear_stream, put_log_if_not_found); } -void Model::get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, pt::TextStream & stream, bool clear_stream, bool put_log_if_not_found) +bool Model::get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, pt::TextStream & stream, bool clear_stream, bool put_log_if_not_found) { if( clear_stream ) { @@ -363,6 +363,7 @@ void Model::get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_fi } model_env = nullptr; + return model_env_local.was_field_found; } @@ -1839,6 +1840,8 @@ void Model::field_member_put_field_raw_value_to_stream( if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) && (is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) ) { + model_env->was_field_found = true; + if( model_env->stream ) { (model_env->model->*getter_method)(*model_env->stream); diff --git a/src/model.h b/src/model.h index acbbc18..d637369 100644 --- a/src/model.h +++ b/src/model.h @@ -255,14 +255,14 @@ public: 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); - void get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, pt::TextStream & stream, bool clear_stream = true, bool put_log_if_not_found = true); - void get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, pt::TextStream & stream, bool clear_stream = true, bool put_log_if_not_found = true); + bool get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, pt::TextStream & stream, bool clear_stream = true, bool put_log_if_not_found = true); + bool get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, pt::TextStream & stream, bool clear_stream = true, bool put_log_if_not_found = true); #ifdef MORM_HAS_EZC_LIBRARY template - void get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, + bool get_raw_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelData * model_data, Ezc::FunInfo & fun_info, pt::TextStream & stream, bool clear_stream = true) { if( clear_stream ) @@ -295,6 +295,7 @@ public: } model_env = nullptr; + return model_env_local.was_field_found; } #endif @@ -760,6 +761,8 @@ protected: if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) && (is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) ) { + model_env->was_field_found = true; + if( model_env->stream ) { (*model_env->stream) << field_value; @@ -890,6 +893,8 @@ protected: if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) && (is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) ) { + model_env->was_field_found = true; + if( typeid(Ezc::FunInfo) == *model_env->ezc_fun_info_typeinfo ) { Ezc::FunInfo * ezc_fun_info = reinterpret_cast*>(model_env->ezc_fun_info); @@ -928,6 +933,7 @@ protected: if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) && (is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) ) { + model_env->was_field_found = true; model_env->ezc_fun_result = (model_env->model->*method)(); } } @@ -954,6 +960,7 @@ protected: if( (is_empty_field(model_env->db_field_name) || is_the_same_field(db_field_name, model_env->db_field_name)) && (is_empty_field(model_env->flat_field_name) || is_the_same_field(flat_field_name, model_env->flat_field_name)) ) { + model_env->was_field_found = true; model_env->ezc_fun_result = (model_env->model->*method)(); } } diff --git a/src/modelenv.h b/src/modelenv.h index ea30753..1a796f7 100644 --- a/src/modelenv.h +++ b/src/modelenv.h @@ -94,6 +94,7 @@ public: Model * child_model; ModelWrapper * model_wrapper; pt::TextStream * stream; + bool was_field_found; // used only in MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM #ifdef MORM_HAS_EZC_LIBRARY @@ -113,6 +114,11 @@ public: ModelEnv(const ModelEnv & e) + { + operator=(e); + } + + ModelEnv & operator=(const ModelEnv & e) { copy_global_objects(e); @@ -129,6 +135,7 @@ public: child_model = e.child_model; model_wrapper = e.model_wrapper; stream = e.stream; + was_field_found = e.was_field_found; #ifdef MORM_HAS_EZC_LIBRARY ezc_fun_info = e.ezc_fun_info; @@ -138,6 +145,8 @@ public: // schema_name and table_name don't have to be copied table2_name = nullptr; + + return *this; } @@ -177,6 +186,7 @@ public: child_model = nullptr; model_wrapper = nullptr; stream = nullptr; + was_field_found = false; #ifdef MORM_HAS_EZC_LIBRARY ezc_fun_info = nullptr; @@ -198,6 +208,7 @@ public: } } + }; }