2018-03-13 23:22:17 +01:00
/*
* This file is a part of morm
* and is distributed under the 2 - Clause BSD licence .
* Author : Tomasz Sowa < t . sowa @ ttmath . org >
*/
/*
2021-02-23 16:58:45 +01:00
* Copyright ( c ) 2018 - 2021 , Tomasz Sowa
2018-03-13 23:22:17 +01:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
*
* 1. Redistributions of source code must retain the above copyright notice ,
* this list of conditions and the following disclaimer .
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS "
* AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR
* CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS
* INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN
* CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE )
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE .
*
*/
# ifndef headerfile_morm_model
# define headerfile_morm_model
# include <string>
2019-08-20 17:49:37 +02:00
# include <list>
# include <vector>
2019-09-11 20:16:22 +02:00
# include <typeinfo>
2019-09-25 18:20:37 +02:00
# include <type_traits>
2018-03-13 23:22:17 +01:00
# include "textstream/textstream.h"
2021-03-11 18:40:32 +01:00
# include "space/space.h"
2018-03-13 23:22:17 +01:00
# include "modelconnector.h"
2018-07-05 11:51:26 +02:00
# include "dbexpression.h"
# include "flatexpression.h"
2019-05-13 19:59:28 +02:00
# include "modelenv.h"
2021-03-10 16:20:11 +01:00
# include "ft.h"
2021-07-01 22:55:56 +02:00
# include "wrapper.h"
2018-03-13 23:22:17 +01:00
2021-06-01 19:34:34 +02:00
# ifdef MORM_HAS_EZC_LIBRARY
2021-09-08 15:34:40 +02:00
# include "env.h"
2021-06-01 19:34:34 +02:00
# endif
# define MORM_MODEL_MEMBER_FIELD(ClassName) \
void field ( const wchar_t * field_name , \
2021-06-20 17:49:54 +02:00
void ( ClassName : : * getter_method ) ( pt : : Stream & ) , \
2021-06-01 19:34:34 +02:00
void ( ClassName : : * setter_method ) ( const char * input_str ) , \
const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
field ( field_name , field_name , getter_method , setter_method , field_type ) ; \
} \
void field ( const wchar_t * db_field_name , \
const wchar_t * flat_field_name , \
2021-06-20 17:49:54 +02:00
void ( ClassName : : * getter_method ) ( pt : : Stream & ) , \
2021-06-01 19:34:34 +02:00
void ( ClassName : : * setter_method ) ( const char * input_str ) , \
const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
2021-06-20 17:49:54 +02:00
typedef void ( Model : : * ModelGetterMethod ) ( pt : : Stream & ) ; \
2021-06-01 19:34:34 +02:00
typedef void ( Model : : * ModelSetterMethod ) ( const char * input_str ) ; \
ModelGetterMethod model_getter_method = static_cast < ModelGetterMethod > ( getter_method ) ; \
ModelSetterMethod model_setter_method = static_cast < ModelSetterMethod > ( setter_method ) ; \
field_member ( db_field_name , flat_field_name , model_getter_method , model_setter_method , field_type ) ; \
} \
using Model : : field ;
# ifdef MORM_HAS_EZC_LIBRARY
# define MORM_MODEL_MEMBER_FIELD_EZC(ClassName) \
template < typename FunInfoStreamType > \
2021-09-08 15:34:40 +02:00
void field ( const wchar_t * field_name , void ( ClassName : : * method ) ( Ezc : : Env < FunInfoStreamType > & ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
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);
2021-06-16 14:01:07 +02:00
{ \
field ( field_name , field_name , method , field_type ) ; \
} \
template < typename FunInfoStreamType > \
2021-09-08 15:34:40 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , void ( ClassName : : * method ) ( Ezc : : Env < FunInfoStreamType > & ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
2021-06-01 19:34:34 +02:00
{ \
2021-09-08 15:34:40 +02:00
typedef void ( Model : : * ModelMember ) ( Ezc : : Env < FunInfoStreamType > & ) ; \
2021-06-01 19:34:34 +02:00
ModelMember model_member = static_cast < ModelMember > ( method ) ; \
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);
2021-06-16 14:01:07 +02:00
field_member_ezc ( db_field_name , flat_field_name , model_member , field_type ) ; \
2021-06-18 19:05:50 +02:00
} \
void field ( const wchar_t * field_name , bool ( ClassName : : * method ) ( ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
field ( field_name , field_name , method , field_type ) ; \
} \
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , bool ( ClassName : : * method ) ( ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
typedef bool ( Model : : * ModelMember ) ( ) ; \
ModelMember model_member = static_cast < ModelMember > ( method ) ; \
field_member_ezc ( db_field_name , flat_field_name , model_member , field_type ) ; \
} \
void field ( const wchar_t * field_name , bool ( ClassName : : * method ) ( ) const , const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
field ( field_name , field_name , method , field_type ) ; \
} \
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , bool ( ClassName : : * method ) ( ) const , const morm : : FT & field_type = morm : : FT : : default_type ) \
{ \
typedef bool ( Model : : * ModelMember ) ( ) const ; \
ModelMember model_member = static_cast < ModelMember > ( method ) ; \
field_member_ezc ( db_field_name , flat_field_name , model_member , field_type ) ; \
} \
2021-07-01 22:55:56 +02:00
void field ( const wchar_t * field_name , void ( ClassName : : * method ) ( morm : : Wrapper & ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
2021-06-18 19:05:50 +02:00
{ \
field ( field_name , field_name , method , field_type ) ; \
} \
2021-07-01 22:55:56 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , void ( ClassName : : * method ) ( morm : : Wrapper & ) , const morm : : FT & field_type = morm : : FT : : default_type ) \
2021-06-18 19:05:50 +02:00
{ \
2021-07-01 22:55:56 +02:00
typedef void ( Model : : * ModelMember ) ( morm : : Wrapper & ) ; \
2021-06-18 19:05:50 +02:00
ModelMember model_member = static_cast < ModelMember > ( method ) ; \
field_member_ezc ( db_field_name , flat_field_name , model_member , field_type ) ; \
2021-06-01 19:34:34 +02:00
}
# endif
# ifdef MORM_HAS_EZC_LIBRARY
# define MORM_MEMBER_FIELD(ClassName) MORM_MODEL_MEMBER_FIELD(ClassName) MORM_MODEL_MEMBER_FIELD_EZC(ClassName)
# else
# define MORM_MEMBER_FIELD(ClassName) MORM_MODEL_MEMBER_FIELD(ClassName)
# endif
2021-05-31 18:40:28 +02:00
2018-03-13 23:22:17 +01:00
namespace morm
{
class Model
{
public :
2018-04-22 03:26:46 +02:00
enum SaveMode
{
2019-09-13 20:17:02 +02:00
DO_INSERT_ON_SAVE = 0 ,
2018-04-22 03:26:46 +02:00
DO_UPDATE_ON_SAVE ,
DO_DELETE_ON_SAVE ,
DO_NOTHING_ON_SAVE ,
} ;
virtual void set_save_mode ( SaveMode save_mode ) ;
virtual SaveMode get_save_mode ( ) ;
2021-03-09 18:10:34 +01:00
virtual void set_has_primary_key_set ( bool has_primary_key ) ;
virtual bool get_has_primary_key_set ( ) ;
2018-04-22 03:26:46 +02:00
virtual void mark_to_delete ( ) ;
virtual void mark_to_remove ( ) ;
virtual void mark_to_insert ( ) ;
virtual void mark_to_update ( ) ;
virtual bool object_exists ( ) ;
virtual bool found ( ) ;
2018-03-13 23:22:17 +01:00
void set_connector ( ModelConnector & connector ) ;
2018-04-22 03:26:46 +02:00
void set_connector ( ModelConnector * connector ) ;
2021-02-23 16:58:45 +01:00
ModelConnector * get_connector ( ) ;
2018-03-13 23:22:17 +01:00
2021-05-20 16:25:01 +02:00
virtual void get_table_name ( pt : : WTextStream & stream , bool with_schema_name = true , ModelData * model_data = nullptr , bool clear_stream = true ) ;
2021-05-14 03:24:53 +02:00
virtual void get_table_name ( std : : wstring & str , bool with_schema_name = true , ModelData * model_data = nullptr , bool clear_string = true ) ;
virtual void get_table_name ( std : : string & str , bool with_schema_name = true , ModelData * model_data = nullptr , bool clear_string = true ) ;
2021-05-20 16:25:01 +02:00
virtual void to_text ( pt : : TextStream & stream , ModelData * model_data , bool clear_stream = true , bool dump_mode = false ) ;
virtual void to_text ( pt : : TextStream & stream , ModelData & model_data , bool clear_stream = true , bool dump_mode = false ) ;
virtual void to_text ( pt : : TextStream & stream , bool clear_stream = true , bool dump_mode = false ) ;
2019-03-07 19:02:29 +01:00
2019-09-13 20:17:02 +02:00
virtual void to_text ( std : : string & str , ModelData * model_data , bool clear_string = true , bool dump_mode = false ) ;
virtual void to_text ( std : : string & str , ModelData & model_data , bool clear_string = true , bool dump_mode = false ) ;
virtual void to_text ( std : : string & str , bool clear_string = true , bool dump_mode = false ) ;
2019-03-07 19:02:29 +01:00
2018-03-23 20:26:57 +01:00
virtual std : : string to_text ( ) ;
virtual std : : string to_string ( ) ;
2018-03-13 23:22:17 +01:00
2021-05-20 16:25:01 +02:00
virtual void generate_insert_query ( pt : : TextStream & stream , ModelData * model_data = nullptr ) ;
2019-09-25 18:20:37 +02:00
virtual bool insert ( ModelData * model_data , bool insert_whole_tree = true ) ;
2019-08-21 19:42:50 +02:00
virtual bool insert ( ModelData & model_data , bool insert_whole_tree = true ) ;
2019-09-25 18:20:37 +02:00
virtual bool insert ( bool insert_whole_tree = true ) ;
2018-03-13 23:22:17 +01:00
2021-05-20 16:25:01 +02:00
virtual void generate_update_query ( pt : : TextStream & stream , ModelData * model_data = nullptr ) ;
2019-09-25 18:20:37 +02:00
virtual bool update ( ModelData * model_data , bool update_whole_tree = true ) ;
2019-09-04 18:02:18 +02:00
virtual bool update ( ModelData & model_data , bool update_whole_tree = true ) ;
2019-09-25 18:20:37 +02:00
virtual bool update ( bool update_whole_tree = true ) ;
2018-03-13 23:22:17 +01:00
2021-05-20 16:25:01 +02:00
virtual void generate_remove_query ( pt : : TextStream & stream , ModelData * model_data = nullptr ) ;
2019-09-25 18:20:37 +02:00
virtual bool remove ( ModelData * model_data , bool remove_whole_tree = true ) ;
2019-09-05 18:32:35 +02:00
virtual bool remove ( ModelData & model_data , bool remove_whole_tree = true ) ;
2019-09-25 18:20:37 +02:00
virtual bool remove ( bool remove_whole_tree = true ) ;
2018-04-22 03:26:46 +02:00
2019-09-25 18:20:37 +02:00
virtual bool save ( ModelData * model_data , bool save_whole_tree = true ) ;
2019-09-04 18:02:18 +02:00
virtual bool save ( ModelData & model_data , bool save_whole_tree = true ) ;
2019-09-25 18:20:37 +02:00
virtual bool save ( bool save_whole_tree = true ) ;
2018-03-13 23:22:17 +01:00
2021-05-20 16:25:01 +02:00
virtual void generate_select_columns ( pt : : TextStream & stream ) ;
2018-03-30 21:34:45 +02:00
// set object to default values
virtual void clear ( ) ;
2018-03-13 23:22:17 +01:00
2021-05-14 03:24:53 +02:00
virtual bool do_migration ( int & current_table_version ) ;
2019-08-22 20:33:35 +02:00
// IMPROVE ME this will be protected
// add set_field_value() functions for each POD type
template < typename FieldValue >
void set_field_value_generic ( const wchar_t * db_field_name , const wchar_t * flat_field_name , const FieldValue & field_value )
{
ModelEnv model_env_local ;
model_env = & model_env_local ;
2019-09-18 17:28:06 +02:00
model_env - > model_work_mode = MORM_MODEL_WORK_MODE_SET_FIELD_VALUE ;
2021-06-01 19:34:34 +02:00
model_env - > model = this ;
2019-08-22 20:33:35 +02:00
2019-09-11 20:16:22 +02:00
FieldValueHelper field_value_helper ;
field_value_helper . db_field_name = db_field_name ;
field_value_helper . flat_field_name = flat_field_name ;
field_value_helper . value_object = & field_value ;
field_value_helper . value_type_info = & typeid ( field_value ) ;
2019-08-22 20:33:35 +02:00
2019-09-11 20:16:22 +02:00
std : : vector < FieldValueHelper > helper_tab ;
helper_tab . push_back ( field_value_helper ) ;
model_env - > field_value_helper_tab = & helper_tab ;
2019-08-22 20:33:35 +02:00
2021-05-13 03:27:21 +02:00
fields ( ) ;
2019-08-22 20:33:35 +02:00
2019-09-24 19:08:45 +02:00
if ( ! helper_tab . back ( ) . found & & model_connector )
{
2021-05-20 16:25:01 +02:00
pt : : Log * plog = model_connector - > get_logger ( ) ;
2019-09-24 19:08:45 +02:00
if ( plog )
{
2021-05-20 16:25:01 +02:00
( * plog ) < < pt : : Log : : log1 < < " Morm: I cannot find such a property: " ;
2019-09-24 19:08:45 +02:00
put_fields_to_log ( * plog , db_field_name , flat_field_name ) ;
2021-05-20 16:25:01 +02:00
( * plog ) < < pt : : Log : : logend ;
2019-09-24 19:08:45 +02:00
}
}
2019-08-22 20:33:35 +02:00
// what if an exception was thrown?
model_env = nullptr ;
}
2018-04-17 00:46:25 +02:00
2019-03-26 19:34:07 +01:00
2021-07-01 22:55:56 +02:00
Model * get_model ( const wchar_t * db_field_name , const wchar_t * flat_field_name ) ;
Wrapper get_wrapper ( const wchar_t * db_field_name , const wchar_t * flat_field_name ) ;
2021-05-31 18:40:28 +02:00
2021-07-01 22:55:56 +02:00
bool get_raw_value ( const wchar_t * db_field_name , const wchar_t * flat_field_name , pt : : Stream & stream , bool clear_stream = true ) ;
bool get_raw_value ( const wchar_t * db_field_name , const wchar_t * flat_field_name , ModelData * model_data , pt : : Stream & stream , bool clear_stream = true ) ;
2021-05-31 18:40:28 +02:00
2021-06-01 19:34:34 +02:00
# ifdef MORM_HAS_EZC_LIBRARY
2021-05-31 18:40:28 +02:00
template < typename FunInfoStreamType >
2021-06-19 20:25:38 +02:00
bool get_raw_value ( const wchar_t * db_field_name , const wchar_t * flat_field_name , ModelData * model_data ,
2021-10-27 14:24:48 +02:00
Ezc : : Env < FunInfoStreamType > & env )
2021-05-31 18:40:28 +02:00
{
ModelEnv model_env_local ;
model_env = & model_env_local ;
model_env - > has_primary_key_set = has_primary_key_set ;
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);
2021-06-16 14:01:07 +02:00
model_env - > model_work_mode = MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM ;
model_env - > db_field_name = db_field_name ;
model_env - > flat_field_name = flat_field_name ;
2021-05-31 18:40:28 +02:00
model_env - > model_data = model_data ;
2021-10-27 14:24:48 +02:00
model_env - > ezc_fun_info = & env ;
model_env - > ezc_fun_info_typeinfo = & typeid ( env ) ;
2021-06-01 19:34:34 +02:00
model_env - > model = this ;
2021-05-31 18:40:28 +02:00
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);
2021-06-16 14:01:07 +02:00
try
2021-05-31 18:40:28 +02:00
{
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);
2021-06-16 14:01:07 +02:00
fields ( ) ;
2021-09-08 15:34:40 +02:00
//fun_info.res = model_env->ezc_fun_result;
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);
2021-06-16 14:01:07 +02:00
}
catch ( . . . )
{
model_env = nullptr ;
throw ;
2021-05-31 18:40:28 +02:00
}
model_env = nullptr ;
2021-06-19 20:25:38 +02:00
return model_env_local . was_field_found ;
2021-05-31 18:40:28 +02:00
}
2021-06-01 19:34:34 +02:00
# endif
2021-05-31 18:40:28 +02:00
2018-03-13 23:22:17 +01:00
protected :
ModelConnector * model_connector ;
2019-05-13 19:59:28 +02:00
ModelEnv * model_env ;
2021-03-09 18:10:34 +01:00
SaveMode save_mode ;
bool has_primary_key_set ;
2019-05-13 19:59:28 +02:00
2018-11-14 18:14:26 +01:00
2018-03-13 23:22:17 +01:00
Model ( ) ;
2018-11-14 18:14:26 +01:00
Model ( const Model & m ) ;
2018-03-13 23:22:17 +01:00
virtual ~ Model ( ) ;
2021-05-13 03:27:21 +02:00
/*
* the main method of mapping between fields and database resultsets
*/
virtual void fields ( ) = 0 ;
virtual void table ( ) ;
virtual void table_name ( const wchar_t * table_name ) ;
virtual void table_name ( const wchar_t * schema_name , const wchar_t * table_name ) ;
2018-04-17 00:46:25 +02:00
virtual void before_select ( ) ;
virtual void before_insert ( ) ;
virtual void before_update ( ) ;
2018-04-22 03:26:46 +02:00
virtual void before_remove ( ) ;
2018-04-17 00:46:25 +02:00
virtual void after_select ( ) ;
virtual void after_insert ( ) ;
virtual void after_update ( ) ;
2018-04-22 03:26:46 +02:00
virtual void after_remove ( ) ;
virtual void after_select_failure ( ) ;
virtual void after_insert_failure ( ) ;
virtual void after_update_failure ( ) ;
virtual void after_remove_failure ( ) ;
2018-03-13 23:22:17 +01:00
2019-09-18 17:28:06 +02:00
virtual int get_work_mode ( ) ;
2018-04-19 17:21:51 +02:00
2019-05-13 19:59:28 +02:00
virtual ModelData * get_model_data ( ) ;
2019-08-21 19:42:50 +02:00
virtual bool insert_tree ( bool insert_whole_tree ) ;
2019-09-04 18:02:18 +02:00
virtual bool update_tree ( bool update_whole_tree ) ;
2019-09-05 18:32:35 +02:00
virtual bool remove_tree ( bool remove_whole_tree ) ;
2019-09-04 18:02:18 +02:00
virtual bool save_tree ( bool save_whole_tree ) ;
2019-05-21 17:51:13 +02:00
2019-05-13 19:59:28 +02:00
virtual void map_values_from_query ( ) ;
2018-07-04 13:34:49 +02:00
2021-05-14 03:24:53 +02:00
virtual bool db_query ( const char * raw_sql ) ;
virtual bool db_query ( const std : : string & raw_sql ) ;
2021-05-20 16:25:01 +02:00
virtual bool db_query ( const pt : : TextStream & raw_sql ) ;
2021-06-27 22:43:10 +02:00
virtual bool db_query ( const char * * raw_sql , size_t len ) ;
2018-07-04 13:34:49 +02:00
2021-06-01 19:34:34 +02:00
2018-07-03 18:55:06 +02:00
/////////////////////////////////
2019-09-25 19:21:12 +02:00
/*
* IMPLEMENT ME
2021-05-12 00:27:35 +02:00
* field methods for such field_values : signed char , char16_t , char32_t , std : : u16string , std : : u32string
2019-09-25 19:21:12 +02:00
*
*/
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , char & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , unsigned char & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , wchar_t & field_value , const FT & field_type = FT : : default_type )
2021-05-11 22:11:31 +02:00
{
field_generic ( field_name , field_name , field_value , field_type ) ;
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , std : : wstring & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , std : : string & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , bool & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , short & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , unsigned short & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , int & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , unsigned int & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , unsigned long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , long long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , unsigned long long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , float & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , double & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , long double & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-20 16:25:01 +02:00
void field ( const wchar_t * field_name , pt : : Date & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-07-01 22:55:56 +02:00
field_date ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-20 16:25:01 +02:00
void field ( const wchar_t * field_name , pt : : Space & field_value , const FT & field_type = FT : : default_type )
2021-03-11 18:40:32 +01:00
{
2021-06-22 17:59:44 +02:00
field_space ( field_name , field_name , field_value , field_type ) ;
2021-03-11 18:40:32 +01:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * field_name , Model & field_value , const FT & field_type = FT : : default_type )
2018-04-26 20:58:31 +02:00
{
2021-03-10 16:20:11 +01:00
field_model ( field_name , field_name , field_value , field_type ) ;
2018-04-26 20:58:31 +02:00
}
2021-06-16 22:23:30 +02:00
template < typename ContainerItemType >
void field ( const wchar_t * field_name , std : : list < ContainerItemType > & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
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);
2021-06-16 14:01:07 +02:00
field_list ( field_name , field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2018-04-26 20:58:31 +02:00
2021-06-16 22:23:30 +02:00
template < typename ContainerItemType >
void field ( const wchar_t * field_name , std : : vector < ContainerItemType > & field_value , const FT & field_type = FT : : default_type )
2019-08-20 17:49:37 +02:00
{
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);
2021-06-16 14:01:07 +02:00
field_vector ( field_name , field_name , field_value , field_type ) ;
2019-08-20 17:49:37 +02:00
}
2018-04-26 20:58:31 +02:00
2021-06-17 21:31:58 +02:00
template < typename ContainerItemType >
void field ( const wchar_t * field_name , std : : list < ContainerItemType * > & field_value , const FT & field_type = FT : : default_type )
{
field_list ( field_name , field_name , field_value , field_type ) ;
}
template < typename ContainerItemType >
void field ( const wchar_t * field_name , std : : vector < ContainerItemType * > & field_value , const FT & field_type = FT : : default_type )
{
field_vector ( field_name , field_name , field_value , field_type ) ;
}
2021-06-01 19:34:34 +02:00
2021-05-31 18:40:28 +02:00
2018-04-26 20:58:31 +02:00
2021-03-10 16:20:11 +01:00
/*
* field methods which take two names : db_field_name and flat_field_name
*/
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , char & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , unsigned char & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , wchar_t & field_value , const FT & field_type = FT : : default_type )
2021-05-11 22:11:31 +02:00
{
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : wstring & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : string & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , bool & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , short & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , unsigned short & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , int & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , unsigned int & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , unsigned long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , long long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , unsigned long long & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , float & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , double & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , long double & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-20 16:25:01 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , pt : : Date & field_value , const FT & field_type = FT : : default_type )
2018-07-03 18:55:06 +02:00
{
2021-07-01 22:55:56 +02:00
field_date ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-03 18:55:06 +02:00
}
2021-05-20 16:25:01 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , pt : : Space & field_value , const FT & field_type = FT : : default_type )
2021-03-11 18:40:32 +01:00
{
2021-06-22 17:59:44 +02:00
field_space ( db_field_name , flat_field_name , field_value , field_type ) ;
2021-03-11 18:40:32 +01:00
}
2018-07-03 18:55:06 +02:00
2021-05-12 04:53:23 +02:00
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , Model & field_value , const FT & field_type = FT : : default_type )
2018-03-13 23:22:17 +01:00
{
2021-03-10 16:20:11 +01:00
field_model ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-04-22 23:04:50 +02:00
}
2021-06-17 21:31:58 +02:00
template < typename ContainerItemType >
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : list < ContainerItemType > & field_value , const FT & field_type = FT : : default_type )
2018-04-22 23:04:50 +02:00
{
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);
2021-06-16 14:01:07 +02:00
field_list ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-04-22 23:04:50 +02:00
}
2021-06-17 21:31:58 +02:00
template < typename ContainerItemType >
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : vector < ContainerItemType > & field_value , const FT & field_type = FT : : default_type )
2019-08-20 17:49:37 +02:00
{
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);
2021-06-16 14:01:07 +02:00
field_vector ( db_field_name , flat_field_name , field_value , field_type ) ;
2019-08-20 17:49:37 +02:00
}
2021-06-17 21:31:58 +02:00
// FIXME we need to correct handle such pointerns, cctor, dtor etc.
template < typename ContainerItemType >
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : list < ContainerItemType * > & field_value , const FT & field_type = FT : : default_type )
{
field_list ( db_field_name , flat_field_name , field_value , field_type ) ;
}
2021-06-01 19:34:34 +02:00
2021-06-17 21:31:58 +02:00
// FIXME we need to correct handle such pointerns, cctor, dtor etc.
template < typename ContainerItemType >
void field ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : vector < ContainerItemType * > & field_value , const FT & field_type = FT : : default_type )
{
field_vector ( db_field_name , flat_field_name , field_value , field_type ) ;
}
2018-07-03 18:55:06 +02:00
protected :
2018-07-04 13:34:49 +02:00
2018-04-22 23:04:50 +02:00
template < typename FieldValue >
2021-03-10 16:20:11 +01:00
void field_generic_set_field_value ( const wchar_t * db_field_name , const wchar_t * flat_field_name , FieldValue & field_value )
2018-04-22 23:04:50 +02:00
{
2019-09-18 16:36:13 +02:00
if ( model_env - > field_value_helper_tab )
2018-04-22 23:04:50 +02:00
{
2019-09-18 16:36:13 +02:00
if ( model_env - > field_index > = 0 & & ( size_t ) model_env - > field_index < model_env - > field_value_helper_tab - > size ( ) )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
FieldValueHelper & helper = ( * model_env - > field_value_helper_tab ) [ model_env - > field_index ] ;
2021-05-20 16:25:01 +02:00
pt : : Log * log = model_connector - > get_logger ( ) ;
2019-09-18 16:36:13 +02:00
2019-09-24 19:08:45 +02:00
if ( ( ! helper . compare_db_field_name | | is_the_same_field ( db_field_name , helper . db_field_name ) ) & &
( ! helper . compare_flat_field_name | | is_the_same_field ( flat_field_name , helper . flat_field_name ) ) )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
if ( helper . value_object & & helper . value_type_info )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
if ( typeid ( field_value ) = = * helper . value_type_info )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
field_value = * ( FieldValue * ) helper . value_object ;
}
else
{
2021-02-24 01:15:17 +01:00
if ( log )
{
2021-05-20 16:25:01 +02:00
( * log ) < < pt : : Log : : log1 < < " Morm: incorrect type of a field in " ;
2021-05-13 02:32:03 +02:00
log_table_name ( ) ;
( * log ) < < " , " ;
2021-02-24 01:15:17 +01:00
put_fields_to_log ( * log , db_field_name , flat_field_name ) ;
( * log ) < < " , type expected " < < typeid ( field_value ) . name ( )
2021-05-20 16:25:01 +02:00
< < " got " < < helper . value_type_info - > name ( ) < < pt : : Log : : logend ;
2021-02-24 01:15:17 +01:00
}
2019-08-22 20:33:35 +02:00
}
}
2019-09-18 16:36:13 +02:00
2019-09-24 19:08:45 +02:00
helper . found = true ;
2019-09-18 16:36:13 +02:00
model_env - > field_index + = 1 ;
2019-08-22 20:33:35 +02:00
}
}
2019-09-18 16:36:13 +02:00
}
}
2019-08-22 20:33:35 +02:00
2021-03-11 18:40:32 +01:00
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-05-12 04:53:23 +02:00
void field_generic_iterate_primary_key_values ( const wchar_t * db_field_name , const wchar_t * flat_field_name , FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
2021-03-10 16:20:11 +01:00
if ( field_type . is_primary_key ( ) )
2019-09-18 16:36:13 +02:00
{
if ( model_env - > field_value_helper_tab )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
if ( model_env - > field_index > = 0 & & ( size_t ) model_env - > field_index < model_env - > field_value_helper_tab - > size ( ) )
2019-08-22 20:33:35 +02:00
{
2019-09-18 16:36:13 +02:00
FieldValueHelper & helper = ( * model_env - > field_value_helper_tab ) [ model_env - > field_index ] ;
helper . value_object = & field_value ;
helper . value_type_info = & typeid ( field_value ) ;
2019-08-22 20:33:35 +02:00
}
2019-09-18 16:36:13 +02:00
}
2019-08-22 20:33:35 +02:00
2019-09-18 16:36:13 +02:00
model_env - > field_index + = 1 ;
}
}
2021-03-11 18:40:32 +01:00
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-05-31 18:40:28 +02:00
void field_generic_generate_flat_string ( const wchar_t * flat_field_name , FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
FlatConnector * flat_connector = model_connector - > get_flat_connector ( ) ;
if ( flat_connector )
{
FlatExpression * flat_expression = flat_connector - > get_expression ( ) ;
if ( flat_expression & & ! is_empty_field ( flat_field_name ) )
{
2021-03-10 16:20:11 +01:00
flat_expression - > field ( flat_field_name , field_value , field_type , model_env ) ;
2019-08-22 20:33:35 +02:00
}
2019-09-18 16:36:13 +02:00
}
}
2021-03-11 18:40:32 +01:00
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-06-01 19:34:34 +02:00
void field_generic_generate_db_sql ( const wchar_t * db_field_name , FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
2019-08-22 20:33:35 +02:00
2019-09-18 16:36:13 +02:00
if ( db_connector )
{
DbExpression * db_expression = db_connector - > get_expression ( ) ;
2019-08-22 20:33:35 +02:00
2019-09-18 16:36:13 +02:00
if ( db_expression & & ! is_empty_field ( db_field_name ) )
2018-07-04 13:34:49 +02:00
{
2021-03-10 16:20:11 +01:00
db_expression - > field ( db_field_name , field_value , field_type , model_env ) ;
2019-09-18 16:36:13 +02:00
}
}
}
2018-07-04 13:34:49 +02:00
2021-03-11 18:40:32 +01:00
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-06-01 19:34:34 +02:00
void field_generic_read_value_from_db_resultset ( const wchar_t * db_field_name , FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
2018-07-04 13:34:49 +02:00
2019-09-18 16:36:13 +02:00
if ( db_connector )
{
if ( ! is_empty_field ( db_field_name ) )
{
if ( model_env - > cursor_helper & & model_env - > cursor_helper - > has_autogenerated_select )
{
2021-03-10 16:20:11 +01:00
get_value_by_field_index ( model_env - > cursor_helper - > current_column , field_value , field_type ) ;
2019-09-18 16:36:13 +02:00
model_env - > cursor_helper - > current_column + = 1 ;
}
else
{
2021-03-10 16:20:11 +01:00
get_value_by_field_name ( db_field_name , field_value , field_type ) ;
2018-07-04 13:34:49 +02:00
}
}
2019-09-18 16:36:13 +02:00
}
}
2018-07-04 13:34:49 +02:00
2021-03-11 18:40:32 +01:00
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-06-01 19:34:34 +02:00
void field_generic_clear_value ( FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
Clearer * clearer = model_connector - > get_clearer ( ) ;
2018-07-04 13:34:49 +02:00
2019-09-18 16:36:13 +02:00
if ( clearer )
{
clearer - > clear_value ( field_value ) ;
}
}
2018-07-04 13:34:49 +02:00
2019-09-18 16:36:13 +02:00
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);
2021-06-16 14:01:07 +02:00
template < typename FieldValue >
void field_generic_put_raw_value_to_stream ( const wchar_t * db_field_name , const wchar_t * flat_field_name , FieldValue & field_value , const FT & field_type )
{
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 ) ) )
{
2021-06-19 20:25:38 +02:00
model_env - > was_field_found = true ;
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);
2021-06-16 14:01:07 +02:00
if ( model_env - > stream )
{
( * model_env - > stream ) < < field_value ;
}
2021-06-18 19:05:50 +02:00
# ifdef MORM_HAS_EZC_LIBRARY
model_env - > ezc_fun_result = convert_to_bool ( field_value ) ;
# endif
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);
2021-06-16 14:01:07 +02:00
}
}
2019-09-18 16:36:13 +02:00
template < typename FieldValue >
2021-05-12 04:53:23 +02:00
void field_generic ( const wchar_t * db_field_name , const wchar_t * flat_field_name , FieldValue & field_value , const FT & field_type )
2019-09-18 16:36:13 +02:00
{
if ( model_connector & & model_env )
{
2021-03-10 16:20:11 +01:00
if ( field_type . is_primary_key ( ) )
2021-03-09 18:10:34 +01:00
{
model_env - > was_primary_key_read = true ;
}
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_SET_FIELD_VALUE )
2018-07-04 13:34:49 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic_set_field_value ( db_field_name , flat_field_name , field_value ) ;
2019-09-18 16:36:13 +02:00
}
2018-07-04 13:34:49 +02:00
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_ITERATE_PRIMARY_KEY_VALUES )
2019-09-18 16:36:13 +02:00
{
2021-03-10 16:20:11 +01:00
field_generic_iterate_primary_key_values ( db_field_name , flat_field_name , field_value , field_type ) ;
2018-07-04 13:34:49 +02:00
}
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GENERATING_FLAT_STRING )
2018-07-04 13:34:49 +02:00
{
2021-05-31 18:40:28 +02:00
field_generic_generate_flat_string ( flat_field_name , field_value , field_type ) ;
2019-09-18 16:36:13 +02:00
}
2018-07-04 13:34:49 +02:00
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GENERATING_DB_SQL )
2019-09-18 16:36:13 +02:00
{
2021-06-01 19:34:34 +02:00
field_generic_generate_db_sql ( db_field_name , field_value , field_type ) ;
2018-07-04 13:34:49 +02:00
}
2018-07-16 00:36:04 +02:00
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_READING_VALUE_FROM_DB_RESULTSET )
2018-07-16 00:36:04 +02:00
{
2021-06-01 19:34:34 +02:00
field_generic_read_value_from_db_resultset ( db_field_name , field_value , field_type ) ;
2019-09-18 16:36:13 +02:00
}
2018-07-16 00:36:04 +02:00
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_CLEARING_VALUE )
2019-09-18 16:36:13 +02:00
{
2021-06-01 19:34:34 +02:00
field_generic_clear_value ( field_value , field_type ) ;
2019-09-18 16:36:13 +02:00
}
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);
2021-06-16 14:01:07 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM )
{
field_generic_put_raw_value_to_stream ( db_field_name , flat_field_name , field_value , field_type ) ;
}
2018-04-22 23:04:50 +02:00
}
}
2018-07-04 13:34:49 +02:00
2021-07-01 22:55:56 +02:00
void field_date ( const wchar_t * db_field_name , const wchar_t * flat_field_name , pt : : Date & field_value , const FT & field_type )
{
if ( model_connector & & model_env )
{
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
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 - > wrapper . date )
{
model_env - > wrapper . date = & field_value ;
}
}
else
{
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
}
}
}
2021-06-22 17:59:44 +02:00
void field_space ( const wchar_t * db_field_name , const wchar_t * flat_field_name , pt : : Space & field_value , const FT & field_type )
{
if ( model_connector & & model_env )
{
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
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 ) ) & &
2021-07-01 22:55:56 +02:00
! model_env - > wrapper . space_wrapper )
2021-06-22 17:59:44 +02:00
{
2021-07-01 22:55:56 +02:00
model_env - > wrapper . space_wrapper = new SpaceWrapper ( & field_value ) ;
2021-06-22 17:59:44 +02:00
}
}
else
{
field_generic ( db_field_name , flat_field_name , field_value , field_type ) ;
}
}
}
2021-06-01 19:34:34 +02:00
void field_member_set_field_value (
const wchar_t * db_field_name ,
const wchar_t * flat_field_name ,
void ( Model : : * setter_method ) ( const char * input_str ) ) ;
void field_member_generate_flat_string (
const wchar_t * flat_field_name ,
2021-06-20 17:49:54 +02:00
void ( Model : : * getter_method ) ( pt : : Stream & ) ,
2021-06-01 19:34:34 +02:00
const FT & field_type ) ;
void field_member_generate_db_sql (
const wchar_t * db_field_name ,
2021-06-20 17:49:54 +02:00
void ( Model : : * getter_method ) ( pt : : Stream & ) ,
2021-06-01 19:34:34 +02:00
const FT & field_type ) ;
void field_member_read_value_from_db_resultset (
const wchar_t * db_field_name ,
void ( Model : : * setter_method ) ( const char * input_str ) ,
const FT & field_type ) ;
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);
2021-06-16 14:01:07 +02:00
void field_member_put_field_raw_value_to_stream (
const wchar_t * db_field_name ,
const wchar_t * flat_field_name ,
2021-06-20 17:49:54 +02:00
void ( Model : : * getter_method ) ( pt : : Stream & ) ,
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);
2021-06-16 14:01:07 +02:00
const FT & field_type ) ;
2021-06-01 19:34:34 +02:00
void field_member_clear_value (
void ( Model : : * setter_method ) ( const char * input_str ) ,
const FT & field_type ) ;
void field_member (
const wchar_t * db_field_name ,
const wchar_t * flat_field_name ,
2021-06-20 17:49:54 +02:00
void ( Model : : * getter_method ) ( pt : : Stream & ) ,
2021-06-01 19:34:34 +02:00
void ( Model : : * setter_method ) ( const char * input_str ) ,
const FT & field_type ) ;
# ifdef MORM_HAS_EZC_LIBRARY
2021-05-31 18:40:28 +02:00
template < typename FunInfoStreamType >
2021-09-08 15:34:40 +02:00
void field_member_ezc ( const wchar_t * db_field_name , const wchar_t * flat_field_name , void ( Model : : * method ) ( Ezc : : Env < FunInfoStreamType > & ) , const FT & field_type )
2021-05-31 18:40:28 +02:00
{
2021-06-01 19:34:34 +02:00
if ( model_connector & & model_env & & model_env - > ezc_fun_info & & model_env - > ezc_fun_info_typeinfo & & model_env - > model )
2021-05-31 18:40:28 +02:00
{
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);
2021-06-16 14:01:07 +02:00
if ( field_type . is_primary_key ( ) )
{
pt : : Log * plog = model_connector - > get_logger ( ) ;
if ( plog )
{
2021-06-18 19:05:50 +02:00
( * plog ) < < pt : : Log : : log1 < < " Morm:: an ezc method cannot be used as a primary key " < < pt : : Log : : logend ;
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);
2021-06-16 14:01:07 +02:00
}
}
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_PUT_FIELD_RAW_VALUE_TO_STREAM )
2021-05-31 18:40:28 +02:00
{
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);
2021-06-16 14:01:07 +02:00
field_member_ezc_put_field_value_to_stream ( db_field_name , flat_field_name , method , field_type ) ;
2021-05-31 18:40:28 +02:00
}
}
}
2021-06-18 19:05:50 +02:00
2021-05-31 18:40:28 +02:00
template < typename FunInfoStreamType >
2021-10-20 08:29:38 +02:00
void field_member_ezc_put_field_value_to_stream ( const wchar_t * db_field_name , const wchar_t * flat_field_name ,
void ( Model : : * method ) ( Ezc : : Env < FunInfoStreamType > & ) , const FT & field_type )
2021-05-31 18:40:28 +02:00
{
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);
2021-06-16 14:01:07 +02:00
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 ) ) )
2021-05-31 18:40:28 +02:00
{
2021-06-19 20:25:38 +02:00
model_env - > was_field_found = true ;
2021-09-08 15:34:40 +02:00
if ( typeid ( Ezc : : Env < FunInfoStreamType > ) = = * model_env - > ezc_fun_info_typeinfo )
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);
2021-06-16 14:01:07 +02:00
{
2021-09-08 15:34:40 +02:00
Ezc : : Env < FunInfoStreamType > * ezc_fun_info = reinterpret_cast < Ezc : : Env < FunInfoStreamType > * > ( model_env - > ezc_fun_info ) ;
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);
2021-06-16 14:01:07 +02:00
( model_env - > model - > * method ) ( * ezc_fun_info ) ;
2021-06-18 19:05:50 +02:00
model_env - > ezc_fun_result = ezc_fun_info - > res ; // ezc_fun_info->res is overwritten in get_raw_value() after fields() method call so we have to remember it in model_env
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);
2021-06-16 14:01:07 +02:00
}
else
2021-05-31 18:40:28 +02:00
{
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);
2021-06-16 14:01:07 +02:00
pt : : Log * plog = model_connector - > get_logger ( ) ;
if ( plog )
{
( * plog ) < < pt : : Log : : log2 < < " Morm: incorrect method type for field: " < < flat_field_name < < pt : : Log : : logend ;
}
2021-05-31 18:40:28 +02:00
}
}
}
2021-06-18 19:05:50 +02:00
void field_member_ezc ( const wchar_t * db_field_name , const wchar_t * flat_field_name , bool ( Model : : * method ) ( ) , const FT & field_type )
{
if ( model_connector & & model_env & & model_env - > model )
{
if ( field_type . is_primary_key ( ) )
{
pt : : Log * plog = model_connector - > get_logger ( ) ;
if ( plog )
{
( * plog ) < < pt : : Log : : log1 < < " Morm:: an ezc method cannot be used as a primary key " < < pt : : Log : : logend ;
}
}
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_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 ) ) )
{
2021-06-19 20:25:38 +02:00
model_env - > was_field_found = true ;
2021-06-18 19:05:50 +02:00
model_env - > ezc_fun_result = ( model_env - > model - > * method ) ( ) ;
}
}
}
}
void field_member_ezc ( const wchar_t * db_field_name , const wchar_t * flat_field_name , bool ( Model : : * method ) ( ) const , const FT & field_type )
{
if ( model_connector & & model_env & & model_env - > model )
{
if ( field_type . is_primary_key ( ) )
{
pt : : Log * plog = model_connector - > get_logger ( ) ;
if ( plog )
{
( * plog ) < < pt : : Log : : log1 < < " Morm:: an ezc method cannot be used as a primary key " < < pt : : Log : : logend ;
}
}
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_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 ) ) )
{
2021-06-19 20:25:38 +02:00
model_env - > was_field_found = true ;
2021-06-18 19:05:50 +02:00
model_env - > ezc_fun_result = ( model_env - > model - > * method ) ( ) ;
}
}
}
}
2021-07-01 22:55:56 +02:00
void field_member_ezc ( const wchar_t * db_field_name , const wchar_t * flat_field_name , void ( Model : : * method ) ( Wrapper & wrapper ) , const FT & field_type )
2021-06-18 19:05:50 +02:00
{
if ( model_connector & & model_env & & model_env - > model )
{
if ( field_type . is_primary_key ( ) )
{
pt : : Log * plog = model_connector - > get_logger ( ) ;
if ( plog )
{
( * plog ) < < pt : : Log : : log1 < < " Morm:: an ezc method cannot be used as a primary key " < < pt : : Log : : logend ;
}
}
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
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 ) ) )
{
2021-07-01 22:55:56 +02:00
( model_env - > model - > * method ) ( model_env - > wrapper ) ;
2021-06-18 19:05:50 +02:00
}
}
}
}
2021-06-01 19:34:34 +02:00
# endif
2021-05-31 18:40:28 +02:00
2021-05-12 04:53:23 +02:00
void field_model_left_join ( const wchar_t * db_field_name , Model & field_model , const FT & field_type , DbExpression * db_expression ) ;
2021-05-12 00:27:35 +02:00
void field_model_save_key ( const wchar_t * db_field_name ) ;
void field_model_set_parent_key_in_child ( const wchar_t * db_field_name , Model & field_model ) ;
void field_model_set_parent_key ( const wchar_t * db_field_name , Model & field_model ) ;
2021-06-17 21:31:58 +02:00
void field_model_iterate_through_childs ( Model & field_model , const FT & field_type ) ;
2021-05-12 04:53:23 +02:00
void field_model_generate_flat_string ( const wchar_t * flat_field_name , Model & field_model , const FT & field_type ) ;
void field_model_generate_db_sql ( const wchar_t * db_field_name , Model & field_model , const FT & field_type ) ;
2021-05-12 00:27:35 +02:00
void field_model_clear_values ( Model & field_model ) ;
2021-05-12 04:53:23 +02:00
void field_model_read_values_from_queryresult ( const wchar_t * db_field_name , Model & field_model , const FT & field_type ) ;
void field_model ( const wchar_t * db_field_name , const wchar_t * flat_field_name , Model & field_model , const FT & field_type ) ;
2021-06-17 21:31:58 +02:00
void field_model ( const wchar_t * db_field_name , const wchar_t * flat_field_name , Model * field_model , const FT & field_type ) ;
2021-05-12 04:53:23 +02:00
void field_model_for_db ( const wchar_t * db_field_name , Model & field_model , const FT & field_type ) ;
2018-03-13 23:22:17 +01:00
2018-07-04 15:52:40 +02:00
2021-06-17 21:31:58 +02:00
template < typename ModelContainer , typename ModelContainerType , typename IsContainerByValueRenameMe >
void field_list_set_parent_key ( const wchar_t * db_field_name , ModelContainer & field_container , ModelContainerType * model_container_type , IsContainerByValueRenameMe * foo )
2019-09-24 19:08:45 +02:00
{
FieldValueHelper helper ;
helper . db_field_name = db_field_name ;
helper . flat_field_name = nullptr ;
helper . compare_flat_field_name = false ;
std : : vector < FieldValueHelper > helper_tab ;
helper_tab . push_back ( helper ) ;
// only one column at the moment, in the future we can have a primary key from more than one column
model_env - > field_value_helper_tab = & helper_tab ;
field_model_save_key ( db_field_name ) ;
2021-06-17 21:31:58 +02:00
if constexpr ( std : : is_base_of < Model , IsContainerByValueRenameMe > ( ) )
{
field_list_set_parent_key_by_value < ModelContainer , ModelContainerType > ( db_field_name , field_container ) ;
}
else
{
field_list_set_parent_key_by_pointer < ModelContainer , ModelContainerType > ( db_field_name , field_container ) ;
}
model_env - > field_value_helper_tab = nullptr ;
}
template < typename ModelContainer , typename ModelContainerType >
void field_list_set_parent_key_by_value ( const wchar_t * db_field_name , ModelContainer & field_container )
{
2019-09-24 19:08:45 +02:00
for ( ModelContainerType & child_model : field_container )
{
child_model . set_connector ( model_connector ) ;
field_model_set_parent_key_in_child ( db_field_name , child_model ) ;
}
2021-06-17 21:31:58 +02:00
}
2019-09-24 19:08:45 +02:00
2021-06-17 21:31:58 +02:00
template < typename ModelContainer , typename ModelContainerType >
void field_list_set_parent_key_by_pointer ( const wchar_t * db_field_name , ModelContainer & field_container )
{
for ( ModelContainerType * child_model : field_container )
{
child_model - > set_connector ( model_connector ) ;
field_model_set_parent_key_in_child ( db_field_name , * child_model ) ;
}
}
template < typename ModelContainer , typename ModelContainerType , typename IsContainerByValueRenameMe >
void field_list_iterate_through_childs ( ModelContainer & field_container , ModelContainerType * model_container_type , const FT & field_type , IsContainerByValueRenameMe * foo )
{
if constexpr ( std : : is_base_of < Model , IsContainerByValueRenameMe > ( ) )
{
field_list_iterate_through_childs_by_value ( field_container , model_container_type , field_type ) ;
}
else
{
field_list_iterate_through_childs_by_pointer ( field_container , model_container_type , field_type ) ;
}
2019-09-24 19:08:45 +02:00
}
2019-03-26 19:34:07 +01:00
template < typename ModelContainer , typename ModelContainerType >
2021-06-17 21:31:58 +02:00
void field_list_iterate_through_childs_by_value ( ModelContainer & field_container , ModelContainerType * model_container_type , const FT & field_type )
2018-04-26 20:58:31 +02:00
{
2021-03-10 16:20:11 +01:00
for ( ModelContainerType & child_model : field_container )
2018-04-26 20:58:31 +02:00
{
2021-06-17 21:31:58 +02:00
field_list_iterate_through_childs ( child_model , field_type ) ;
}
}
2018-07-04 13:34:49 +02:00
2021-06-17 21:31:58 +02:00
template < typename ModelContainer , typename ModelContainerType >
void field_list_iterate_through_childs_by_pointer ( ModelContainer & field_container , ModelContainerType * model_container_type , const FT & field_type )
{
for ( ModelContainerType * child_model : field_container )
{
field_list_iterate_through_childs ( * child_model , field_type ) ;
}
}
2019-09-24 13:09:11 +02:00
2018-07-04 13:34:49 +02:00
2021-06-17 21:31:58 +02:00
template < typename ModelContainerType >
void field_list_iterate_through_childs ( ModelContainerType & child_model , const FT & field_type )
{
ModelEnv model_env_local ;
model_env_local . copy_global_objects ( * model_env ) ;
model_env_local . model = & child_model ;
child_model . model_env = & model_env_local ;
child_model . model_env - > has_primary_key_set = child_model . has_primary_key_set ;
child_model . set_connector ( model_connector ) ;
child_model . table ( ) ;
field_model_iterate_through_childs ( child_model , field_type ) ;
child_model . model_env = nullptr ;
2019-09-24 13:09:11 +02:00
}
2021-06-17 21:31:58 +02:00
template < typename ModelContainer , typename ModelContainerType , typename IsContainerByValueRenameMe >
void field_list_generate_flat_string ( const wchar_t * flat_field_name , ModelContainer & field_container , ModelContainerType * model_container_type ,
const FT & field_type , IsContainerByValueRenameMe * foo )
2019-09-24 13:09:11 +02:00
{
FlatConnector * flat_connector = model_connector - > get_flat_connector ( ) ;
if ( flat_connector )
{
FlatExpression * flat_expression = flat_connector - > get_expression ( ) ;
2021-03-10 16:20:11 +01:00
if ( flat_expression )
2019-03-26 19:34:07 +01:00
{
2021-06-17 21:31:58 +02:00
flat_expression - > field_list ( flat_field_name , field_container , model_container_type , field_type , model_connector , model_env , foo ) ;
2019-09-24 13:09:11 +02:00
}
}
}
2019-03-26 19:34:07 +01:00
2021-06-17 21:31:58 +02:00
template < typename ModelContainer , typename ModelContainerType , typename IsContainerByValueRenameMe >
void field_list_clearing_values ( ModelContainer & field_container , ModelContainerType * model_container_type , IsContainerByValueRenameMe * foo )
2019-09-24 13:09:11 +02:00
{
Clearer * clearer = model_connector - > get_clearer ( ) ;
2019-08-20 17:49:37 +02:00
2019-09-24 13:09:11 +02:00
if ( clearer )
{
2021-06-17 21:31:58 +02:00
clearer - > clear_container ( field_container , model_container_type , foo ) ;
2019-09-24 13:09:11 +02:00
}
}
2021-06-16 22:23:30 +02:00
template < typename ContainerItemType >
void field_vector ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : vector < ContainerItemType > & field_value , const FT & field_type )
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);
2021-06-16 14:01:07 +02:00
{
2021-06-16 22:23:30 +02:00
ContainerItemType * item_type_null_pointer = nullptr ;
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);
2021-06-16 14:01:07 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
2021-06-16 22:23:30 +02:00
if constexpr ( std : : is_base_of < Model , ContainerItemType > ( ) )
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);
2021-06-16 14:01:07 +02:00
{
2021-06-16 22:23:30 +02:00
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 ) ) & &
2021-07-01 22:55:56 +02:00
! model_env - > wrapper . model_container_wrapper )
2021-06-16 22:23:30 +02:00
{
2021-07-01 22:55:56 +02:00
model_env - > wrapper . model_container_wrapper = new ModelWrapperVector ( & field_value ) ;
2021-06-16 22:23:30 +02:00
}
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);
2021-06-16 14:01:07 +02:00
}
}
else
{
2021-06-17 21:31:58 +02:00
ContainerItemType * pointer = nullptr ;
field_list_generic ( db_field_name , flat_field_name , field_value , item_type_null_pointer , field_type , pointer ) ;
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);
2021-06-16 14:01:07 +02:00
}
}
2021-06-16 22:23:30 +02:00
template < typename ContainerItemType >
void field_list ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : list < ContainerItemType > & field_value , const FT & field_type )
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);
2021-06-16 14:01:07 +02:00
{
2021-06-16 22:23:30 +02:00
ContainerItemType * item_type_null_pointer = nullptr ;
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);
2021-06-16 14:01:07 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
2021-06-16 22:23:30 +02:00
if constexpr ( std : : is_base_of < Model , ContainerItemType > ( ) )
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);
2021-06-16 14:01:07 +02:00
{
2021-06-16 22:23:30 +02:00
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 ) ) & &
2021-07-01 22:55:56 +02:00
! model_env - > wrapper . model_container_wrapper )
2021-06-16 22:23:30 +02:00
{
2021-07-01 22:55:56 +02:00
model_env - > wrapper . model_container_wrapper = new ModelWrapperList ( & field_value ) ;
2021-06-16 22:23:30 +02:00
}
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);
2021-06-16 14:01:07 +02:00
}
}
else
{
2021-06-17 21:31:58 +02:00
ContainerItemType * pointer = nullptr ;
field_list_generic ( db_field_name , flat_field_name , field_value , item_type_null_pointer , field_type , pointer ) ;
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);
2021-06-16 14:01:07 +02:00
}
}
2021-06-17 21:31:58 +02:00
template < typename ContainerItemType >
void field_vector ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : vector < ContainerItemType * > & field_value , const FT & field_type )
{
ContainerItemType * item_type_null_pointer = nullptr ;
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);
2021-06-16 14:01:07 +02:00
2021-06-17 21:31:58 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
if constexpr ( std : : is_base_of < Model , ContainerItemType > ( ) )
{
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 ) ) & &
2021-07-01 22:55:56 +02:00
! model_env - > wrapper . model_container_wrapper )
2021-06-17 21:31:58 +02:00
{
2021-07-01 22:55:56 +02:00
model_env - > wrapper . model_container_wrapper = new ModelWrapperVectorPointer ( & field_value ) ;
2021-06-17 21:31:58 +02:00
}
}
}
else
{
void * pointer = nullptr ;
field_list_generic ( db_field_name , flat_field_name , field_value , item_type_null_pointer , field_type , pointer ) ;
}
}
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);
2021-06-16 14:01:07 +02:00
2021-06-17 21:31:58 +02:00
template < typename ContainerItemType >
void field_list ( const wchar_t * db_field_name , const wchar_t * flat_field_name , std : : list < ContainerItemType * > & field_value , const FT & field_type )
{
ContainerItemType * item_type_null_pointer = nullptr ;
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GET_MODEL_WRAPPER )
{
if constexpr ( std : : is_base_of < Model , ContainerItemType > ( ) )
{
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 ) ) & &
2021-07-01 22:55:56 +02:00
! model_env - > wrapper . model_container_wrapper )
2021-06-17 21:31:58 +02:00
{
2021-07-01 22:55:56 +02:00
model_env - > wrapper . model_container_wrapper = new ModelWrapperListPointer ( & field_value ) ;
2021-06-17 21:31:58 +02:00
}
}
}
else
{
void * pointer = nullptr ;
field_list_generic ( db_field_name , flat_field_name , field_value , item_type_null_pointer , field_type , pointer ) ;
}
}
template < typename ModelContainer , typename ModelContainerType , typename IsContainerByValueRenameMe >
void field_list_generic ( const wchar_t * db_field_name , const wchar_t * flat_field_name , ModelContainer & field_container , ModelContainerType * model_container_type ,
const FT & field_type , IsContainerByValueRenameMe * foo )
2019-09-24 13:09:11 +02:00
{
if ( model_connector & & model_env )
{
2021-05-20 16:25:01 +02:00
pt : : Log * plog = model_connector - > get_logger ( ) ;
2021-03-10 16:20:11 +01:00
2019-09-25 18:20:37 +02:00
if ( ! is_empty_field ( db_field_name ) )
2019-09-24 19:08:45 +02:00
{
2021-03-10 16:20:11 +01:00
/*
* IMPROVEME
* field_type . is_foreign_key ( ) is not implemented for lists yet
* ( in such a case parent will point only to one object ( or none ) so the list will consists of only one object ( or none ) )
*/
if ( field_type . is_foreign_key ( ) )
2019-09-25 18:20:37 +02:00
{
2021-03-10 16:20:11 +01:00
if ( plog )
2019-09-25 18:20:37 +02:00
{
2021-05-20 16:25:01 +02:00
( * plog ) < < pt : : Log : : log1 < < " Morm: error: FT::is_foreign_key is not implemented for a list/vector yet " < < pt : : Log : : logend ;
2021-03-10 16:20:11 +01:00
return ;
2019-09-25 18:20:37 +02:00
}
2021-03-10 16:20:11 +01:00
}
2021-06-20 17:49:54 +02:00
if constexpr ( std : : is_base_of < Model , ModelContainerType > ( ) )
2021-03-10 16:20:11 +01:00
{
2021-06-20 17:49:54 +02:00
bool print_need_foreign_key_option = false ;
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_SET_PARENT_ID )
2021-03-10 16:20:11 +01:00
{
2021-06-20 17:49:54 +02:00
if ( field_type . is_foreign_key ( ) | | field_type . is_foreign_key_in_child ( ) )
2021-03-10 16:20:11 +01:00
{
2021-06-17 21:31:58 +02:00
field_list_set_parent_key ( db_field_name , field_container , model_container_type , foo ) ;
2021-03-10 16:20:11 +01:00
}
2021-06-20 17:49:54 +02:00
else
{
print_need_foreign_key_option = true ;
}
}
2019-09-24 19:08:45 +02:00
2021-06-20 17:49:54 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_ITERATE_THROUGH_CHILDS_WITHOUT_FOREIGN_KEY )
{
if ( field_type . is_foreign_key ( ) | | field_type . is_foreign_key_in_child ( ) )
2021-03-10 16:20:11 +01:00
{
2021-06-17 21:31:58 +02:00
// IMPROVEME it would be good to make some optimisation before going through all items
// such as: if UPDATE is called then we check if field_type allows to make update
field_list_iterate_through_childs ( field_container , model_container_type , field_type , foo ) ;
2021-03-10 16:20:11 +01:00
}
2021-06-20 17:49:54 +02:00
else
2021-03-10 16:20:11 +01:00
{
2021-06-20 17:49:54 +02:00
print_need_foreign_key_option = true ;
2021-03-10 16:20:11 +01:00
}
2019-09-25 18:20:37 +02:00
}
2021-06-20 17:49:54 +02:00
if ( print_need_foreign_key_option & & plog )
{
( * plog ) < < pt : : Log : : log1 < < " Morm: error in " ;
log_table_name_with_field ( db_field_name ) ;
( * plog ) < < " field, you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag for a list of child objects " < < pt : : Log : : logend ;
}
2019-09-25 18:20:37 +02:00
}
else
{
if ( plog )
{
2021-06-20 17:49:54 +02:00
( * plog ) < < pt : : Log : : log1 < < " Morm: ignoring " ;
2021-05-13 02:32:03 +02:00
log_table_name_with_field ( db_field_name ) ;
2021-06-20 17:49:54 +02:00
( * plog ) < < " as this is not a container with Model objects " < < pt : : Log : : logend ;
2019-09-25 18:20:37 +02:00
}
}
2019-03-26 19:34:07 +01:00
}
2021-03-10 16:20:11 +01:00
if ( ! is_empty_field ( flat_field_name ) )
2019-09-24 13:09:11 +02:00
{
2021-03-10 16:20:11 +01:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GENERATING_FLAT_STRING )
{
2021-06-17 21:31:58 +02:00
field_list_generate_flat_string ( flat_field_name , field_container , model_container_type , field_type , foo ) ;
2021-03-10 16:20:11 +01:00
}
2019-09-24 13:09:11 +02:00
}
2019-03-26 19:34:07 +01:00
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_CLEARING_VALUE )
2018-07-04 13:34:49 +02:00
{
2021-06-17 21:31:58 +02:00
field_list_clearing_values ( field_container , model_container_type , foo ) ;
2018-07-04 13:34:49 +02:00
}
2018-07-16 00:36:04 +02:00
}
}
2018-11-14 18:14:26 +01:00
2019-05-13 05:12:31 +02:00
template < typename FieldValue >
2021-05-12 04:53:23 +02:00
void get_value_by_field_index ( int field_index , FieldValue & field_value , const FT & field_type )
2019-05-13 05:12:31 +02:00
{
2019-09-18 14:29:20 +02:00
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
2019-05-13 05:12:31 +02:00
2019-09-18 14:29:20 +02:00
if ( db_connector & & model_env - > cursor_helper & & model_env - > cursor_helper - > query_result )
{
if ( ! model_env - > cursor_helper - > query_result - > is_null ( field_index ) )
2019-05-13 05:12:31 +02:00
{
2019-09-18 14:29:20 +02:00
const char * val_str = model_env - > cursor_helper - > query_result - > get_field_string_value ( field_index ) ;
2019-05-13 05:12:31 +02:00
2019-09-18 14:29:20 +02:00
if ( val_str )
2019-05-13 05:12:31 +02:00
{
2021-05-11 22:11:31 +02:00
db_connector - > get_value ( val_str , field_value , field_type ) ;
2019-05-13 05:12:31 +02:00
}
}
2021-03-09 18:10:34 +01:00
else
{
2021-03-10 16:20:11 +01:00
if ( field_type . is_primary_key ( ) )
2021-03-09 18:10:34 +01:00
{
model_env - > has_primary_key_set = false ;
}
}
2019-05-13 05:12:31 +02:00
}
}
2018-11-14 18:14:26 +01:00
template < typename FieldValue >
2021-05-12 04:53:23 +02:00
void get_value_by_field_name ( const wchar_t * field_name , FieldValue & field_value , const FT & field_type )
2018-11-14 18:14:26 +01:00
{
2019-09-17 19:55:39 +02:00
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
if ( db_connector & & model_env - > cursor_helper & & model_env - > cursor_helper - > query_result )
2018-11-14 18:14:26 +01:00
{
2019-09-18 14:29:20 +02:00
int column_index = - 1 ;
2019-09-13 20:17:02 +02:00
2019-09-17 19:55:39 +02:00
if ( model_env - > cursor_helper - > use_table_prefix_for_fetching_values & & model_env - > finder_helper )
{
2021-05-12 00:27:35 +02:00
DbExpression * db_expression = db_connector - > get_expression ( ) ;
2019-09-13 20:17:02 +02:00
2021-05-12 00:27:35 +02:00
if ( db_expression )
{
std : : wstring table_field_name ;
2021-05-20 16:25:01 +02:00
pt : : TextStream table_field_name_str ;
2019-09-13 20:17:02 +02:00
2021-05-12 00:27:35 +02:00
// CHECK ME not tested yet after changing to db_expression->table_with_index_and_field_to_stream()
db_expression - > table_with_index_and_field_to_stream ( table_field_name_str , model_env - > table_name , model_env - > table_index , field_name , field_type ) ;
2021-06-20 17:49:54 +02:00
table_field_name_str . to_str ( table_field_name ) ;
2021-05-12 00:27:35 +02:00
column_index = model_env - > cursor_helper - > query_result - > get_column_index ( table_field_name . c_str ( ) ) ;
}
2019-09-17 19:55:39 +02:00
}
else
{
2019-09-18 14:29:20 +02:00
column_index = model_env - > cursor_helper - > query_result - > get_column_index ( field_name ) ;
2019-09-17 19:55:39 +02:00
}
2019-09-18 14:29:20 +02:00
if ( column_index ! = - 1 & & ! model_env - > cursor_helper - > query_result - > is_null ( column_index ) )
2019-09-17 19:55:39 +02:00
{
2019-09-18 14:29:20 +02:00
const char * val_str = model_env - > cursor_helper - > query_result - > get_field_string_value ( column_index ) ;
if ( val_str )
{
2021-05-11 22:11:31 +02:00
db_connector - > get_value ( val_str , field_value , field_type ) ;
2019-09-18 14:29:20 +02:00
}
2018-11-14 18:14:26 +01:00
}
2021-03-09 18:10:34 +01:00
else
{
2021-03-10 16:20:11 +01:00
if ( field_type . is_primary_key ( ) )
2021-03-09 18:10:34 +01:00
{
model_env - > has_primary_key_set = false ;
}
}
2018-11-14 18:14:26 +01:00
}
}
2021-05-12 00:27:35 +02:00
virtual void set_parent_key_in_childs ( ) ;
2019-08-22 20:33:35 +02:00
2018-07-04 13:34:49 +02:00
public :
2018-04-26 20:58:31 +02:00
2018-04-17 00:46:25 +02:00
template < typename FieldValue >
2021-03-09 18:10:34 +01:00
bool get_last_sequence ( const wchar_t * sequence_table_name , FieldValue & field_value )
2018-04-17 00:46:25 +02:00
{
if ( model_connector )
{
2018-07-04 13:34:49 +02:00
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
if ( db_connector & & ! is_empty_field ( sequence_table_name ) )
{
2021-03-09 18:10:34 +01:00
return db_connector - > get_last_sequence ( sequence_table_name , field_value ) ;
2018-07-04 13:34:49 +02:00
}
2018-04-17 00:46:25 +02:00
}
2021-03-09 18:10:34 +01:00
return false ;
}
template < typename FieldValue >
bool get_last_sequence_for_primary_key ( const wchar_t * sequence_table_name , FieldValue & field_value )
{
has_primary_key_set = get_last_sequence ( sequence_table_name , field_value ) ;
return has_primary_key_set ;
2018-04-17 00:46:25 +02:00
}
2018-04-22 23:04:50 +02:00
template < typename FieldValue >
void add_field_for_select ( const wchar_t * new_column_expression , const wchar_t * new_column_name , const wchar_t * flat_field_name , FieldValue & field_value )
{
2021-04-12 18:53:55 +02:00
FT field_type = FT : : no_insertable | FT : : no_updatable | FT : : raw_field_name ;
2019-09-18 17:28:06 +02:00
if ( model_connector & & model_env )
2018-04-22 23:04:50 +02:00
{
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GENERATING_DB_SQL )
2018-04-22 23:04:50 +02:00
{
2018-07-04 13:34:49 +02:00
DbConnector * db_connector = model_connector - > get_db_connector ( ) ;
if ( db_connector )
{
DbExpression * db_expression = db_connector - > get_expression ( ) ;
if ( db_expression & & ! is_empty_field ( new_column_expression ) )
{
2021-04-12 18:53:55 +02:00
db_expression - > add_field_for_select ( new_column_expression , new_column_name , field_value , field_type , model_env ) ;
2018-07-04 13:34:49 +02:00
}
}
2018-04-22 23:04:50 +02:00
}
else
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_GENERATING_FLAT_STRING )
2018-04-22 23:04:50 +02:00
{
2021-04-12 18:53:55 +02:00
field_generic ( L " " , flat_field_name , field_value , field_type ) ;
2018-04-22 23:04:50 +02:00
}
else
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_READING_VALUE_FROM_DB_RESULTSET )
2018-04-22 23:04:50 +02:00
{
2021-04-12 18:53:55 +02:00
field_generic ( new_column_name , L " " , field_value , field_type ) ;
2018-04-22 23:04:50 +02:00
}
else
2019-09-18 17:28:06 +02:00
if ( model_env - > model_work_mode = = MORM_MODEL_WORK_MODE_CLEARING_VALUE )
2018-04-22 23:04:50 +02:00
{
2021-04-12 18:53:55 +02:00
field_generic ( L " " , L " " , field_value , field_type ) ; // the names don't matter here
2018-04-22 23:04:50 +02:00
}
}
}
2019-09-25 18:20:37 +02:00
// RENAME ME to something like select_field() or field_select()
2018-04-22 23:04:50 +02:00
template < typename FieldValue >
void add_field_for_select ( const wchar_t * new_column_expression , const wchar_t * new_column_name , FieldValue & field_value )
{
add_field_for_select ( new_column_expression , new_column_name , new_column_name , field_value ) ;
}
2018-03-13 23:22:17 +01:00
2018-04-22 23:04:50 +02:00
2018-07-04 13:34:49 +02:00
protected :
virtual bool is_empty_field ( const wchar_t * value ) ;
2019-08-22 20:33:35 +02:00
virtual bool is_the_same_field ( const wchar_t * field1 , const wchar_t * field2 ) ;
2021-03-11 12:22:37 +01:00
2021-03-09 18:10:34 +01:00
virtual void put_to_log ( const wchar_t * str ) ;
2021-05-20 16:25:01 +02:00
virtual void put_fields_to_log ( pt : : Log & log , const wchar_t * db_field_name , const wchar_t * flat_field_name ) ;
2019-09-24 19:08:45 +02:00
2021-05-13 02:32:03 +02:00
virtual void log_table_name ( bool put_schema_name = true ) ;
virtual void log_table_name_with_field ( const wchar_t * db_field_name = nullptr , bool put_schema_name = true ) ;
2021-03-10 16:20:11 +01:00
2021-05-14 03:24:53 +02:00
template < typename ModelObject >
bool do_migration ( int & current_table_version , int destination_table_version , ModelObject * model_object , bool ( ModelObject : : * migration_function ) ( ) )
{
bool status = true ;
if ( current_table_version < destination_table_version )
{
if ( ( model_object - > * migration_function ) ( ) )
{
current_table_version = destination_table_version ;
}
else
{
status = false ;
}
}
return status ;
}
2021-06-18 19:05:50 +02:00
// those methods are used when converting fields to bool for Ezc library
virtual bool convert_to_bool ( char v ) ;
virtual bool convert_to_bool ( unsigned char v ) ;
virtual bool convert_to_bool ( wchar_t v ) ;
virtual bool convert_to_bool ( const std : : wstring & str ) ;
virtual bool convert_to_bool ( const wchar_t * str ) ;
virtual bool convert_to_bool ( const std : : string & str ) ;
virtual bool convert_to_bool ( const char * str ) ;
virtual bool convert_to_bool ( bool v ) ;
virtual bool convert_to_bool ( short v ) ;
virtual bool convert_to_bool ( unsigned short v ) ;
virtual bool convert_to_bool ( int v ) ;
virtual bool convert_to_bool ( unsigned int v ) ;
virtual bool convert_to_bool ( long v ) ;
virtual bool convert_to_bool ( unsigned long v ) ;
virtual bool convert_to_bool ( long long v ) ;
virtual bool convert_to_bool ( unsigned long long v ) ;
virtual bool convert_to_bool ( float v ) ;
virtual bool convert_to_bool ( double v ) ;
virtual bool convert_to_bool ( long double v ) ;
virtual bool convert_to_bool ( const pt : : Date & date ) ;
virtual bool convert_to_bool ( const pt : : TextStream & val ) ;
virtual bool convert_to_bool ( const pt : : WTextStream & val ) ;
virtual bool convert_to_bool ( const pt : : Space & space ) ;
2021-05-14 03:24:53 +02:00
2019-05-13 19:59:28 +02:00
template < typename ModelClass > friend class Finder ;
2018-11-14 18:14:26 +01:00
template < typename ModelClass > friend class Cursor ;
2018-07-03 18:55:06 +02:00
friend class BaseExpression ;
2021-03-11 12:22:37 +01:00
friend class DbConnector ;
2021-05-31 18:40:28 +02:00
friend class FlatConnector ;
2018-07-03 18:55:06 +02:00
2018-03-13 23:22:17 +01:00
} ;
2021-03-11 18:40:32 +01:00
2018-03-13 23:22:17 +01:00
} // namespace
# endif