diff --git a/src/baseexpression.cpp b/src/baseexpression.cpp index 11ef30d..03d024d 100644 --- a/src/baseexpression.cpp +++ b/src/baseexpression.cpp @@ -148,7 +148,7 @@ void BaseExpression::after_generate_from_model() } -bool BaseExpression::can_field_be_generated(FT) +bool BaseExpression::can_field_be_generated(const FT &) { return true; } @@ -208,7 +208,7 @@ bool BaseExpression::is_long_field_name(const PT::TextStream & field_name) } -void BaseExpression::put_field_name(const wchar_t * field_name, FT field_type, ModelEnv * model_env) +void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field_type, ModelEnv * model_env) { if( field_type.is_raw_field_name() ) { @@ -283,7 +283,7 @@ void BaseExpression::put_short_field_name(const wchar_t * field_name, ModelEnv * } -void BaseExpression::save_foreign_key(const wchar_t * field_name, 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 * old_out_stream = out_stream; @@ -332,93 +332,93 @@ void BaseExpression::after_second_part_long_field_name() -void BaseExpression::before_field_value(const std::wstring &, FT field_type) +void BaseExpression::before_field_value(const std::wstring &, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::before_field_value(const std::string &, FT field_type) +void BaseExpression::before_field_value(const std::string &, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(const std::wstring &, FT field_type) +void BaseExpression::after_field_value(const std::wstring &, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::after_field_value(const std::string &, FT field_type) +void BaseExpression::after_field_value(const std::string &, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(const wchar_t *, FT field_type) +void BaseExpression::before_field_value(const wchar_t *, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(const wchar_t *, FT field_type) +void BaseExpression::after_field_value(const wchar_t *, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(const char *, FT field_type) +void BaseExpression::before_field_value(const char *, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(const char *, FT field_type) +void BaseExpression::after_field_value(const char *, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(wchar_t, FT field_type) +void BaseExpression::before_field_value(wchar_t, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(wchar_t, FT field_type) +void BaseExpression::after_field_value(wchar_t, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(char, FT field_type) +void BaseExpression::before_field_value(char, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(char, FT field_type) +void BaseExpression::after_field_value(char, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(const PT::Date &, FT field_type) +void BaseExpression::before_field_value(const PT::Date &, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(const PT::Date &, FT field_type) +void BaseExpression::after_field_value(const PT::Date &, const FT & field_type) { after_field_value_string(field_type); } -void BaseExpression::before_field_value(const PT::Space &, FT field_type) +void BaseExpression::before_field_value(const PT::Space &, const FT & field_type) { before_field_value_string(field_type); } -void BaseExpression::after_field_value(const PT::Space &, FT field_type) +void BaseExpression::after_field_value(const PT::Space &, const FT & field_type) { after_field_value_string(field_type); } @@ -448,7 +448,7 @@ void BaseExpression::char_to_hex(char c, PT::TextStream & stream) -void BaseExpression::esc(char val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(char val, PT::TextStream & stream, const FT & field_type) { if( field_type.is_binary() || field_type.is_hexadecimal() ) { @@ -461,13 +461,13 @@ void BaseExpression::esc(char val, PT::TextStream & stream, FT field_type) } -void BaseExpression::esc(unsigned char val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(unsigned char val, PT::TextStream & stream, const FT & field_type) { esc(static_cast(val), stream, field_type); } -void BaseExpression::esc(wchar_t val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(wchar_t val, PT::TextStream & stream, const FT & field_type) { if( field_type.use_utf8() ) { @@ -487,7 +487,7 @@ void BaseExpression::esc(wchar_t val, PT::TextStream & stream, FT field_type) } -void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, const FT & field_type) { if( field_type.use_utf8() ) { @@ -513,19 +513,19 @@ void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, } -void BaseExpression::esc(const std::wstring & val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const std::wstring & val, PT::TextStream & stream, const FT & field_type) { esc(val.c_str(), true, val.size(), stream, field_type); } -void BaseExpression::esc(const wchar_t * val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const wchar_t * val, PT::TextStream & stream, const FT & field_type) { esc(val, false, 0, stream, field_type); } -void BaseExpression::esc(const std::string & val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const std::string & val, PT::TextStream & stream, const FT & field_type) { for(size_t i = 0 ; i < val.size() ; ++i) { @@ -534,7 +534,7 @@ void BaseExpression::esc(const std::string & val, PT::TextStream & stream, FT fi } -void BaseExpression::esc(const char * val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const char * val, PT::TextStream & stream, const FT & field_type) { for(size_t i = 0 ; val[i] != 0 ; ++i) { @@ -543,7 +543,7 @@ void BaseExpression::esc(const char * val, PT::TextStream & stream, FT field_typ } -void BaseExpression::esc(bool val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(bool val, PT::TextStream & stream, const FT & field_type) { if( val ) stream << "true"; @@ -552,80 +552,80 @@ void BaseExpression::esc(bool val, PT::TextStream & stream, FT field_type) } -void BaseExpression::esc(short val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(short val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(unsigned short val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(unsigned short val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(int val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(int val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(unsigned int val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(unsigned int val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(long val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(long val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(unsigned long val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(unsigned long val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(long long val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(long long val, PT::TextStream & stream, const FT & field_type) { // not implemented in PT::TextStream yet //stream << val; } -void BaseExpression::esc(unsigned long long val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(unsigned long long val, PT::TextStream & stream, const FT & field_type) { //stream << val; } -void BaseExpression::esc(float val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(float val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(double val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(double val, PT::TextStream & stream, const FT & field_type) { stream << val; } -void BaseExpression::esc(long double val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(long double val, PT::TextStream & stream, const FT & field_type) { // IMPLEMENT ME in PT::TextStream //stream << val; } -void BaseExpression::esc(const PT::Date & date, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type) { stream << date; } -void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream, const FT & field_type) { PT::TextStream::const_iterator i = val.begin(); @@ -635,7 +635,7 @@ void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream, FT } } -void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, const FT & field_type) { PT::WTextStream::const_iterator i = val.begin(); @@ -645,7 +645,7 @@ void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, F } } -void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream, FT field_type) +void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream, const FT & field_type) { PT::WTextStream tmp_stream; @@ -763,11 +763,11 @@ void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream, FT fi //} -void BaseExpression::before_field_value_string(FT field_type) +void BaseExpression::before_field_value_string(const FT & field_type) { } -void BaseExpression::after_field_value_string(FT field_type) +void BaseExpression::after_field_value_string(const FT & field_type) { } diff --git a/src/baseexpression.h b/src/baseexpression.h index 23a7a76..d00bad2 100644 --- a/src/baseexpression.h +++ b/src/baseexpression.h @@ -76,7 +76,7 @@ public: template - void field(const wchar_t * field_name, const FieldValue & field_value, FT field_type, ModelEnv * model_env) + void field(const wchar_t * field_name, const FieldValue & field_value, const FT & field_type, ModelEnv * model_env) { if( out_stream && can_field_be_generated(field_type) ) { @@ -127,7 +127,7 @@ public: template - void put_field_value_or_null(const FieldValue & field_value, FT field_type, ModelEnv * model_env) + void put_field_value_or_null(const FieldValue & field_value, const FT & field_type, ModelEnv * model_env) { if( field_type.is_primary_key() ) { @@ -164,7 +164,7 @@ public: template - void field_list(const wchar_t * field_name, ModelContainer & field_value, FT field_type, ModelConnector * model_connector, ModelEnv * model_env) + void field_list(const wchar_t * field_name, ModelContainer & field_value, const FT & field_type, ModelConnector * model_connector, ModelEnv * model_env) { if( out_stream && can_field_be_generated(field_type) ) { @@ -187,7 +187,7 @@ public: } template - void field_model(const wchar_t * field_name, ModelClass & field_model, FT field_type, ModelEnv * model_env) + void field_model(const wchar_t * field_name, ModelClass & field_model, const FT & field_type, ModelEnv * model_env) { if( out_stream && can_field_be_generated(field_type) ) { @@ -215,7 +215,7 @@ public: } template - void field_to_stream(PT::TextStream & stream, const wchar_t * field_name, const FieldValue & field_value, FT field_type, ModelEnv * model_env) + void field_to_stream(PT::TextStream & stream, const wchar_t * field_name, const FieldValue & field_value, const FT & field_type, ModelEnv * model_env) { this->out_stream = &stream; field(field_name, field_value, field_type, model_env); @@ -247,35 +247,35 @@ public: * esc for: signed char, wchar_t, char16_t, char32_t * */ - virtual void esc(char val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(unsigned char val, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(char val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(unsigned char val, PT::TextStream & stream, const FT & field_type = FT::default_type); - virtual void esc(wchar_t val, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(wchar_t val, PT::TextStream & stream, const FT & field_type = FT::default_type); - virtual void esc(const std::wstring & val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(const wchar_t * val, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(const std::wstring & val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(const wchar_t * val, PT::TextStream & stream, const FT & field_type = FT::default_type); - virtual void esc(const std::string & val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(const char * val, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(const std::string & val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(const char * val, PT::TextStream & stream, const FT & field_type = FT::default_type); - virtual void esc(bool val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(short val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(unsigned short val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(int val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(unsigned int val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(long val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(unsigned long val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(long long val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(unsigned long long val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(float val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(double val, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(long double val, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(bool val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(short val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(unsigned short val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(int val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(unsigned int val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(long val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(unsigned long val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(long long val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(unsigned long long val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(float val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(double val, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(long double val, PT::TextStream & stream, const FT & field_type = FT::default_type); //virtual void esc(void* val, PT::TextStream & stream); - virtual void esc(const PT::Date & date, PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(const PT::TextStream & val,PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(const PT::WTextStream & val,PT::TextStream & stream, FT field_type = FT::default_type); - virtual void esc(const PT::Space & space, PT::TextStream & stream, FT field_type = FT::default_type); + virtual void esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type = FT::default_type); + virtual void esc(const PT::TextStream & 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 bool is_long_field_name(const wchar_t * field_name); virtual bool is_long_field_name(const PT::TextStream & table_name); @@ -294,17 +294,17 @@ protected: virtual void before_generate_from_model(); virtual void after_generate_from_model(); - virtual bool can_field_be_generated(FT); + virtual bool can_field_be_generated(const FT &); virtual void field_before(); virtual void field_after(); - virtual void put_field_name(const wchar_t * field_name, 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, 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 dump_additional_info(Model & model); template - void put_field_value(const FieldValue & field_value, FT field_type) + void put_field_value(const FieldValue & field_value, const FT & field_type) { if( out_stream ) { @@ -632,37 +632,37 @@ protected: 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 &, FT field_type); - virtual void after_field_value(const std::wstring &, 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 before_field_value(const std::string &, FT field_type); - virtual void after_field_value(const std::string &, FT field_type); + virtual void before_field_value(const std::string &, const FT & field_type); + virtual void after_field_value(const std::string &, const FT & field_type); - virtual void before_field_value(const wchar_t *, FT field_type); - virtual void after_field_value(const wchar_t *, FT field_type); + virtual void before_field_value(const wchar_t *, const FT & field_type); + virtual void after_field_value(const wchar_t *, const FT & field_type); - virtual void before_field_value(const char *, FT field_type); - virtual void after_field_value(const char *, FT field_type); + virtual void before_field_value(const char *, const FT & field_type); + virtual void after_field_value(const char *, const FT & field_type); - virtual void before_field_value(wchar_t, FT field_type); - virtual void after_field_value(wchar_t, FT field_type); + virtual void before_field_value(wchar_t, const FT & field_type); + virtual void after_field_value(wchar_t, const FT & field_type); - virtual void before_field_value(char, FT field_type); - virtual void after_field_value(char, FT field_type); + virtual void before_field_value(char, const FT & field_type); + virtual void after_field_value(char, const FT & field_type); - virtual void before_field_value(const PT::Date &, FT field_type); - virtual void after_field_value(const PT::Date &, FT field_type); + virtual void before_field_value(const PT::Date &, const FT & field_type); + virtual void after_field_value(const PT::Date &, const FT & field_type); - virtual void before_field_value(const PT::Space &, FT field_type); - virtual void after_field_value(const PT::Space &, FT field_type); + virtual void before_field_value(const PT::Space &, const FT & field_type); + virtual void after_field_value(const PT::Space &, const FT & field_type); template - void before_field_value(const FieldValue &, FT field_type) + void before_field_value(const FieldValue &, const FT & field_type) { } template - void after_field_value(const FieldValue &, FT field_type) + void after_field_value(const FieldValue &, const FT & field_type) { } @@ -714,13 +714,13 @@ protected: - virtual void before_field_value_string(FT field_type); - virtual void after_field_value_string(FT field_type); + virtual void before_field_value_string(const FT & field_type); + virtual void after_field_value_string(const FT & field_type); char char_to_hex_part(char c); void char_to_hex(char c, PT::TextStream & stream); - void esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, FT field_type = FT::default_type); + void esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, const FT & field_type = FT::default_type); }; diff --git a/src/dbconnector.cpp b/src/dbconnector.cpp index 4b3a4c3..6ec2cab 100644 --- a/src/dbconnector.cpp +++ b/src/dbconnector.cpp @@ -344,7 +344,7 @@ void DbConnector::unescape_hex_string(const char * str, std::string & out) } -void DbConnector::unescape_hex_string(const char * str, std::wstring & out, FT field_type) +void DbConnector::unescape_hex_string(const char * str, std::wstring & out, const FT & field_type) { if( field_type.use_utf8() ) { @@ -373,7 +373,7 @@ void DbConnector::unescape_bin_string(const char * str, std::string & out) } -void DbConnector::unescape_bin_string(const char * str, std::wstring & out, FT field_type) +void DbConnector::unescape_bin_string(const char * str, std::wstring & out, const FT & field_type) { unescape_hex_string(str, out, field_type); } @@ -410,7 +410,7 @@ size_t DbConnector::unescape_hex_char(const char * value_str, char * utf8_str, s // CHECKME need to be tested // returns how many characters were used from value_str -size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_value, FT field_type) +size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_value, const FT & field_type) { size_t len = 0; @@ -456,7 +456,7 @@ size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_va } -size_t DbConnector::unescape_bin_char(const char * value_str, wchar_t & field_value, FT field_type) +size_t DbConnector::unescape_bin_char(const char * value_str, wchar_t & field_value, const FT & field_type) { return unescape_hex_char(value_str, field_value, field_type); } @@ -464,7 +464,7 @@ size_t DbConnector::unescape_bin_char(const char * value_str, wchar_t & field_va // CHECKME need to be tested -void DbConnector::get_value(const char * value_str, char & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, char & field_value, const FT & field_type) { wchar_t c; @@ -495,7 +495,7 @@ void DbConnector::get_value(const char * value_str, char & field_value, FT field // CHECKME need to be tested -void DbConnector::get_value(const char * value_str, unsigned char & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, unsigned char & field_value, const FT & field_type) { char tmp_char; get_value(value_str, tmp_char, field_type); @@ -506,7 +506,7 @@ void DbConnector::get_value(const char * value_str, unsigned char & field_value, // CHECKME need to be tested -void DbConnector::get_value(const char * value_str, wchar_t & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, wchar_t & field_value, const FT & field_type) { field_value = 0; @@ -547,7 +547,7 @@ void DbConnector::get_value(const char * value_str, wchar_t & field_value, FT fi // CHECKME need to be tested -void DbConnector::get_value(const char * value_str, std::wstring & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, std::wstring & field_value, const FT & field_type) { if( field_type.is_binary() ) { @@ -576,7 +576,7 @@ void DbConnector::get_value(const char * value_str, std::wstring & field_value, // CHECKME need to be tested -void DbConnector::get_value(const char * value_str, std::string & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, std::string & field_value, const FT & field_type) { if( field_type.is_binary() ) { @@ -594,7 +594,7 @@ void DbConnector::get_value(const char * value_str, std::string & field_value, F } -void DbConnector::get_value(const char * value_str, bool & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, bool & field_value, const FT & field_type) { // IMPROVE ME // this 't' is locale dependent @@ -602,91 +602,91 @@ void DbConnector::get_value(const char * value_str, bool & field_value, FT field } -void DbConnector::get_value(const char * value_str, short & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, short & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = (short)PT::Toi(value_str, 10); } -void DbConnector::get_value(const char * value_str, unsigned short & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, unsigned short & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = (unsigned short)PT::Toui(value_str, 10); } -void DbConnector::get_value(const char * value_str, int & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, int & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Toi(value_str, 10); } -void DbConnector::get_value(const char * value_str, unsigned int & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, unsigned int & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Toui(value_str, 10); } -void DbConnector::get_value(const char * value_str, long & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, long & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Tol(value_str, 10); } -void DbConnector::get_value(const char * value_str, unsigned long & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, unsigned long & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Toul(value_str, 10); } -void DbConnector::get_value(const char * value_str, long long & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, long long & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Toll(value_str, 10); } -void DbConnector::get_value(const char * value_str, unsigned long long & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, unsigned long long & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = PT::Toull(value_str, 10); } -void DbConnector::get_value(const char * value_str, float & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, float & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = strtof(value_str, 0); } -void DbConnector::get_value(const char * value_str, double & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, double & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = strtod(value_str, 0); } -void DbConnector::get_value(const char * value_str, long double & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, long double & field_value, const FT & field_type) { // IMPROVE ME give some overflow checking field_value = strtold(value_str, 0); } -void DbConnector::get_value(const char * value_str, PT::Date & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, PT::Date & field_value, const FT & field_type) { // IMPROVE ME give some log if parsing failed field_value.Parse(value_str); } -void DbConnector::get_value(const char * value_str, PT::Space & field_value, FT field_type) +void DbConnector::get_value(const char * value_str, PT::Space & field_value, const FT & field_type) { field_value.clear(); diff --git a/src/dbconnector.h b/src/dbconnector.h index d7e3b2e..2a93cd3 100644 --- a/src/dbconnector.h +++ b/src/dbconnector.h @@ -91,25 +91,25 @@ public: virtual bool query_insert(const PT::TextStream & stream, QueryResult & query_result); virtual bool query_remove(const PT::TextStream & stream, QueryResult & query_result); - virtual void get_value(const char * value_str, char & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, unsigned char & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, wchar_t & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, std::wstring & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, std::string & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, bool & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, short & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, unsigned short & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, int & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, unsigned int & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, long & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, unsigned long & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, long long & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, unsigned long long & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, float & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, double & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, long double & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, PT::Date & field_value, FT field_type = FT::default_type); - virtual void get_value(const char * value_str, PT::Space & field_value, FT field_type = FT::default_type); + virtual void get_value(const char * value_str, char & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, unsigned char & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, wchar_t & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, std::wstring & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, std::string & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, bool & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, short & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, unsigned short & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, int & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, unsigned int & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, long & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, unsigned long & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, long long & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, unsigned long long & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, float & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, double & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, long double & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, PT::Date & field_value, const FT & field_type = FT::default_type); + virtual void get_value(const char * value_str, PT::Space & field_value, const FT & field_type = FT::default_type); // add get_value for PT::TextStream and PT::WTextStream @@ -149,14 +149,14 @@ protected: virtual const char * query_last_sequence(const wchar_t * sequence_table_name); virtual void unescape_hex_string(const char * str, std::string & out); - virtual void unescape_hex_string(const char * str, std::wstring & out, FT field_type); + virtual void unescape_hex_string(const char * str, std::wstring & out, const FT & field_type); virtual void unescape_bin_string(const char * str, std::string & out); - virtual void unescape_bin_string(const char * str, std::wstring & out, FT field_type); + virtual void unescape_bin_string(const char * str, std::wstring & out, const FT & field_type); virtual size_t unescape_hex_char(const char * value_str, char * utf8_str, size_t utf8_str_max_len); - virtual size_t unescape_hex_char(const char * value_str, wchar_t & field_value, FT field_type); - virtual size_t unescape_bin_char(const char * value_str, wchar_t & field_value, FT field_type); + virtual size_t unescape_hex_char(const char * value_str, wchar_t & field_value, const FT & field_type); + virtual size_t unescape_bin_char(const char * value_str, wchar_t & field_value, const FT & field_type); private: diff --git a/src/dbexpression.cpp b/src/dbexpression.cpp index 5bf82d4..913d321 100644 --- a/src/dbexpression.cpp +++ b/src/dbexpression.cpp @@ -62,7 +62,7 @@ int DbExpression::get_output_type() } -bool DbExpression::can_field_be_generated(FT field_type) +bool DbExpression::can_field_be_generated(const FT & field_type) { if( output_type == MORM_OUTPUT_TYPE_DB_INSERT ) { @@ -183,13 +183,13 @@ void DbExpression::put_name_value_separator() -void DbExpression::before_field_value_string(FT field_type) +void DbExpression::before_field_value_string(const FT & field_type) { (*out_stream) << "'"; } -void DbExpression::after_field_value_string(FT field_type) +void DbExpression::after_field_value_string(const FT & field_type) { (*out_stream) << "'"; } diff --git a/src/dbexpression.h b/src/dbexpression.h index 5c4cbdb..c09d579 100644 --- a/src/dbexpression.h +++ b/src/dbexpression.h @@ -63,7 +63,7 @@ public: virtual DbExpression & page(PT::TextStream & stream, size_t page_number, size_t page_size); template - void add_field_for_select(const wchar_t * new_column_expression, const wchar_t * new_column_name, FieldValue & field_value, FT field_type, ModelEnv * model_env) + void add_field_for_select(const wchar_t * new_column_expression, const wchar_t * new_column_name, FieldValue & field_value, const FT & field_type, ModelEnv * model_env) { std::wstring column_expression; // field() methods can be called recursively, so don't make it as class object @@ -81,15 +81,15 @@ protected: int output_type; std::vector conjunctions; - bool can_field_be_generated(FT field_type); + bool can_field_be_generated(const FT & field_type); void field_before(); void put_name_value_separator(); private: - void before_field_value_string(FT field_type); - void after_field_value_string(FT field_type); + void before_field_value_string(const FT & field_type); + void after_field_value_string(const FT & field_type); }; diff --git a/src/flatexpression.cpp b/src/flatexpression.cpp index 0a31f52..884604a 100644 --- a/src/flatexpression.cpp +++ b/src/flatexpression.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2018, Tomasz Sowa + * Copyright (c) 2018-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ namespace morm { -void FlatExpression::esc(const PT::Date & date, PT::TextStream & stream, FT field_type) +void FlatExpression::esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type) { date.SerializeISO(stream); } diff --git a/src/flatexpression.h b/src/flatexpression.h index fc45823..87e362e 100644 --- a/src/flatexpression.h +++ b/src/flatexpression.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2018, Tomasz Sowa + * Copyright (c) 2018-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ class FlatExpression : public BaseExpression { public: - void esc(const PT::Date & date, PT::TextStream & stream, FT field_type); + void esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type); diff --git a/src/jsonexpression.cpp b/src/jsonexpression.cpp index a2d18dd..bb15a4f 100644 --- a/src/jsonexpression.cpp +++ b/src/jsonexpression.cpp @@ -105,12 +105,12 @@ void JSONExpression::after_second_part_long_field_name() } -void JSONExpression::before_field_value_string(FT field_type) +void JSONExpression::before_field_value_string(const FT & field_type) { (*out_stream) << "\""; } -void JSONExpression::after_field_value_string(FT field_type) +void JSONExpression::after_field_value_string(const FT & field_type) { (*out_stream) << "\""; } @@ -134,7 +134,7 @@ void JSONExpression::after_field_value_list() } -void JSONExpression::esc(char val, PT::TextStream & stream, FT field_type) +void JSONExpression::esc(char val, PT::TextStream & stream, const FT & field_type) { if( field_type.is_hexadecimal() || field_type.is_binary() ) { diff --git a/src/jsonexpression.h b/src/jsonexpression.h index a9f39bf..ebe7352 100644 --- a/src/jsonexpression.h +++ b/src/jsonexpression.h @@ -70,13 +70,13 @@ protected: // 'morm::JSONExpression::esc' hides overloaded virtual function [-Woverloaded-virtual] using FlatExpression::esc; - void esc(char val, PT::TextStream & stream, FT field_type); + void esc(char val, PT::TextStream & stream, const FT & field_type); private: - void before_field_value_string(FT field_type); - void after_field_value_string(FT field_type); + void before_field_value_string(const FT & field_type); + void after_field_value_string(const FT & field_type); }; diff --git a/src/model.cpp b/src/model.cpp index f9e9845..efe3f58 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -1006,7 +1006,7 @@ void Model::put_fields_to_log(PT::Log & log, const wchar_t * db_field_name, cons * this is only in a case when has_foreign_key is false, may it can be ignored? we can use unique index in such a case * */ -void Model::field_model_left_join(const wchar_t * db_field_name, Model & field_model, FT field_type, DbExpression * db_expression) +void Model::field_model_left_join(const wchar_t * db_field_name, Model & field_model, const FT & field_type, DbExpression * db_expression) { if( model_env && field_model.model_env && model_env->finder_helper ) { @@ -1208,7 +1208,7 @@ void Model::field_model_iterate_through_childs(const wchar_t * db_field_name, Mo -void Model::field_model_generate_flat_string(const wchar_t * flat_field_name, Model & field_model, FT field_type) +void Model::field_model_generate_flat_string(const wchar_t * flat_field_name, Model & field_model, const FT & field_type) { FlatConnector * flat_connector = model_connector->get_flat_connector(); @@ -1228,7 +1228,7 @@ void Model::field_model_generate_flat_string(const wchar_t * flat_field_name, Mo } -void Model::field_model_generate_db_sql(const wchar_t * db_field_name, Model & field_model, FT field_type) +void Model::field_model_generate_db_sql(const wchar_t * db_field_name, Model & field_model, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); @@ -1314,7 +1314,7 @@ void Model::field_model_clear_values(Model & field_model) } -void Model::field_model_read_values_from_queryresult(const wchar_t * db_field_name, Model & field_model, FT field_type) +void Model::field_model_read_values_from_queryresult(const wchar_t * db_field_name, Model & field_model, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); @@ -1343,7 +1343,7 @@ void Model::field_model_read_values_from_queryresult(const wchar_t * db_field_na } -void Model::field_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_model, FT field_type) +void Model::field_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_model, const FT & field_type) { if( model_connector && model_env ) { @@ -1393,7 +1393,7 @@ void Model::field_model(const wchar_t * db_field_name, const wchar_t * flat_fiel } -void Model::field_model_for_db(const wchar_t * db_field_name, Model & field_model, FT field_type) +void Model::field_model_for_db(const wchar_t * db_field_name, Model & field_model, const FT & field_type) { if( model_env->model_work_mode == MORM_MODEL_WORK_MODE_SET_PARENT_ID ) { diff --git a/src/model.h b/src/model.h index a9d7e57..bd7472e 100644 --- a/src/model.h +++ b/src/model.h @@ -222,115 +222,115 @@ protected: * field methods for such field_values: signed char, char16_t, char32_t, std::u16string, std::u32string * */ - void field(const wchar_t * field_name, char & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, char & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, unsigned char & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, unsigned char & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, wchar_t & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, wchar_t & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, std::wstring & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, std::wstring & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, std::string & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, std::string & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, bool & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, bool & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, short & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, short & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, unsigned short & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, unsigned short & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, int & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, int & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, unsigned int & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, unsigned int & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, long & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, unsigned long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, unsigned long & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, long long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, long long & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, unsigned long long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, unsigned long long & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, float & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, float & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, double & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, double & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, long double & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, long double & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, PT::Date & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, PT::Date & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, PT::Space & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, PT::Space & field_value, const FT & field_type = FT::default_type) { field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, Model & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, Model & field_value, const FT & field_type = FT::default_type) { field_model(field_name, field_name, field_value, field_type); } template - void field(const wchar_t * field_name, std::list & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, std::list & field_value, const FT & field_type = FT::default_type) { ModelClass * list_model_null_pointer = nullptr; field_list(field_name, field_name, field_value, list_model_null_pointer, field_type); } template - void field(const wchar_t * field_name, std::vector & field_value, FT field_type = FT::default_type) + void field(const wchar_t * field_name, std::vector & field_value, const FT & field_type = FT::default_type) { ModelClass * list_model_null_pointer = nullptr; field_list(field_name, field_name, field_value, list_model_null_pointer, field_type); @@ -341,116 +341,116 @@ protected: * field methods which take two names: db_field_name and flat_field_name */ - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, char & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, char & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned char & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned char & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, wchar_t & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, wchar_t & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::wstring & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::wstring & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::string & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::string & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, bool & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, short & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, short & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned short & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned short & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, int & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, int & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned int & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned int & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned long & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long long & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned long long & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, unsigned long long & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, float & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, float & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, double & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, double & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long double & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, long double & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, PT::Date & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, PT::Date & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, PT::Space & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, PT::Space & field_value, const FT & field_type = FT::default_type) { field_generic(db_field_name, flat_field_name, field_value, field_type); } - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_value, const FT & field_type = FT::default_type) { // has_foreign_key was here field_model(db_field_name, flat_field_name, field_value, field_type); } template - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::list & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::list & field_value, const FT & field_type = FT::default_type) { ModelClass * list_model_null_pointer = nullptr; field_list(db_field_name, flat_field_name, field_value, list_model_null_pointer, field_type); } template - void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::vector & field_value, FT field_type = FT::default_type) + void field(const wchar_t * db_field_name, const wchar_t * flat_field_name, std::vector & field_value, const FT & field_type = FT::default_type) { ModelClass * list_model_null_pointer = nullptr; field_list(db_field_name, flat_field_name, field_value, list_model_null_pointer, field_type); @@ -501,7 +501,7 @@ protected: template - void field_generic_iterate_primary_key_values(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic_iterate_primary_key_values(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { if( field_type.is_primary_key() ) { @@ -521,7 +521,7 @@ protected: template - void field_generic_generate_flat_string(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic_generate_flat_string(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { FlatConnector * flat_connector = model_connector->get_flat_connector(); @@ -538,7 +538,7 @@ protected: template - void field_generic_generate_db_sql(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic_generate_db_sql(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); @@ -555,7 +555,7 @@ protected: template - void field_generic_read_value_from_db_resultset(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic_read_value_from_db_resultset(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); @@ -578,7 +578,7 @@ protected: template - void field_generic_clear_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic_clear_value(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { Clearer * clearer = model_connector->get_clearer(); @@ -590,7 +590,7 @@ protected: template - void field_generic(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, FT field_type) + void field_generic(const wchar_t * db_field_name, const wchar_t * flat_field_name, FieldValue & field_value, const FT & field_type) { if( model_connector && model_env ) { @@ -632,17 +632,17 @@ protected: } - void field_model_left_join(const wchar_t * db_field_name, Model & field_model, FT field_type, DbExpression * db_expression); + void field_model_left_join(const wchar_t * db_field_name, Model & field_model, const FT & field_type, DbExpression * db_expression); void field_model_save_key(const wchar_t * db_field_name); void field_model_set_parent_key_in_child(const wchar_t * db_field_name, Model & field_model); void field_model_set_parent_key(const wchar_t * db_field_name, Model & field_model); void field_model_iterate_through_childs(const wchar_t * db_field_name, Model & field_model); - void field_model_generate_flat_string(const wchar_t * flat_field_name, Model & field_model, FT field_type); - void field_model_generate_db_sql(const wchar_t * db_field_name, Model & field_model, FT field_type); + void field_model_generate_flat_string(const wchar_t * flat_field_name, Model & field_model, const FT & field_type); + void field_model_generate_db_sql(const wchar_t * db_field_name, Model & field_model, const FT & field_type); void field_model_clear_values(Model & field_model); - void field_model_read_values_from_queryresult(const wchar_t * db_field_name, Model & field_model, FT field_type); - void field_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_model, FT field_type); - void field_model_for_db(const wchar_t * db_field_name, Model & field_model, FT field_type); + void field_model_read_values_from_queryresult(const wchar_t * db_field_name, Model & field_model, const FT & field_type); + void field_model(const wchar_t * db_field_name, const wchar_t * flat_field_name, Model & field_model, const FT & field_type); + void field_model_for_db(const wchar_t * db_field_name, Model & field_model, const FT & field_type); template @@ -709,7 +709,7 @@ protected: template - void field_list_generate_flat_string(const wchar_t * flat_field_name, ModelContainer & field_container, FT field_type) + void field_list_generate_flat_string(const wchar_t * flat_field_name, ModelContainer & field_container, const FT & field_type) { FlatConnector * flat_connector = model_connector->get_flat_connector(); @@ -738,7 +738,7 @@ protected: template - void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelContainer & field_container, ModelContainerType * model_container_type, FT field_type) + void field_list(const wchar_t * db_field_name, const wchar_t * flat_field_name, ModelContainer & field_container, ModelContainerType * model_container_type, const FT & field_type) { if( model_connector && model_env ) { @@ -809,7 +809,7 @@ protected: template - void get_value_by_field_index(int field_index, FieldValue & field_value, FT field_type) + void get_value_by_field_index(int field_index, FieldValue & field_value, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); @@ -836,7 +836,7 @@ protected: template - void get_value_by_field_name(const wchar_t * field_name, FieldValue & field_value, FT field_type) + void get_value_by_field_name(const wchar_t * field_name, FieldValue & field_value, const FT & field_type) { DbConnector * db_connector = model_connector->get_db_connector(); diff --git a/src/postgresqlexpression.cpp b/src/postgresqlexpression.cpp index 392c0b7..90b9cf8 100644 --- a/src/postgresqlexpression.cpp +++ b/src/postgresqlexpression.cpp @@ -77,7 +77,7 @@ void PostgreSQLExpression::after_second_part_long_field_name() -void PostgreSQLExpression::before_field_value_string(FT field_type) +void PostgreSQLExpression::before_field_value_string(const FT & field_type) { if( field_type.is_binary() ) { @@ -94,14 +94,14 @@ void PostgreSQLExpression::before_field_value_string(FT field_type) } } -void PostgreSQLExpression::after_field_value_string(FT field_type) +void PostgreSQLExpression::after_field_value_string(const FT & field_type) { (*out_stream) << "'"; } -void PostgreSQLExpression::esc(char val, PT::TextStream & stream, FT field_type) +void PostgreSQLExpression::esc(char val, PT::TextStream & stream, const FT & field_type) { if( field_type.is_hexadecimal() || field_type.is_binary() ) { @@ -123,7 +123,7 @@ void PostgreSQLExpression::esc(char val, PT::TextStream & stream, FT field_type) } -void PostgreSQLExpression::esc(const PT::Date & date, PT::TextStream & stream, FT field_type) +void PostgreSQLExpression::esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type) { stream << date << "+00"; } diff --git a/src/postgresqlexpression.h b/src/postgresqlexpression.h index 3be9a23..fc76a1a 100644 --- a/src/postgresqlexpression.h +++ b/src/postgresqlexpression.h @@ -45,8 +45,8 @@ class PostgreSQLExpression : public DbExpression { public: - void esc(char val, PT::TextStream & stream, FT field_type); - void esc(const PT::Date & date, PT::TextStream & stream, FT field_type); + void esc(char val, PT::TextStream & stream, const FT & field_type); + void esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type); DbExpression & page(PT::TextStream & stream, size_t page_number, size_t page_size); @@ -64,8 +64,8 @@ protected: private: - void before_field_value_string(FT field_type); - void after_field_value_string(FT field_type); + void before_field_value_string(const FT & field_type); + void after_field_value_string(const FT & field_type); };