add Finder::esc_like(...) methods

This commit is contained in:
Tomasz Sowa 2023-10-10 19:43:02 +02:00
parent 8200092524
commit 92d9d2c01b
Signed by: tomasz.sowa
GPG Key ID: 662CC1438638588B
3 changed files with 114 additions and 36 deletions

View File

@ -1051,39 +1051,39 @@ void BaseExpression::put_alias(const pt::WTextStream & alias_name_prefix, int in
void BaseExpression::put_string(const char * str, const FT & field_type, bool add_quotes)
void BaseExpression::put_string(const char * str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
void BaseExpression::put_string(const wchar_t * str, const FT & field_type, bool add_quotes)
void BaseExpression::put_string(const wchar_t * str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
void BaseExpression::put_string(const std::string & str, const FT & field_type, bool add_quotes)
void BaseExpression::put_string(const std::string & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
void BaseExpression::put_string(const std::wstring & str, const FT & field_type, bool add_quotes)
void BaseExpression::put_string(const std::wstring & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
void BaseExpression::put_stream(const pt::TextStream & str, const FT & field_type, bool add_quotes)
void BaseExpression::put_stream(const pt::TextStream & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
void BaseExpression::put_stream(const pt::WTextStream & str, const FT & field_type, bool add_quotes)
void BaseExpression::put_stream(const pt::WTextStream & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
put_string_generic(str, field_type, add_quotes);
put_string_generic(str, field_type, add_quotes, model_env);
}
@ -1186,50 +1186,50 @@ void BaseExpression::alias_to_stream(pt::TextStream & stream, const pt::WTextStr
void BaseExpression::string_to_stream(pt::TextStream & stream, const char * str, const FT & field_type, bool add_quotes)
void BaseExpression::string_to_stream(pt::TextStream & stream, const char * str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream;
put_string(str, field_type, add_quotes);
put_string(str, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}
void BaseExpression::string_to_stream(pt::TextStream & stream, const wchar_t * str, const FT & field_type, bool add_quotes)
void BaseExpression::string_to_stream(pt::TextStream & stream, const wchar_t * str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream;
put_string(str, field_type, add_quotes);
put_string(str, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::string & str, const FT & field_type, bool add_quotes)
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::string & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream;
put_string(str, field_type, add_quotes);
put_string(str, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::wstring & str, const FT & field_type, bool add_quotes)
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::wstring & str, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream;
put_string(str, field_type, add_quotes);
put_string(str, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}
void BaseExpression::stream_to_stream(pt::TextStream & stream_out, const pt::TextStream & stream_in, const FT & field_type, bool add_quotes)
void BaseExpression::stream_to_stream(pt::TextStream & stream_out, const pt::TextStream & stream_in, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream_out;
put_stream(stream_in, field_type, add_quotes);
put_stream(stream_in, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}
void BaseExpression::stream_to_stream(pt::TextStream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes)
void BaseExpression::stream_to_stream(pt::TextStream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes, ModelEnv * model_env)
{
this->out_stream = &stream_out;
put_stream(stream_in, field_type, add_quotes);
put_stream(stream_in, field_type, add_quotes, model_env);
this->out_stream = nullptr;
}

View File

@ -253,12 +253,12 @@ public:
virtual void put_alias(const pt::WTextStream & alias_name, int index);
virtual void put_alias(const pt::WTextStream & alias_name_prefix, int index, const wchar_t * alias_name_postfix);
virtual void put_string(const char * str, const FT & field_type, bool add_quotes = false);
virtual void put_string(const wchar_t * str, const FT & field_type, bool add_quotes = false);
virtual void put_string(const std::string & str, const FT & field_type, bool add_quotes = false);
virtual void put_string(const std::wstring & str, const FT & field_type, bool add_quotes = false);
virtual void put_stream(const pt::TextStream & str, const FT & field_type, bool add_quotes = false);
virtual void put_stream(const pt::WTextStream & str, const FT & field_type, bool add_quotes = false);
virtual void put_string(const char * str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void put_string(const wchar_t * str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void put_string(const std::string & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void put_string(const std::wstring & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void put_stream(const pt::TextStream & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void put_stream(const pt::WTextStream & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
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);
@ -273,12 +273,12 @@ public:
virtual void alias_to_stream(pt::TextStream & stream, const pt::WTextStream & alias_name, int index);
virtual void alias_to_stream(pt::TextStream & stream, const pt::WTextStream & alias_name_prefix, int index, const wchar_t * alias_name_postfix);
virtual void string_to_stream(pt::TextStream & stream, const char * str, const FT & field_type, bool add_quotes = false);
virtual void string_to_stream(pt::TextStream & stream, const wchar_t * str, const FT & field_type, bool add_quotes = false);
virtual void string_to_stream(pt::TextStream & stream, const std::string & str, const FT & field_type, bool add_quotes = false);
virtual void string_to_stream(pt::TextStream & stream, const std::wstring & str, const FT & field_type, bool add_quotes = false);
virtual void stream_to_stream(pt::TextStream & stream_out, const pt::TextStream & stream_in, const FT & field_type, bool add_quotes = false);
virtual void stream_to_stream(pt::TextStream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes = false);
virtual void string_to_stream(pt::TextStream & stream, const char * str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void string_to_stream(pt::TextStream & stream, const wchar_t * str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void string_to_stream(pt::TextStream & stream, const std::string & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void string_to_stream(pt::TextStream & stream, const std::wstring & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void stream_to_stream(pt::TextStream & stream_out, const pt::TextStream & stream_in, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);
virtual void stream_to_stream(pt::TextStream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr);

View File

@ -846,6 +846,84 @@ public:
}
Finder<ModelClass> & esc_like(const char * str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
Finder<ModelClass> & esc_like(const wchar_t * str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
Finder<ModelClass> & esc_like(const std::string & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
Finder<ModelClass> & esc_like(const std::wstring & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
Finder<ModelClass> & esc_like(const pt::TextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->stream_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
Finder<ModelClass> & esc_like(const pt::WTextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
{
if( out_stream && db_expression )
{
model_env.use_escaping_for_like = true;
db_expression->stream_to_stream(*out_stream, str, field_type, add_quotes, &model_env);
model_env.use_escaping_for_like = false;
}
return *this;
}
/*
* like
*/