winix_fullmorm #4
|
@ -169,44 +169,20 @@ void BaseExpression::field_after()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BaseExpression::is_long_field_name(const wchar_t * field_name)
|
|
||||||
|
void BaseExpression::put_field_name_and_table_if_needed(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||||
{
|
{
|
||||||
bool is_long = false;
|
if( use_prefix && model_env )
|
||||||
|
|
||||||
while( *field_name != 0 )
|
|
||||||
{
|
{
|
||||||
if( *field_name == '.' )
|
put_table_with_index_and_field(model_env->table_name, model_env->table_index, field_name, field_type);
|
||||||
{
|
}
|
||||||
is_long = true;
|
else
|
||||||
break;
|
{
|
||||||
}
|
put_field_name(field_name, field_type, model_env);
|
||||||
|
|
||||||
field_name += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_long;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BaseExpression::is_long_field_name(const PT::TextStream & field_name)
|
|
||||||
{
|
|
||||||
PT::TextStream::const_iterator i = field_name.begin();
|
|
||||||
bool is_long = false;
|
|
||||||
|
|
||||||
while( i != field_name.end() )
|
|
||||||
{
|
|
||||||
if( *i == '.' )
|
|
||||||
{
|
|
||||||
is_long = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return is_long;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||||
{
|
{
|
||||||
|
@ -216,73 +192,15 @@ void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( is_long_field_name(field_name) )
|
// !!!!!!!!!!!!!!!!!!!
|
||||||
put_long_field_name(field_name);
|
// there are too many methods: before... after...
|
||||||
else
|
|
||||||
put_short_field_name(field_name, model_env);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const wchar_t * BaseExpression::put_long_part_field_name(const wchar_t * field_name)
|
|
||||||
{
|
|
||||||
while( *field_name != 0 && *field_name != '.' )
|
|
||||||
{
|
|
||||||
esc(*field_name, *out_stream);
|
|
||||||
field_name += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return field_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_long_field_name(const wchar_t * field_name)
|
|
||||||
{
|
|
||||||
before_first_part_long_field_name();
|
|
||||||
field_name = put_long_part_field_name(field_name);
|
|
||||||
after_first_part_long_field_name();
|
|
||||||
|
|
||||||
if( *field_name == '.' )
|
|
||||||
{
|
|
||||||
field_name += 1;
|
|
||||||
(*out_stream) << '.';
|
|
||||||
|
|
||||||
before_second_part_long_field_name();
|
|
||||||
field_name = put_long_part_field_name(field_name);
|
|
||||||
after_second_part_long_field_name();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::put_short_field_name(const wchar_t * field_name, ModelEnv * model_env)
|
|
||||||
{
|
|
||||||
if( use_prefix && model_env )
|
|
||||||
{
|
|
||||||
before_first_part_long_field_name();
|
|
||||||
esc(model_env->table_name, *out_stream);
|
|
||||||
|
|
||||||
if( model_env->table_index > 1 )
|
|
||||||
{
|
|
||||||
(*out_stream) << model_env->table_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
after_first_part_long_field_name();
|
|
||||||
|
|
||||||
(*out_stream) << '.';
|
|
||||||
|
|
||||||
before_second_part_long_field_name();
|
|
||||||
esc(field_name, *out_stream);
|
|
||||||
after_second_part_long_field_name();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
before_short_field_name();
|
before_short_field_name();
|
||||||
esc(field_name, *out_stream);
|
esc(field_name, *out_stream);
|
||||||
after_short_field_name();
|
after_short_field_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
void BaseExpression::save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env)
|
||||||
{
|
{
|
||||||
PT::TextStream str;
|
PT::TextStream str;
|
||||||
|
@ -886,6 +804,26 @@ void BaseExpression::put_table_with_index_and_field(const PT::WTextStream & tabl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BaseExpression::put_table_and_field(const wchar_t * table_name, const wchar_t * field_name, const FT & field_type)
|
||||||
|
{
|
||||||
|
if( out_stream )
|
||||||
|
{
|
||||||
|
put_table(table_name);
|
||||||
|
(*out_stream) << '.';
|
||||||
|
put_field_name(field_name, field_type, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseExpression::put_table_and_field(const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type)
|
||||||
|
{
|
||||||
|
if( out_stream )
|
||||||
|
{
|
||||||
|
put_table(table_name);
|
||||||
|
(*out_stream) << '.';
|
||||||
|
put_field_name(field_name, field_type, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name)
|
void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name)
|
||||||
|
@ -952,6 +890,22 @@ void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & strea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type)
|
||||||
|
{
|
||||||
|
this->out_stream = &stream;
|
||||||
|
put_table_and_field(table_name, field_name, field_type);
|
||||||
|
this->out_stream = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type)
|
||||||
|
{
|
||||||
|
this->out_stream = &stream;
|
||||||
|
put_table_and_field(table_name, field_name, field_type);
|
||||||
|
this->out_stream = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
||||||
{
|
{
|
||||||
put_field_name(field_name, field_type, model_env);
|
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_SAVE_FIELDS )
|
if( work_mode == MORM_WORK_MODE_MODEL_SAVE_FIELDS )
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
{
|
{
|
||||||
if( (size_t)model_env->field_index < model_env->set_field_name_helper->size() )
|
if( (size_t)model_env->field_index < model_env->set_field_name_helper->size() )
|
||||||
{
|
{
|
||||||
put_field_name((*model_env->set_field_name_helper)[model_env->field_index], field_type, model_env);
|
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_name_value_separator();
|
||||||
put_field_value_or_null(field_value, field_type, model_env);
|
put_field_value_or_null(field_value, field_type, model_env);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
put_field_name(field_name, field_type, model_env);
|
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||||
put_name_value_separator();
|
put_name_value_separator();
|
||||||
put_field_value_or_null(field_value, field_type, model_env);
|
put_field_value_or_null(field_value, field_type, model_env);
|
||||||
}
|
}
|
||||||
|
@ -172,12 +172,12 @@ public:
|
||||||
|
|
||||||
// if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
// if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
||||||
// {
|
// {
|
||||||
// put_field_name(field_name);
|
// put_field_name_and_table_if_needed(field_name);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
||||||
{
|
{
|
||||||
put_field_name(field_name, field_type, model_env);
|
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||||
put_name_value_separator();
|
put_name_value_separator();
|
||||||
put_field_value_list(field_value, model_connector, model_env);
|
put_field_value_list(field_value, model_connector, model_env);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public:
|
||||||
|
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS )
|
||||||
{
|
{
|
||||||
put_field_name(field_name, field_type, model_env);
|
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
|
if( work_mode == MORM_WORK_MODE_MODEL_VALUES )
|
||||||
|
@ -205,7 +205,7 @@ public:
|
||||||
else
|
else
|
||||||
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
if( work_mode == MORM_WORK_MODE_MODEL_FIELDS_VALUES )
|
||||||
{
|
{
|
||||||
put_field_name(field_name, field_type, model_env);
|
put_field_name_and_table_if_needed(field_name, field_type, model_env);
|
||||||
put_name_value_separator();
|
put_name_value_separator();
|
||||||
generate_from_model(field_model);
|
generate_from_model(field_model);
|
||||||
}
|
}
|
||||||
|
@ -231,6 +231,8 @@ public:
|
||||||
virtual void put_table_with_index(const PT::WTextStream & table_name, int index);
|
virtual void put_table_with_index(const PT::WTextStream & table_name, int index);
|
||||||
virtual void put_table_with_index_and_field(const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type);
|
virtual void put_table_with_index_and_field(const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type);
|
||||||
virtual void put_table_with_index_and_field(const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type);
|
virtual void put_table_with_index_and_field(const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type);
|
||||||
|
virtual void put_table_and_field(const wchar_t * table_name, const wchar_t * field_name, const FT & field_type);
|
||||||
|
virtual void put_table_and_field(const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type);
|
||||||
|
|
||||||
virtual void schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name);
|
virtual void schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name);
|
||||||
virtual void schema_table_to_stream(PT::TextStream & stream, const PT::WTextStream & schema_name, const PT::WTextStream & table_name);
|
virtual void schema_table_to_stream(PT::TextStream & stream, const PT::WTextStream & schema_name, const PT::WTextStream & table_name);
|
||||||
|
@ -240,6 +242,8 @@ public:
|
||||||
virtual void table_with_index_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index);
|
virtual void table_with_index_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index);
|
||||||
virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type);
|
virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type);
|
||||||
virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type);
|
virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type);
|
||||||
|
virtual void table_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type);
|
||||||
|
virtual void table_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -277,8 +281,6 @@ public:
|
||||||
virtual void esc(const PT::WTextStream & val,PT::TextStream & stream, const FT & field_type = FT::default_type);
|
virtual void esc(const PT::WTextStream & val,PT::TextStream & stream, const FT & field_type = FT::default_type);
|
||||||
virtual void esc(const PT::Space & space, PT::TextStream & stream, const FT & field_type = FT::default_type);
|
virtual void esc(const PT::Space & space, PT::TextStream & stream, const FT & field_type = FT::default_type);
|
||||||
|
|
||||||
virtual bool is_long_field_name(const wchar_t * field_name);
|
|
||||||
virtual bool is_long_field_name(const PT::TextStream & table_name);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -298,6 +300,7 @@ protected:
|
||||||
virtual void field_before();
|
virtual void field_before();
|
||||||
virtual void field_after();
|
virtual void field_after();
|
||||||
|
|
||||||
|
virtual void put_field_name_and_table_if_needed(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env);
|
||||||
virtual void put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env);
|
virtual void put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env);
|
||||||
|
|
||||||
virtual void save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env);
|
virtual void save_foreign_key(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env);
|
||||||
|
@ -588,7 +591,7 @@ protected:
|
||||||
this->out_stream = &stream;
|
this->out_stream = &stream;
|
||||||
|
|
||||||
field_before();
|
field_before();
|
||||||
put_field_name(field_name, FT::default_type, model_env);
|
put_field_name_and_table_if_needed(field_name, FT::default_type, model_env);
|
||||||
put_name_value_separator();
|
put_name_value_separator();
|
||||||
|
|
||||||
bool is_first = true;
|
bool is_first = true;
|
||||||
|
@ -628,10 +631,6 @@ protected:
|
||||||
virtual void before_second_part_long_field_name();
|
virtual void before_second_part_long_field_name();
|
||||||
virtual void after_second_part_long_field_name();
|
virtual void after_second_part_long_field_name();
|
||||||
|
|
||||||
virtual const wchar_t * put_long_part_field_name(const wchar_t * field_name);
|
|
||||||
virtual void put_long_field_name(const wchar_t * field_name);
|
|
||||||
virtual void put_short_field_name(const wchar_t * field_name, ModelEnv * model_env);
|
|
||||||
|
|
||||||
virtual void before_field_value(const std::wstring &, const FT & field_type);
|
virtual void before_field_value(const std::wstring &, const FT & field_type);
|
||||||
virtual void after_field_value(const std::wstring &, const FT & field_type);
|
virtual void after_field_value(const std::wstring &, const FT & field_type);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue