add Finder::esc(...) methods
This commit is contained in:
parent
7f4deaf847
commit
2ac8769d3a
|
@ -939,6 +939,31 @@ void BaseExpression::put_table_and_field(const pt::WTextStream & table_name, con
|
|||
|
||||
|
||||
|
||||
void BaseExpression::put_string(const char * str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
put_string_generic(str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_string(const wchar_t * str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
put_string_generic(str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_string(const std::string & str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
put_string_generic(str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::put_string(const std::wstring & str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
put_string_generic(str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BaseExpression::schema_table_to_stream(pt::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
|
@ -1020,6 +1045,41 @@ void BaseExpression::table_and_field_to_stream(pt::TextStream & stream, const pt
|
|||
|
||||
|
||||
|
||||
void BaseExpression::string_to_stream(pt::TextStream & stream, const char * str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_string(str, field_type, add_quotes);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::string_to_stream(pt::TextStream & stream, const wchar_t * str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_string(str, field_type, add_quotes);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::string & str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_string(str, field_type, add_quotes);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BaseExpression::string_to_stream(pt::TextStream & stream, const std::wstring & str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
this->out_stream = &stream;
|
||||
put_string(str, field_type, add_quotes);
|
||||
this->out_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool BaseExpression::is_empty_field(const wchar_t * value)
|
||||
{
|
||||
return (!value || *value == '\0');
|
||||
|
|
|
@ -262,6 +262,11 @@ public:
|
|||
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 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 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 table_to_stream(pt::TextStream & stream, const wchar_t * table_name);
|
||||
|
@ -273,6 +278,50 @@ public:
|
|||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
template<typename StringType>
|
||||
void put_string_generic(const StringType * str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
if( out_stream )
|
||||
{
|
||||
if( add_quotes )
|
||||
{
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
esc(str, *out_stream, field_type);
|
||||
|
||||
if( add_quotes )
|
||||
{
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename StringType>
|
||||
void put_string_generic(const StringType & str, const FT & field_type, bool add_quotes)
|
||||
{
|
||||
if( out_stream )
|
||||
{
|
||||
if( add_quotes )
|
||||
{
|
||||
before_field_value_string(field_type);
|
||||
}
|
||||
|
||||
esc(str, *out_stream, field_type);
|
||||
|
||||
if( add_quotes )
|
||||
{
|
||||
after_field_value_string(field_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IMPLEMENT ME
|
||||
|
|
45
src/finder.h
45
src/finder.h
|
@ -654,6 +654,51 @@ public:
|
|||
}
|
||||
|
||||
|
||||
Finder<ModelClass> & esc(const char * str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
|
||||
{
|
||||
if( out_stream && db_expression )
|
||||
{
|
||||
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Finder<ModelClass> & esc(const wchar_t * str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
|
||||
{
|
||||
if( out_stream && db_expression )
|
||||
{
|
||||
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Finder<ModelClass> & esc(const std::string & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
|
||||
{
|
||||
if( out_stream && db_expression )
|
||||
{
|
||||
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Finder<ModelClass> & esc(const std::wstring & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type)
|
||||
{
|
||||
if( out_stream && db_expression )
|
||||
{
|
||||
db_expression->string_to_stream(*out_stream, str, field_type, add_quotes);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Cursor<ModelClass> get_cursor()
|
||||
{
|
||||
Cursor<ModelClass> cursor;
|
||||
|
|
Loading…
Reference in New Issue