diff --git a/samples/Makefile.dep b/samples/Makefile.dep index 415c75e..2714320 100644 --- a/samples/Makefile.dep +++ b/samples/Makefile.dep @@ -4,9 +4,7 @@ ./main.o: ../../pikotools/src/space/space.h ./main.o: ../../pikotools/src/convert/inttostr.h ./main.o: ../../pikotools/src/utf8/utf8.h -./main.o: ../../pikotools/src/textstream/stream.h -./main.o: ../../pikotools/src/utf8/utf8_templates.h -./main.o: ../../pikotools/src/utf8/utf8_private.h sample01.h basesample.h +./main.o: ../../pikotools/src/textstream/stream.h sample01.h basesample.h ./main.o: ../src/morm.h ../src/version.h ../src/morm_types.h ../src/model.h ./main.o: ../../pikotools/src/textstream/textstream.h ./main.o: ../../pikotools/src/textstream/stream.h diff --git a/src/Makefile.dep b/src/Makefile.dep index a03eb57..4205586 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -9,8 +9,6 @@ ./baseexpression.o: ../../pikotools/src/textstream/stream.h ./baseexpression.o: ../../pikotools/src/space/space.h ./baseexpression.o: ../../pikotools/src/utf8/utf8.h -./baseexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./baseexpression.o: ../../pikotools/src/utf8/utf8_private.h ./baseexpression.o: ../../pikotools/src/membuffer/membuffer.h ./baseexpression.o: ../../pikotools/src/textstream/types.h ./baseexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -23,9 +21,7 @@ ./clearer.o: ../../pikotools/src/convert/inttostr.h ./clearer.o: ../../pikotools/src/space/space.h ./clearer.o: ../../pikotools/src/utf8/utf8.h -./clearer.o: ../../pikotools/src/textstream/stream.h -./clearer.o: ../../pikotools/src/utf8/utf8_templates.h -./clearer.o: ../../pikotools/src/utf8/utf8_private.h ft.h model.h +./clearer.o: ../../pikotools/src/textstream/stream.h ft.h model.h ./clearer.o: ../../pikotools/src/textstream/textstream.h ./clearer.o: ../../pikotools/src/textstream/stream.h ./clearer.o: ../../pikotools/src/membuffer/membuffer.h @@ -42,8 +38,6 @@ ./dbconnector.o: ../../pikotools/src/convert/inttostr.h ./dbconnector.o: ../../pikotools/src/utf8/utf8.h ./dbconnector.o: ../../pikotools/src/textstream/stream.h -./dbconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./dbconnector.o: ../../pikotools/src/utf8/utf8_private.h ./dbconnector.o: ../../pikotools/src/convert/baseparser.h ./dbconnector.o: ../../pikotools/src/textstream/textstream.h ./dbconnector.o: ../../pikotools/src/textstream/stream.h @@ -77,8 +71,6 @@ ./dbexpression.o: ../../pikotools/src/textstream/stream.h ./dbexpression.o: ../../pikotools/src/space/space.h ./dbexpression.o: ../../pikotools/src/utf8/utf8.h -./dbexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./dbexpression.o: ../../pikotools/src/utf8/utf8_private.h ./dbexpression.o: ../../pikotools/src/membuffer/membuffer.h ./dbexpression.o: ../../pikotools/src/textstream/types.h ./dbexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -97,8 +89,6 @@ ./flatconnector.o: ../../pikotools/src/textstream/stream.h ./flatconnector.o: ../../pikotools/src/space/space.h ./flatconnector.o: ../../pikotools/src/utf8/utf8.h -./flatconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./flatconnector.o: ../../pikotools/src/utf8/utf8_private.h ./flatconnector.o: ../../pikotools/src/membuffer/membuffer.h ./flatconnector.o: ../../pikotools/src/textstream/types.h ./flatconnector.o: ../../pikotools/src/textstream/stream_private.h @@ -117,8 +107,6 @@ ./flatexpression.o: ../../pikotools/src/textstream/stream.h ./flatexpression.o: ../../pikotools/src/space/space.h ./flatexpression.o: ../../pikotools/src/utf8/utf8.h -./flatexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./flatexpression.o: ../../pikotools/src/utf8/utf8_private.h ./flatexpression.o: ../../pikotools/src/membuffer/membuffer.h ./flatexpression.o: ../../pikotools/src/textstream/types.h ./flatexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -136,8 +124,6 @@ ./jsonconnector.o: ../../pikotools/src/textstream/stream.h ./jsonconnector.o: ../../pikotools/src/space/space.h ./jsonconnector.o: ../../pikotools/src/utf8/utf8.h -./jsonconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./jsonconnector.o: ../../pikotools/src/utf8/utf8_private.h ./jsonconnector.o: ../../pikotools/src/membuffer/membuffer.h ./jsonconnector.o: ../../pikotools/src/textstream/types.h ./jsonconnector.o: ../../pikotools/src/textstream/stream_private.h @@ -154,8 +140,6 @@ ./jsonexpression.o: ../../pikotools/src/textstream/stream.h ./jsonexpression.o: ../../pikotools/src/space/space.h ./jsonexpression.o: ../../pikotools/src/utf8/utf8.h -./jsonexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./jsonexpression.o: ../../pikotools/src/utf8/utf8_private.h ./jsonexpression.o: ../../pikotools/src/membuffer/membuffer.h ./jsonexpression.o: ../../pikotools/src/textstream/types.h ./jsonexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -171,8 +155,6 @@ ./model.o: ../../pikotools/src/convert/inttostr.h ./model.o: ../../pikotools/src/utf8/utf8.h ./model.o: ../../pikotools/src/textstream/stream.h -./model.o: ../../pikotools/src/utf8/utf8_templates.h -./model.o: ../../pikotools/src/utf8/utf8_private.h ./model.o: ../../pikotools/src/date/date.h ./model.o: ../../pikotools/src/membuffer/membuffer.h ./model.o: ../../pikotools/src/textstream/types.h @@ -189,9 +171,7 @@ ./modelconnector.o: ../../pikotools/src/convert/inttostr.h ./modelconnector.o: ../../pikotools/src/space/space.h ./modelconnector.o: ../../pikotools/src/utf8/utf8.h -./modelconnector.o: ../../pikotools/src/textstream/stream.h -./modelconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./modelconnector.o: ../../pikotools/src/utf8/utf8_private.h ft.h +./modelconnector.o: ../../pikotools/src/textstream/stream.h ft.h ./modelconnector.o: dbconnector.h ../../pikotools/src/log/log.h ./modelconnector.o: ../../pikotools/src/textstream/textstream.h ./modelconnector.o: ../../pikotools/src/textstream/stream.h @@ -211,8 +191,6 @@ ./postgresqlexpression.o: ../../pikotools/src/textstream/stream.h ./postgresqlexpression.o: ../../pikotools/src/space/space.h ./postgresqlexpression.o: ../../pikotools/src/utf8/utf8.h -./postgresqlexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./postgresqlexpression.o: ../../pikotools/src/utf8/utf8_private.h ./postgresqlexpression.o: ../../pikotools/src/membuffer/membuffer.h ./postgresqlexpression.o: ../../pikotools/src/textstream/types.h ./postgresqlexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -228,8 +206,6 @@ ./postgresqlqueryresult.o: ../../pikotools/src/convert/inttostr.h ./postgresqlqueryresult.o: ../../pikotools/src/utf8/utf8.h ./postgresqlqueryresult.o: ../../pikotools/src/textstream/stream.h -./postgresqlqueryresult.o: ../../pikotools/src/utf8/utf8_templates.h -./postgresqlqueryresult.o: ../../pikotools/src/utf8/utf8_private.h ./postgresqlqueryresult.o: ../../pikotools/src/date/date.h ./postgresqlqueryresult.o: ../../pikotools/src/membuffer/membuffer.h ./postgresqlqueryresult.o: ../../pikotools/src/textstream/types.h @@ -242,8 +218,6 @@ ./queryresult.o: ../../pikotools/src/convert/inttostr.h ./queryresult.o: ../../pikotools/src/utf8/utf8.h ./queryresult.o: ../../pikotools/src/textstream/stream.h -./queryresult.o: ../../pikotools/src/utf8/utf8_templates.h -./queryresult.o: ../../pikotools/src/utf8/utf8_private.h ./queryresult.o: ../../pikotools/src/date/date.h ./queryresult.o: ../../pikotools/src/membuffer/membuffer.h ./queryresult.o: ../../pikotools/src/textstream/types.h @@ -259,8 +233,6 @@ ./csvexpression.o: ../../pikotools/src/textstream/stream.h ./csvexpression.o: ../../pikotools/src/space/space.h ./csvexpression.o: ../../pikotools/src/utf8/utf8.h -./csvexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./csvexpression.o: ../../pikotools/src/utf8/utf8_private.h ./csvexpression.o: ../../pikotools/src/membuffer/membuffer.h ./csvexpression.o: ../../pikotools/src/textstream/types.h ./csvexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -280,8 +252,6 @@ ./xmlexpression.o: ../../pikotools/src/textstream/stream.h ./xmlexpression.o: ../../pikotools/src/space/space.h ./xmlexpression.o: ../../pikotools/src/utf8/utf8.h -./xmlexpression.o: ../../pikotools/src/utf8/utf8_templates.h -./xmlexpression.o: ../../pikotools/src/utf8/utf8_private.h ./xmlexpression.o: ../../pikotools/src/membuffer/membuffer.h ./xmlexpression.o: ../../pikotools/src/textstream/types.h ./xmlexpression.o: ../../pikotools/src/textstream/stream_private.h @@ -298,8 +268,6 @@ ./transaction.o: ../../pikotools/src/convert/inttostr.h ./transaction.o: ../../pikotools/src/utf8/utf8.h ./transaction.o: ../../pikotools/src/textstream/stream.h -./transaction.o: ../../pikotools/src/utf8/utf8_templates.h -./transaction.o: ../../pikotools/src/utf8/utf8_private.h ./transaction.o: ../../pikotools/src/date/date.h ./transaction.o: ../../pikotools/src/membuffer/membuffer.h ./transaction.o: ../../pikotools/src/textstream/types.h @@ -317,8 +285,6 @@ ./xmlconnector.o: ../../pikotools/src/textstream/stream.h ./xmlconnector.o: ../../pikotools/src/space/space.h ./xmlconnector.o: ../../pikotools/src/utf8/utf8.h -./xmlconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./xmlconnector.o: ../../pikotools/src/utf8/utf8_private.h ./xmlconnector.o: ../../pikotools/src/membuffer/membuffer.h ./xmlconnector.o: ../../pikotools/src/textstream/types.h ./xmlconnector.o: ../../pikotools/src/textstream/stream_private.h @@ -336,8 +302,6 @@ ./csvconnector.o: ../../pikotools/src/textstream/stream.h ./csvconnector.o: ../../pikotools/src/space/space.h ./csvconnector.o: ../../pikotools/src/utf8/utf8.h -./csvconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./csvconnector.o: ../../pikotools/src/utf8/utf8_private.h ./csvconnector.o: ../../pikotools/src/membuffer/membuffer.h ./csvconnector.o: ../../pikotools/src/textstream/types.h ./csvconnector.o: ../../pikotools/src/textstream/stream_private.h @@ -352,8 +316,6 @@ ./postgresqlconnector.o: ../../pikotools/src/space/space.h ./postgresqlconnector.o: ../../pikotools/src/convert/inttostr.h ./postgresqlconnector.o: ../../pikotools/src/utf8/utf8.h -./postgresqlconnector.o: ../../pikotools/src/utf8/utf8_templates.h -./postgresqlconnector.o: ../../pikotools/src/utf8/utf8_private.h ./postgresqlconnector.o: ../../pikotools/src/date/date.h ./postgresqlconnector.o: ../../pikotools/src/membuffer/membuffer.h ./postgresqlconnector.o: ../../pikotools/src/textstream/types.h diff --git a/src/baseexpression.cpp b/src/baseexpression.cpp index 1dde0b2..babf731 100644 --- a/src/baseexpression.cpp +++ b/src/baseexpression.cpp @@ -435,6 +435,15 @@ void BaseExpression::after_field_value(const pt::Space &, const FT & field_type, after_field_value_string(field_type, model_env); } +void BaseExpression::before_field_value_generic() +{ +} + +void BaseExpression::after_field_value_generic() +{ +} + + void BaseExpression::put_name_value_separator() { @@ -692,28 +701,6 @@ void BaseExpression::esc(const pt::Date & date, pt::Stream & stream, const FT & } -void BaseExpression::esc(const pt::TextStream & val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) -{ - pt::TextStream::const_iterator i = val.begin(); - - for(; i != val.end() ; ++i) - { - esc(*i, stream, field_type, model_env); - } -} - - -void BaseExpression::esc(const pt::WTextStream & val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) -{ - pt::WTextStream::const_iterator i = val.begin(); - - for(; i != val.end() ; ++i) - { - esc(*i, stream, field_type, model_env); - } -} - - void BaseExpression::esc(const pt::Space & space, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) { pt::WTextStream tmp_stream; @@ -728,7 +715,25 @@ void BaseExpression::esc(const pt::Space & space, pt::Stream & stream, const FT } - +void BaseExpression::esc(const pt::Stream & val, pt::Stream & stream, const FT & field_type, ModelEnv * model_env) +{ + if( val.is_char_stream() ) + { + // from utf8 to utf8 or from utf8 to wide + pt::utf8_to_output_function(val, [&](int z) { + esc(static_cast(z), stream, field_type, model_env); + }); + } + else + if( val.is_wchar_stream() ) + { + // from wide to wide or from wide to utf8 + for(size_t i=0 ; i < val.size() ; ++i) + { + esc(val.get_wchar(i), stream, field_type, model_env); + } + } +} //void BaseExpression::put_type(char val, pt::Stream & stream) @@ -1070,13 +1075,7 @@ void BaseExpression::put_string(const std::wstring & str, const FT & field_type, } -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, model_env); -} - - -void BaseExpression::put_stream(const pt::WTextStream & str, const FT & field_type, bool add_quotes, ModelEnv * model_env) +void BaseExpression::put_stream(const pt::Stream & str, const FT & field_type, bool add_quotes, ModelEnv * model_env) { put_string_generic(str, field_type, add_quotes, model_env); } @@ -1212,15 +1211,7 @@ void BaseExpression::string_to_stream(pt::Stream & stream, const std::wstring & } -void BaseExpression::stream_to_stream(pt::Stream & 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, model_env); - this->out_stream = nullptr; -} - - -void BaseExpression::stream_to_stream(pt::Stream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes, ModelEnv * model_env) +void BaseExpression::stream_to_stream(pt::Stream & stream_out, const pt::Stream & 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, model_env); diff --git a/src/baseexpression.h b/src/baseexpression.h index b7afa4c..4fc29ba 100644 --- a/src/baseexpression.h +++ b/src/baseexpression.h @@ -249,8 +249,13 @@ public: 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 put_stream(const pt::Stream & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); + + template + void put_stream(const pt::TextStreamBase & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr) + { + put_string_generic(str, field_type, add_quotes, model_env); + } virtual void schema_table_to_stream(pt::Stream & stream, const wchar_t * schema_name, const wchar_t * table_name); virtual void schema_table_to_stream(pt::Stream & stream, const pt::WTextStream & schema_name, const pt::WTextStream & table_name); @@ -269,8 +274,16 @@ public: virtual void string_to_stream(pt::Stream & stream, const wchar_t * str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); virtual void string_to_stream(pt::Stream & stream, const std::string & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); virtual void string_to_stream(pt::Stream & stream, const std::wstring & str, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); - virtual void stream_to_stream(pt::Stream & 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::Stream & stream_out, const pt::WTextStream & stream_in, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); + + virtual void stream_to_stream(pt::Stream & stream_out, const pt::Stream & stream_in, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr); + + template + void stream_to_stream(pt::Stream & stream_out, const pt::TextStreamBase & stream_in, const FT & field_type, bool add_quotes = false, ModelEnv * model_env = nullptr) + { + this->out_stream = &stream_out; + put_stream(stream_in, field_type, add_quotes, model_env); + this->out_stream = nullptr; + } @@ -344,10 +357,35 @@ public: virtual void esc(long double val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); virtual void esc(const pt::Date & date, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); - virtual void esc(const pt::TextStream & val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); - virtual void esc(const pt::WTextStream & val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); virtual void esc(const pt::Space & space, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); + virtual void esc(const pt::Stream & val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr); + template + void esc(const pt::TextStreamBase & val, pt::Stream & stream, const FT & field_type = FT::default_type, ModelEnv * model_env = nullptr) + { + if( val.is_char_stream() ) + { + // from utf8 to utf8 or from utf8 to wide + typename pt::TextStreamBase::const_iterator start = val.begin(); + typename pt::TextStreamBase::const_iterator end = val.end(); + + pt::utf8_to_output_function(start, end, [&](int z) { + esc(static_cast(z), stream, field_type, model_env); + }); + } + else + if( val.is_wchar_stream() ) + { + // from wide to wide or from wide to utf8 + typename pt::TextStreamBase::const_iterator i = val.begin(); + typename pt::TextStreamBase::const_iterator end = val.end(); + + for(; i != end ; ++i) + { + esc(*i, stream, field_type, model_env); + } + } + } protected: @@ -643,15 +681,34 @@ protected: virtual void after_field_value(const pt::Space &, const FT & field_type, ModelEnv * model_env); template - void before_field_value(const FieldValue &, const FT & field_type, ModelEnv * model_env) + void before_field_value(const FieldValue & field_value, const FT & field_type, ModelEnv * model_env) { + if constexpr ( std::is_base_of() ) + { + before_field_value_string(field_type, model_env); + } + else + { + before_field_value_generic(); + } } template void after_field_value(const FieldValue &, const FT & field_type, ModelEnv * model_env) { + if constexpr ( std::is_base_of() ) + { + after_field_value_string(field_type, model_env); + } + else + { + after_field_value_generic(); + } } + virtual void before_field_value_generic(); + virtual void after_field_value_generic(); + virtual void put_name_value_separator(); diff --git a/src/finder.h b/src/finder.h index 3ef0b07..eb8ce78 100644 --- a/src/finder.h +++ b/src/finder.h @@ -118,7 +118,7 @@ public: Finder & set_stream(pt::Stream & out_stream) { - this->out_stream = out_stream; + this->out_stream = &out_stream; return *this; } @@ -740,12 +740,59 @@ public: } + template + Finder & raw(const pt::TextStreamBase & sql, bool add_spaces = true) + { + return raw_generic_text_stream(sql, add_spaces); + } + + + Finder & raw(short int sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + + Finder & raw(int sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + Finder & raw(long sql, bool add_spaces = true) { return raw_generic(sql, add_spaces); } + Finder & raw(long long sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + + Finder & raw(unsigned short int sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + Finder & raw(unsigned int sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + Finder & raw(unsigned long sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + + Finder & raw(unsigned long long sql, bool add_spaces = true) + { + return raw_generic(sql, add_spaces); + } + + Finder & raw(const pt::Date & date, bool add_spaces = true, const FT & field_type = morm::FT::default_type) { if( out_stream && db_expression ) @@ -801,7 +848,7 @@ public: } - Finder & esc(const pt::TextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) + Finder & esc(const pt::Stream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) { if( out_stream && db_expression ) { @@ -812,7 +859,8 @@ public: } - Finder & esc(const pt::WTextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) + template + Finder & esc(const pt::TextStreamBase & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) { if( out_stream && db_expression ) { @@ -892,7 +940,7 @@ public: } - Finder & esc_like(const pt::TextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) + Finder & esc_like(const pt::Stream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) { if( out_stream && db_expression ) { @@ -905,7 +953,8 @@ public: } - Finder & esc_like(const pt::WTextStream & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) + template + Finder & esc_like(const pt::TextStreamBase & str, bool add_quotes = true, const FT & field_type = morm::FT::default_type) { if( out_stream && db_expression ) { @@ -1005,42 +1054,45 @@ public: } - Finder & like(const wchar_t * field_name, const pt::TextStream & pattern, + Finder & like(const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & like(const wchar_t * table_name, const wchar_t * field_name, const pt::TextStream & pattern, + Finder & like(const wchar_t * table_name, const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(table_name, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & like(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::TextStream & pattern, + Finder & like(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(table_name, table_index, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & like(const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & like(const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & like(const wchar_t * table_name, const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & like(const wchar_t * table_name, const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(table_name, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & like(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & like(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return like_generic(table_name, table_index, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); @@ -1134,42 +1186,45 @@ public: } - Finder & ilike(const wchar_t * field_name, const pt::TextStream & pattern, + Finder & ilike(const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & ilike(const wchar_t * table_name, const wchar_t * field_name, const pt::TextStream & pattern, + Finder & ilike(const wchar_t * table_name, const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(table_name, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & ilike(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::TextStream & pattern, + Finder & ilike(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::Stream & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(table_name, table_index, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & ilike(const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & ilike(const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & ilike(const wchar_t * table_name, const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & ilike(const wchar_t * table_name, const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(table_name, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); } - Finder & ilike(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::WTextStream & pattern, + template + Finder & ilike(const wchar_t * table_name, int table_index, const wchar_t * field_name, const pt::TextStreamBase & pattern, bool escape_pattern = true, bool add_prefix_percent = true, bool add_postfix_percent = true) { return ilike_generic(table_name, table_index, field_name, pattern, escape_pattern, add_prefix_percent, add_postfix_percent); @@ -1666,6 +1721,66 @@ private: return *this; } + + template + Finder & raw_generic_text_stream(const pt::TextStreamBase & sql, bool add_spaces = true) + { + if( out_stream ) + { + if( add_spaces ) + (*out_stream) << ' '; + + if( sql.is_char_stream() ) + { + raw_generic_text_stream_utf8(sql); + } + else + { + raw_generic_text_stream_wide(sql); + } + + if( add_spaces ) + (*out_stream) << ' '; + } + + return *this; + } + + + template + void raw_generic_text_stream_utf8(const pt::TextStreamBase & sql) + { + if( out_stream->is_char_stream() ) + { + // utf8 to utf8 + typename pt::TextStreamBase::const_iterator i = sql.begin(); + + for( ; i != sql.end() ; ++i) + { + (*out_stream) << *i; + } + } + else + { + // utf8 to wide + typename pt::TextStreamBase::const_iterator start = sql.begin(); + typename pt::TextStreamBase::const_iterator end = sql.end(); + pt::utf8_to_wide(start, end, *out_stream, false); + } + } + + + template + void raw_generic_text_stream_wide(const pt::TextStreamBase & sql) + { + typename pt::TextStreamBase::const_iterator i = sql.begin(); + + for( ; i != sql.end() ; ++i) + { + (*out_stream) << *i; + } + } + }; } // namespace