changed the way how we get a specific field value - now we do not use expressions (BaseExpression), to get the raw value we don't need an expression object:
- removed MORM_WORK_MODE_GET_SPECIFIC_FIELD_VALUE from expression work mode - removed: void BaseExpression::field(const wchar_t * field_name, void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env) - removed from BaseExpression: template<typename FunInfoStreamType> void field(const wchar_t * field_name, void (Model::*fun)(Ezc::FunInfo<FunInfoStreamType> &), const FT & field_type, ModelEnv * model_env) - removed: void FlatConnector::to_text(const wchar_t * flat_field_name, pt::TextStream & stream, Model & model) - renamed/changed: Model::put_field_value(...) -> Model::get_raw_value() added classes: class ModelWrapper - base wrapper class for a model or a model container class ModelWrapperModel : public ModelWrapper - wrapper for a model template<typename VectorType> class ModelWrapperVector : public ModelWrapper - wrapper for vector of models template<typename ListType> class ModelWrapperList : public ModelWrapper - wrapper for list of models ModelWrapper... classes are used by ezc library for iterating through child models and for iterating in [for...] statements added to Model: Model * get_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool put_log_if_not_found = true); ModelWrapper * get_model_wrapper(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool put_log_if_not_found = true);
This commit is contained in:
@@ -206,73 +206,6 @@ void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::field(const wchar_t * field_name, void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( out_stream && can_field_be_generated(field_type) )
|
||||
{
|
||||
field_before();
|
||||
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
||||
{
|
||||
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
|
||||
{
|
||||
put_field_value(getter_method, field_type, model_env);
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
||||
{
|
||||
if( model_env && model_env->set_field_name_helper )
|
||||
{
|
||||
if( (size_t)model_env->field_index < model_env->set_field_name_helper->size() )
|
||||
{
|
||||
put_field_name_and_table_if_needed((*model_env->set_field_name_helper)[model_env->field_index], field_type, model_env);
|
||||
put_name_value_separator();
|
||||
put_field_value(getter_method, field_type, model_env);
|
||||
}
|
||||
|
||||
model_env->field_index += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||
put_name_value_separator();
|
||||
put_field_value(getter_method, field_type, model_env);
|
||||
}
|
||||
}
|
||||
else
|
||||
if( work_mode == MORM_WORK_MODE_GET_SPECIFIC_FIELD_VALUE )
|
||||
{
|
||||
if( model_env && model_env->flat_field_name && pt::is_equal(model_env->flat_field_name, field_name) )
|
||||
{
|
||||
put_field_value(getter_method, field_type, model_env);
|
||||
}
|
||||
}
|
||||
|
||||
field_after();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_field_value(void (Model::*getter_method)(pt::TextStream &), const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
if( model_env && model_env->model && out_stream )
|
||||
{
|
||||
// IMPROVEME
|
||||
// if field_type is something like raw_value then don't call before_field_value_string() and after...()
|
||||
// and don't do escaping
|
||||
|
||||
before_field_value_string(field_type);
|
||||
|
||||
// FIXME add escaping, we need to create a tmp buffer pt::TextStream and this buffer put to getter_method
|
||||
(model_env->model->*getter_method)(*out_stream);
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BaseExpression::save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||
{
|
||||
@@ -592,14 +525,13 @@ void BaseExpression::esc(unsigned long val, pt::TextStream & stream, const FT &
|
||||
|
||||
void BaseExpression::esc(long long val, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
// not implemented in pt::TextStream yet
|
||||
//stream << val;
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(unsigned long long val, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
//stream << val;
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
@@ -617,8 +549,7 @@ void BaseExpression::esc(double val, pt::TextStream & stream, const FT & field_t
|
||||
|
||||
void BaseExpression::esc(long double val, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
// IMPLEMENT ME in pt::TextStream
|
||||
//stream << val;
|
||||
stream << val;
|
||||
}
|
||||
|
||||
|
||||
@@ -627,6 +558,7 @@ void BaseExpression::esc(const pt::Date & date, pt::TextStream & stream, const F
|
||||
stream << date;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const pt::TextStream & val, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
pt::TextStream::const_iterator i = val.begin();
|
||||
@@ -637,6 +569,7 @@ void BaseExpression::esc(const pt::TextStream & val, pt::TextStream & stream, co
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const pt::WTextStream & val, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
pt::WTextStream::const_iterator i = val.begin();
|
||||
@@ -647,6 +580,7 @@ void BaseExpression::esc(const pt::WTextStream & val, pt::TextStream & stream, c
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type)
|
||||
{
|
||||
pt::WTextStream tmp_stream;
|
||||
|
Reference in New Issue
Block a user