diff --git a/src/baseexpression.cpp b/src/baseexpression.cpp index b0a9275..f3827d1 100644 --- a/src/baseexpression.cpp +++ b/src/baseexpression.cpp @@ -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; } diff --git a/src/baseexpression.h b/src/baseexpression.h index 7d7ac35..af16390 100644 --- a/src/baseexpression.h +++ b/src/baseexpression.h @@ -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); diff --git a/src/finder.h b/src/finder.h index c37f30c..fbf2182 100644 --- a/src/finder.h +++ b/src/finder.h @@ -846,6 +846,84 @@ public: } + Finder & 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 & 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 & 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 & 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 & 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 & 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 */