diff --git a/samples/attachment.h b/samples/attachment.h index a247ab1..ca8e256 100644 --- a/samples/attachment.h +++ b/samples/attachment.h @@ -71,7 +71,7 @@ public: std::string content; std::vector types; bool some_flags; - PT::Date created_date; + pt::Date created_date; Language language; diff --git a/samples/attachment2.h b/samples/attachment2.h index 2548060..6961707 100644 --- a/samples/attachment2.h +++ b/samples/attachment2.h @@ -71,7 +71,7 @@ public: std::string content; std::vector types; bool some_flags; - PT::Date created_date; + pt::Date created_date; Language language; diff --git a/samples/main.cpp b/samples/main.cpp index 413aa3b..063199e 100644 --- a/samples/main.cpp +++ b/samples/main.cpp @@ -61,17 +61,17 @@ void print_syntax() int main(int argc, const char ** argv) { -PT::Space args; -PT::Space & args_options = args.FindAddSpace(L"options"); +pt::Space args; +pt::Space & args_options = args.FindAddSpace(L"options"); args_options.Add(L"c", 1); // one argument - config file args_options.Add(L"config", 1); - PT::MainSpaceParser main_parser; + pt::MainSpaceParser main_parser; main_parser.UTF8(true); main_parser.SetSpace(args); - PT::MainSpaceParser::Status args_status = main_parser.Parse(argc, argv); + pt::MainSpaceParser::Status args_status = main_parser.Parse(argc, argv); - if( args_status != PT::MainSpaceParser::status_ok ) + if( args_status != pt::MainSpaceParser::status_ok ) { std::cout << "Syntax error in arguments" << std::endl; return 1; @@ -101,9 +101,9 @@ args_options.Add(L"config", 1); * create database morm_test owner morm_test; * */ - PT::Log log; - PT::FileLog file_log; - PT::WTextStream log_buffer; + pt::Log log; + pt::FileLog file_log; + pt::WTextStream log_buffer; file_log.init(L"log.txt", true, 4, true); log.SetLogBuffer(&log_buffer); diff --git a/src/baseexpression.cpp b/src/baseexpression.cpp index c14a81b..d93a4f9 100644 --- a/src/baseexpression.cpp +++ b/src/baseexpression.cpp @@ -74,12 +74,12 @@ int BaseExpression::get_work_mode() -PT::TextStream * BaseExpression::get_text_stream() +pt::TextStream * BaseExpression::get_text_stream() { return out_stream; } -void BaseExpression::set_text_stream(PT::TextStream * out_stream) +void BaseExpression::set_text_stream(pt::TextStream * out_stream) { this->out_stream = out_stream; } @@ -88,7 +88,7 @@ void BaseExpression::set_text_stream(PT::TextStream * out_stream) -PT::TextStream * BaseExpression::get_current_stream() +pt::TextStream * BaseExpression::get_current_stream() { return out_stream; } @@ -107,7 +107,7 @@ bool BaseExpression::get_allow_to_use_prefix() -void BaseExpression::generate_from_model(PT::TextStream & stream, Model & model) +void BaseExpression::generate_from_model(pt::TextStream & stream, Model & model) { this->out_stream = &stream; generate_from_model(model); @@ -208,8 +208,8 @@ void BaseExpression::put_field_name(const wchar_t * field_name, const FT & field 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; + pt::TextStream str; + pt::TextStream * old_out_stream = out_stream; out_stream = &str; put_field_name(field_name, field_type, model_env); @@ -337,22 +337,22 @@ void BaseExpression::after_field_value(char, const FT & field_type) after_field_value_string(field_type); } -void BaseExpression::before_field_value(const PT::Date &, const 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 &, const 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 &, const 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 &, const FT & field_type) +void BaseExpression::after_field_value(const pt::Space &, const FT & field_type) { after_field_value_string(field_type); } @@ -373,7 +373,7 @@ char BaseExpression::char_to_hex_part(char c) } -void BaseExpression::char_to_hex(char c, PT::TextStream & stream) +void BaseExpression::char_to_hex(char c, pt::TextStream & stream) { stream << char_to_hex_part(((unsigned char)c) >> 4); stream << char_to_hex_part(((unsigned char)c) & 0x0f); @@ -382,7 +382,7 @@ void BaseExpression::char_to_hex(char c, PT::TextStream & stream) -void BaseExpression::esc(char val, PT::TextStream & stream, const FT & field_type) +void BaseExpression::esc(char val, pt::TextStream & stream, const FT & field_type) { if( field_type.is_binary() || field_type.is_hexadecimal() ) { @@ -395,19 +395,19 @@ void BaseExpression::esc(char val, PT::TextStream & stream, const FT & field_typ } -void BaseExpression::esc(unsigned char val, PT::TextStream & stream, const 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, const FT & field_type) +void BaseExpression::esc(wchar_t val, pt::TextStream & stream, const FT & field_type) { if( field_type.use_utf8() ) { char utf8_buf[10]; - size_t utf8_len = PT::IntToUTF8((int)val, utf8_buf, sizeof(utf8_buf)); + size_t utf8_len = pt::IntToUTF8((int)val, utf8_buf, sizeof(utf8_buf)); for(size_t a = 0 ; a < utf8_len ; ++a) { @@ -421,7 +421,7 @@ void BaseExpression::esc(wchar_t val, PT::TextStream & stream, const FT & field_ } -void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, const 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() ) { @@ -429,7 +429,7 @@ void BaseExpression::esc(const wchar_t * val, bool has_known_length, size_t len, for(size_t i = 0 ; has_known_length ? (i < len) : val[i] != 0 ; ++i) { - size_t utf8_len = PT::IntToUTF8((int)val[i], utf8_buf, sizeof(utf8_buf)); + size_t utf8_len = pt::IntToUTF8((int)val[i], utf8_buf, sizeof(utf8_buf)); for(size_t a = 0 ; a < utf8_len ; ++a) { @@ -447,19 +447,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, const 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, const 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, const 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) { @@ -468,7 +468,7 @@ void BaseExpression::esc(const std::string & val, PT::TextStream & stream, const } -void BaseExpression::esc(const char * val, PT::TextStream & stream, const 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) { @@ -477,7 +477,7 @@ void BaseExpression::esc(const char * val, PT::TextStream & stream, const FT & f } -void BaseExpression::esc(bool val, PT::TextStream & stream, const FT & field_type) +void BaseExpression::esc(bool val, pt::TextStream & stream, const FT & field_type) { if( val ) stream << "true"; @@ -486,82 +486,82 @@ void BaseExpression::esc(bool val, PT::TextStream & stream, const FT & field_typ } -void BaseExpression::esc(short val, PT::TextStream & stream, const 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, const 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, const 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, const 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, const 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, const 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, const FT & field_type) +void BaseExpression::esc(long long val, pt::TextStream & stream, const FT & field_type) { - // not implemented in PT::TextStream yet + // not implemented in pt::TextStream yet //stream << val; } -void BaseExpression::esc(unsigned long long val, PT::TextStream & stream, const 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, const 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, const 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, const FT & field_type) +void BaseExpression::esc(long double val, pt::TextStream & stream, const FT & field_type) { - // IMPLEMENT ME in PT::TextStream + // IMPLEMENT ME in pt::TextStream //stream << val; } -void BaseExpression::esc(const PT::Date & date, PT::TextStream & stream, const 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, const FT & field_type) +void BaseExpression::esc(const pt::TextStream & val, pt::TextStream & stream, const FT & field_type) { - PT::TextStream::const_iterator i = val.begin(); + pt::TextStream::const_iterator i = val.begin(); for(; i != val.end() ; ++i) { @@ -569,9 +569,9 @@ void BaseExpression::esc(const PT::TextStream & val, PT::TextStream & stream, co } } -void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, const FT & field_type) +void BaseExpression::esc(const pt::WTextStream & val, pt::TextStream & stream, const FT & field_type) { - PT::WTextStream::const_iterator i = val.begin(); + pt::WTextStream::const_iterator i = val.begin(); for(; i != val.end() ; ++i) { @@ -579,119 +579,119 @@ void BaseExpression::esc(const PT::WTextStream & val, PT::TextStream & stream, c } } -void BaseExpression::esc(const PT::Space & space, PT::TextStream & stream, const FT & field_type) +void BaseExpression::esc(const pt::Space & space, pt::TextStream & stream, const FT & field_type) { - PT::WTextStream tmp_stream; + pt::WTextStream tmp_stream; space.serialize_to_space_stream(tmp_stream, true); esc(tmp_stream, stream, field_type); } -//void BaseExpression::put_type(char val, PT::TextStream & stream) +//void BaseExpression::put_type(char val, pt::TextStream & stream) //{ // stream << "char"; //} // -//void BaseExpression::put_type(unsigned char val, PT::TextStream & stream) +//void BaseExpression::put_type(unsigned char val, pt::TextStream & stream) //{ // stream << "unsigned char"; //} // // -//void BaseExpression::put_type(const std::wstring & val, PT::TextStream & stream) +//void BaseExpression::put_type(const std::wstring & val, pt::TextStream & stream) //{ // stream << "text"; //} // -//void BaseExpression::put_type(const wchar_t * val, PT::TextStream & stream) +//void BaseExpression::put_type(const wchar_t * val, pt::TextStream & stream) //{ // stream << "text"; //} // // -//void BaseExpression::put_type(const std::string & val, PT::TextStream & stream) +//void BaseExpression::put_type(const std::string & val, pt::TextStream & stream) //{ // stream << "text"; //} // -//void BaseExpression::put_type(const char * val, PT::TextStream & stream) +//void BaseExpression::put_type(const char * val, pt::TextStream & stream) //{ // stream << "text"; //} // // -//void BaseExpression::put_type(bool val, PT::TextStream & stream) +//void BaseExpression::put_type(bool val, pt::TextStream & stream) //{ // stream << "boolean"; //} // -//void BaseExpression::put_type(short val, PT::TextStream & stream) +//void BaseExpression::put_type(short val, pt::TextStream & stream) //{ // stream << "short integer"; //} // -//void BaseExpression::put_type(unsigned short val, PT::TextStream & stream) +//void BaseExpression::put_type(unsigned short val, pt::TextStream & stream) //{ // stream << "unsigned short integer"; //} // -//void BaseExpression::put_type(int val, PT::TextStream & stream) +//void BaseExpression::put_type(int val, pt::TextStream & stream) //{ // stream << "integer"; //} // -//void BaseExpression::put_type(unsigned int val, PT::TextStream & stream) +//void BaseExpression::put_type(unsigned int val, pt::TextStream & stream) //{ // stream << "unsigned integer"; //} // -//void BaseExpression::put_type(long val, PT::TextStream & stream) +//void BaseExpression::put_type(long val, pt::TextStream & stream) //{ // stream << "long integer"; //} // -//void BaseExpression::put_type(unsigned long val, PT::TextStream & stream) +//void BaseExpression::put_type(unsigned long val, pt::TextStream & stream) //{ // stream << "unsigned long integer"; //} // -//void BaseExpression::put_type(long long val, PT::TextStream & stream) +//void BaseExpression::put_type(long long val, pt::TextStream & stream) //{ // stream << "very long integer"; //} // -//void BaseExpression::put_type(unsigned long long val, PT::TextStream & stream) +//void BaseExpression::put_type(unsigned long long val, pt::TextStream & stream) //{ // stream << "unsigned very long integer"; //} // -//void BaseExpression::put_type(float val, PT::TextStream & stream) +//void BaseExpression::put_type(float val, pt::TextStream & stream) //{ // stream << "float"; //} // -//void BaseExpression::put_type(double val, PT::TextStream & stream) +//void BaseExpression::put_type(double val, pt::TextStream & stream) //{ // stream << "double"; //} // -//void BaseExpression::put_type(long double val, PT::TextStream & stream) +//void BaseExpression::put_type(long double val, pt::TextStream & stream) //{ // stream << "long double"; //} // -////void BaseExpression::put_type(void* val, PT::TextStream & stream) +////void BaseExpression::put_type(void* val, pt::TextStream & stream) ////{ ////} // // -//void BaseExpression::put_type(const PT::Date & date, PT::TextStream & stream) +//void BaseExpression::put_type(const pt::Date & date, pt::TextStream & stream) //{ // stream << "date"; //} // -//void BaseExpression::put_type(const Model & model, PT::TextStream & stream) +//void BaseExpression::put_type(const Model & model, pt::TextStream & stream) //{ // stream << "object"; //} @@ -740,7 +740,7 @@ void BaseExpression::put_schema_table(const wchar_t * schema_name, const wchar_t /* * schema_name can be empty - in such a case we do not put the schema name */ -void BaseExpression::put_schema_table(const PT::WTextStream & schema_name, const PT::WTextStream & table_name) +void BaseExpression::put_schema_table(const pt::WTextStream & schema_name, const pt::WTextStream & table_name) { if( out_stream ) { @@ -778,7 +778,7 @@ void BaseExpression::put_table(const wchar_t * table_name) } -void BaseExpression::put_table(const PT::WTextStream & table_name) +void BaseExpression::put_table(const pt::WTextStream & table_name) { if( out_stream ) { @@ -806,7 +806,7 @@ void BaseExpression::put_table_with_index(const wchar_t * table_name, int index) } -void BaseExpression::put_table_with_index(const PT::WTextStream & table_name, int index) +void BaseExpression::put_table_with_index(const pt::WTextStream & table_name, int index) { if( out_stream ) { @@ -833,7 +833,7 @@ void BaseExpression::put_table_with_index_and_field(const wchar_t * table_name, } } -void BaseExpression::put_table_with_index_and_field(const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type) +void BaseExpression::put_table_with_index_and_field(const pt::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type) { if( out_stream ) { @@ -854,7 +854,7 @@ void BaseExpression::put_table_and_field(const wchar_t * table_name, const wchar } } -void BaseExpression::put_table_and_field(const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type) +void BaseExpression::put_table_and_field(const pt::WTextStream & table_name, const wchar_t * field_name, const FT & field_type) { if( out_stream ) { @@ -866,7 +866,7 @@ void BaseExpression::put_table_and_field(const PT::WTextStream & table_name, con -void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name) +void BaseExpression::schema_table_to_stream(pt::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name) { this->out_stream = &stream; put_schema_table(schema_name, table_name); @@ -874,7 +874,7 @@ void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const wchar } -void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const PT::WTextStream & schema_name, const PT::WTextStream & table_name) +void BaseExpression::schema_table_to_stream(pt::TextStream & stream, const pt::WTextStream & schema_name, const pt::WTextStream & table_name) { this->out_stream = &stream; put_schema_table(schema_name, table_name); @@ -882,7 +882,7 @@ void BaseExpression::schema_table_to_stream(PT::TextStream & stream, const PT::W } -void BaseExpression::table_to_stream(PT::TextStream & stream, const wchar_t * table_name) +void BaseExpression::table_to_stream(pt::TextStream & stream, const wchar_t * table_name) { this->out_stream = &stream; put_table(table_name); @@ -890,7 +890,7 @@ void BaseExpression::table_to_stream(PT::TextStream & stream, const wchar_t * ta } -void BaseExpression::table_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name) +void BaseExpression::table_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name) { this->out_stream = &stream; put_table(table_name); @@ -898,7 +898,7 @@ void BaseExpression::table_to_stream(PT::TextStream & stream, const PT::WTextStr } -void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index) +void BaseExpression::table_with_index_to_stream(pt::TextStream & stream, const wchar_t * table_name, int index) { this->out_stream = &stream; put_table_with_index(table_name, index); @@ -906,7 +906,7 @@ void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const w } -void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index) +void BaseExpression::table_with_index_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, int index) { this->out_stream = &stream; put_table_with_index(table_name, index); @@ -914,7 +914,7 @@ void BaseExpression::table_with_index_to_stream(PT::TextStream & stream, const P } -void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type) +void BaseExpression::table_with_index_and_field_to_stream(pt::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type) { this->out_stream = &stream; put_table_with_index_and_field(table_name, index, field_name, field_type); @@ -922,7 +922,7 @@ void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & strea } -void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type) +void BaseExpression::table_with_index_and_field_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type) { this->out_stream = &stream; put_table_with_index_and_field(table_name, index, field_name, field_type); @@ -930,7 +930,7 @@ void BaseExpression::table_with_index_and_field_to_stream(PT::TextStream & strea } -void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type) +void BaseExpression::table_and_field_to_stream(pt::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type) { this->out_stream = &stream; put_table_and_field(table_name, field_name, field_type); @@ -938,7 +938,7 @@ void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const wc } -void BaseExpression::table_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type) +void BaseExpression::table_and_field_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, const wchar_t * field_name, const FT & field_type) { this->out_stream = &stream; put_table_and_field(table_name, field_name, field_type); diff --git a/src/baseexpression.h b/src/baseexpression.h index d29f2d8..c702422 100644 --- a/src/baseexpression.h +++ b/src/baseexpression.h @@ -60,14 +60,14 @@ public: virtual void set_work_mode(int work_mode); virtual int get_work_mode(); - virtual PT::TextStream * get_text_stream(); - virtual void set_text_stream(PT::TextStream * out_stream); + virtual pt::TextStream * get_text_stream(); + virtual void set_text_stream(pt::TextStream * out_stream); virtual void clear(); - virtual void generate_from_model(PT::TextStream & stream, Model & model); + virtual void generate_from_model(pt::TextStream & stream, Model & model); - virtual PT::TextStream * get_current_stream(); + virtual pt::TextStream * get_current_stream(); // rename me virtual void allow_to_use_prefix(bool use_prefix); @@ -143,21 +143,21 @@ public: } template - void field_in(PT::TextStream & stream, const wchar_t * field_name, const std::set & container, ModelEnv * model_env) + void field_in(pt::TextStream & stream, const wchar_t * field_name, const std::set & container, ModelEnv * model_env) { field_in_generic>(stream, field_name, container, model_env); } template - void field_in(PT::TextStream & stream, const wchar_t * field_name, const std::list & container, ModelEnv * model_env) + void field_in(pt::TextStream & stream, const wchar_t * field_name, const std::list & container, ModelEnv * model_env) { field_in_generic>(stream, field_name, container, model_env); } template - void field_in(PT::TextStream & stream, const wchar_t * field_name, const std::vector & container, ModelEnv * model_env) + void field_in(pt::TextStream & stream, const wchar_t * field_name, const std::vector & container, ModelEnv * model_env) { field_in_generic>(stream, field_name, container, model_env); } @@ -215,7 +215,7 @@ public: } template - void field_to_stream(PT::TextStream & stream, const wchar_t * field_name, const FieldValue & field_value, const 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); @@ -224,26 +224,26 @@ public: virtual void put_schema_table(const wchar_t * schema_name, const wchar_t * table_name); - virtual void put_schema_table(const PT::WTextStream & schema_name, const PT::WTextStream & table_name); + virtual void put_schema_table(const pt::WTextStream & schema_name, const pt::WTextStream & table_name); virtual void put_table(const wchar_t * table_name); - virtual void put_table(const PT::WTextStream & table_name); + virtual void put_table(const pt::WTextStream & table_name); virtual void put_table_with_index(const wchar_t * table_name, int index); - virtual void put_table_with_index(const PT::WTextStream & table_name, int index); + virtual void put_table_with_index(const pt::WTextStream & table_name, int index); virtual void put_table_with_index_and_field(const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type); - virtual void put_table_with_index_and_field(const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type); + virtual void put_table_with_index_and_field(const pt::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type); virtual void put_table_and_field(const wchar_t * table_name, const wchar_t * field_name, const FT & field_type); - virtual void put_table_and_field(const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type); + virtual void put_table_and_field(const pt::WTextStream & table_name, const wchar_t * field_name, const FT & field_type); - virtual void schema_table_to_stream(PT::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name); - virtual void schema_table_to_stream(PT::TextStream & stream, const PT::WTextStream & schema_name, const PT::WTextStream & table_name); - virtual void table_to_stream(PT::TextStream & stream, const wchar_t * table_name); - virtual void table_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name); - virtual void table_with_index_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index); - virtual void table_with_index_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index); - virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type); - virtual void table_with_index_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type); - virtual void table_and_field_to_stream(PT::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type); - virtual void table_and_field_to_stream(PT::TextStream & stream, const PT::WTextStream & table_name, const wchar_t * field_name, const FT & field_type); + virtual void schema_table_to_stream(pt::TextStream & stream, const wchar_t * schema_name, const wchar_t * table_name); + virtual void schema_table_to_stream(pt::TextStream & stream, const pt::WTextStream & schema_name, const pt::WTextStream & table_name); + virtual void table_to_stream(pt::TextStream & stream, const wchar_t * table_name); + virtual void table_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name); + virtual void table_with_index_to_stream(pt::TextStream & stream, const wchar_t * table_name, int index); + virtual void table_with_index_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, int index); + virtual void table_with_index_and_field_to_stream(pt::TextStream & stream, const wchar_t * table_name, int index, const wchar_t * field_name, const FT & field_type); + virtual void table_with_index_and_field_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, int index, const wchar_t * field_name, const FT & field_type); + virtual void table_and_field_to_stream(pt::TextStream & stream, const wchar_t * table_name, const wchar_t * field_name, const FT & field_type); + virtual void table_and_field_to_stream(pt::TextStream & stream, const pt::WTextStream & table_name, const wchar_t * field_name, const FT & field_type); /* @@ -251,35 +251,35 @@ public: * esc for: signed char, wchar_t, char16_t, char32_t * */ - 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(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, const 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, 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::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, 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(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, 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(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, 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 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); @@ -288,7 +288,7 @@ protected: int work_mode; /* what to do: generating fields list, values list or fields-values list */ bool is_first_field; - PT::TextStream * out_stream; + pt::TextStream * out_stream; bool use_prefix; @@ -485,7 +485,7 @@ protected: put_field_value_list_non_model(field_value, model_connector); } - void put_field_value_list(std::vector & field_value, ModelConnector * model_connector, ModelEnv *) + void put_field_value_list(std::vector & field_value, ModelConnector * model_connector, ModelEnv *) { put_field_value_list_non_model(field_value, model_connector); } @@ -574,7 +574,7 @@ protected: put_field_value_list_non_model(field_value, model_connector); } - void put_field_value_list(std::list & field_value, ModelConnector * model_connector, ModelEnv *) + void put_field_value_list(std::list & field_value, ModelConnector * model_connector, ModelEnv *) { put_field_value_list_non_model(field_value, model_connector); } @@ -583,7 +583,7 @@ protected: // used in 'in()' statements, may should be renamed? template - void field_in_generic(PT::TextStream & stream, const wchar_t * field_name, const Container & container, ModelEnv * model_env) + void field_in_generic(pt::TextStream & stream, const wchar_t * field_name, const Container & container, ModelEnv * model_env) { // IMPROVE ME // what about if container is empty? @@ -645,11 +645,11 @@ protected: 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 &, const FT & field_type); - virtual void after_field_value(const PT::Date &, const 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 &, const FT & field_type); - virtual void after_field_value(const PT::Space &, const 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 &, const FT & field_type) @@ -669,40 +669,40 @@ protected: * put_type for: signed char, wchar_t, char16_t, char32_t * */ -// virtual void put_type(char val, PT::TextStream & stream); -// virtual void put_type(unsigned char val, PT::TextStream & stream); +// virtual void put_type(char val, pt::TextStream & stream); +// virtual void put_type(unsigned char val, pt::TextStream & stream); // -// virtual void put_type(const std::wstring & val, PT::TextStream & stream); -// virtual void put_type(const wchar_t * val, PT::TextStream & stream); +// virtual void put_type(const std::wstring & val, pt::TextStream & stream); +// virtual void put_type(const wchar_t * val, pt::TextStream & stream); // -// virtual void put_type(const std::string & val, PT::TextStream & stream); -// virtual void put_type(const char * val, PT::TextStream & stream); +// virtual void put_type(const std::string & val, pt::TextStream & stream); +// virtual void put_type(const char * val, pt::TextStream & stream); // -// virtual void put_type(bool val, PT::TextStream & stream); -// virtual void put_type(short val, PT::TextStream & stream); -// virtual void put_type(unsigned short val, PT::TextStream & stream); -// virtual void put_type(int val, PT::TextStream & stream); -// virtual void put_type(unsigned int val, PT::TextStream & stream); -// virtual void put_type(long val, PT::TextStream & stream); -// virtual void put_type(unsigned long val, PT::TextStream & stream); -// virtual void put_type(long long val, PT::TextStream & stream); -// virtual void put_type(unsigned long long val, PT::TextStream & stream); -// virtual void put_type(float val, PT::TextStream & stream); -// virtual void put_type(double val, PT::TextStream & stream); -// virtual void put_type(long double val, PT::TextStream & stream); - //virtual void put_type(void* val, PT::TextStream & stream); +// virtual void put_type(bool val, pt::TextStream & stream); +// virtual void put_type(short val, pt::TextStream & stream); +// virtual void put_type(unsigned short val, pt::TextStream & stream); +// virtual void put_type(int val, pt::TextStream & stream); +// virtual void put_type(unsigned int val, pt::TextStream & stream); +// virtual void put_type(long val, pt::TextStream & stream); +// virtual void put_type(unsigned long val, pt::TextStream & stream); +// virtual void put_type(long long val, pt::TextStream & stream); +// virtual void put_type(unsigned long long val, pt::TextStream & stream); +// virtual void put_type(float val, pt::TextStream & stream); +// virtual void put_type(double val, pt::TextStream & stream); +// virtual void put_type(long double val, pt::TextStream & stream); + //virtual void put_type(void* val, pt::TextStream & stream); -// virtual void put_type(const PT::Date & date, PT::TextStream & stream); -// virtual void put_type(const Model & model, PT::TextStream & stream); +// virtual void put_type(const pt::Date & date, pt::TextStream & stream); +// virtual void put_type(const Model & model, pt::TextStream & stream); // // template -// void put_type(const std::list & model, PT::TextStream & stream) +// void put_type(const std::list & model, pt::TextStream & stream) // { // stream << "table"; // may just use std::list? // } // // template -// void put_type(const std::vector & model, PT::TextStream & stream) +// void put_type(const std::vector & model, pt::TextStream & stream) // { // stream << "table"; // may just just std::vector? // } @@ -713,9 +713,9 @@ protected: 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 char_to_hex(char c, pt::TextStream & stream); - void esc(const wchar_t * val, bool has_known_length, size_t len, PT::TextStream & stream, const 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); bool is_empty_field(const wchar_t * value); }; diff --git a/src/clearer.cpp b/src/clearer.cpp index 53b2381..97a2270 100644 --- a/src/clearer.cpp +++ b/src/clearer.cpp @@ -138,12 +138,12 @@ void Clearer::clear_value(long double & field_value) field_value = 0.0; } -void Clearer::clear_value(PT::Date & field_value) +void Clearer::clear_value(pt::Date & field_value) { field_value.Clear(); } -void Clearer::clear_value(PT::Space & field_value) +void Clearer::clear_value(pt::Space & field_value) { field_value.clear(); } diff --git a/src/clearer.h b/src/clearer.h index d6ab824..5427de2 100644 --- a/src/clearer.h +++ b/src/clearer.h @@ -69,8 +69,8 @@ public: virtual void clear_value(float & field_value); virtual void clear_value(double & field_value); virtual void clear_value(long double & field_value); - virtual void clear_value(PT::Date & field_value); - virtual void clear_value(PT::Space & field_value); + virtual void clear_value(pt::Date & field_value); + virtual void clear_value(pt::Space & field_value); virtual void clear_model(Model & field_value); diff --git a/src/dbconnector.cpp b/src/dbconnector.cpp index 12da18b..b39f8be 100644 --- a/src/dbconnector.cpp +++ b/src/dbconnector.cpp @@ -67,13 +67,13 @@ DbConnector::~DbConnector() } -void DbConnector::set_logger(PT::Log * log) +void DbConnector::set_logger(pt::Log * log) { this->log = log; } -void DbConnector::set_logger(PT::Log & log) +void DbConnector::set_logger(pt::Log & log) { this->log = &log; } @@ -85,7 +85,7 @@ void DbConnector::set_log_queries(bool log_queries) } -bool DbConnector::query(const PT::TextStream & stream) +bool DbConnector::query(const pt::TextStream & stream) { std::unique_ptr query_result_ptr(create_query_result()); return query(stream, *query_result_ptr); @@ -107,7 +107,7 @@ bool DbConnector::query(const char * query_str) -bool DbConnector::query(const PT::TextStream & stream, QueryResult & query_result) +bool DbConnector::query(const pt::TextStream & stream, QueryResult & query_result) { std::string query_str; stream.to_string(query_str); @@ -152,22 +152,22 @@ bool DbConnector::query_remove(const char * query_str, QueryResult & query_resul -bool DbConnector::query_select(const PT::TextStream & stream, QueryResult & query_result) +bool DbConnector::query_select(const pt::TextStream & stream, QueryResult & query_result) { return query(stream, query_result); } -bool DbConnector::query_update(const PT::TextStream & stream, QueryResult & query_result) +bool DbConnector::query_update(const pt::TextStream & stream, QueryResult & query_result) { return query(stream, query_result); } -bool DbConnector::query_insert(const PT::TextStream & stream, QueryResult & query_result) +bool DbConnector::query_insert(const pt::TextStream & stream, QueryResult & query_result) { return query(stream, query_result); } -bool DbConnector::query_remove(const PT::TextStream & stream, QueryResult & query_result) +bool DbConnector::query_remove(const pt::TextStream & stream, QueryResult & query_result) { return query(stream, query_result); } @@ -181,7 +181,7 @@ DbExpression * DbConnector::get_expression() } -void DbConnector::generate_select_columns(PT::TextStream & stream, Model & model) +void DbConnector::generate_select_columns(pt::TextStream & stream, Model & model) { allocate_default_expression_if_needed(); @@ -196,7 +196,7 @@ void DbConnector::generate_select_columns(PT::TextStream & stream, Model & model } -void DbConnector::generate_insert_query(PT::TextStream & stream, Model & model) +void DbConnector::generate_insert_query(pt::TextStream & stream, Model & model) { allocate_default_expression_if_needed(); @@ -221,7 +221,7 @@ void DbConnector::generate_insert_query(PT::TextStream & stream, Model & model) } -void DbConnector::generate_update_query(PT::TextStream & stream, Model & model) +void DbConnector::generate_update_query(pt::TextStream & stream, Model & model) { allocate_default_expression_if_needed(); @@ -246,7 +246,7 @@ void DbConnector::generate_update_query(PT::TextStream & stream, Model & model) } -void DbConnector::generate_remove_query(PT::TextStream & stream, Model & model) +void DbConnector::generate_remove_query(pt::TextStream & stream, Model & model) { allocate_default_expression_if_needed(); @@ -265,7 +265,7 @@ void DbConnector::generate_remove_query(PT::TextStream & stream, Model & model) } } -bool DbConnector::insert(PT::TextStream & stream, Model & model) +bool DbConnector::insert(pt::TextStream & stream, Model & model) { std::unique_ptr query_result_ptr(create_query_result()); @@ -274,7 +274,7 @@ bool DbConnector::insert(PT::TextStream & stream, Model & model) } -bool DbConnector::update(PT::TextStream & stream, Model & model) +bool DbConnector::update(pt::TextStream & stream, Model & model) { std::unique_ptr query_result_ptr(create_query_result()); @@ -283,7 +283,7 @@ bool DbConnector::update(PT::TextStream & stream, Model & model) } -bool DbConnector::remove(PT::TextStream & stream, Model & model) +bool DbConnector::remove(pt::TextStream & stream, Model & model) { std::unique_ptr query_result_ptr(create_query_result()); @@ -333,14 +333,14 @@ char DbConnector::unescape_hex_char_part(char hex) { if( log ) { - (*log) << PT::Log::log2 << "Morm: incorrect character when reading a hex string, char code: " << (int)(unsigned char)hex; + (*log) << pt::Log::log2 << "Morm: incorrect character when reading a hex string, char code: " << (int)(unsigned char)hex; if( hex >= 32 ) { (*log) << " '" << hex << "'"; } - (*log) << PT::Log::logend; + (*log) << pt::Log::logend; } } @@ -443,7 +443,7 @@ size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_va int value_int; bool is_correct; - len = PT::UTF8ToInt(utf8_str, utf8_str_len, value_int, is_correct); + len = pt::UTF8ToInt(utf8_str, utf8_str_len, value_int, is_correct); len = len * 2; if( is_correct ) @@ -454,7 +454,7 @@ size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_va { if( log ) { - (*log) << PT::Log::log2 << "Morm: incorrect utf-8 sequence (ignoring)" << PT::Log::logend; + (*log) << pt::Log::log2 << "Morm: incorrect utf-8 sequence (ignoring)" << pt::Log::logend; } } } @@ -469,7 +469,7 @@ size_t DbConnector::unescape_hex_char(const char * value_str, wchar_t & field_va { if( log ) { - (*log) << PT::Log::log2 << "Morm: unexpected end of string (ignoring)" << PT::Log::logend; + (*log) << pt::Log::log2 << "Morm: unexpected end of string (ignoring)" << pt::Log::logend; } } } @@ -503,8 +503,8 @@ void DbConnector::get_value(const char * value_str, char & field_value, const FT { if( log ) { - (*log) << PT::Log::log2 << "Morm: a character greater than 127 cannot be stored in char type, code point: " - << (int)c << " '" << c << "'" << PT::Log::logend; + (*log) << pt::Log::log2 << "Morm: a character greater than 127 cannot be stored in char type, code point: " + << (int)c << " '" << c << "'" << pt::Log::logend; } } } @@ -548,7 +548,7 @@ void DbConnector::get_value(const char * value_str, wchar_t & field_value, const int value_int; bool is_correct; - PT::UTF8ToInt(value_str, value_int, is_correct); + pt::UTF8ToInt(value_str, value_int, is_correct); if( is_correct ) { @@ -584,7 +584,7 @@ void DbConnector::get_value(const char * value_str, std::wstring & field_value, { if( field_type.use_utf8() ) { - PT::UTF8ToWide(value_str, field_value); + pt::UTF8ToWide(value_str, field_value); } else { @@ -627,56 +627,56 @@ void DbConnector::get_value(const char * value_str, bool & field_value, const FT 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); + field_value = (short)pt::Toi(value_str, 10); } 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); + field_value = (unsigned short)pt::Toui(value_str, 10); } 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); + field_value = pt::Toi(value_str, 10); } 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); + field_value = pt::Toui(value_str, 10); } 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); + field_value = pt::Tol(value_str, 10); } 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); + field_value = pt::Toul(value_str, 10); } 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); + field_value = pt::Toll(value_str, 10); } 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); + field_value = pt::Toull(value_str, 10); } @@ -701,30 +701,30 @@ void DbConnector::get_value(const char * value_str, long double & field_value, c } -void DbConnector::get_value(const char * value_str, PT::Date & field_value, const 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, const FT & field_type) +void DbConnector::get_value(const char * value_str, pt::Space & field_value, const FT & field_type) { field_value.clear(); if( *value_str != '\0' ) { - PT::SpaceParser space_parser; + pt::SpaceParser space_parser; space_parser.SetSpace(field_value); - if( space_parser.ParseSpace(value_str) != PT::SpaceParser::ok ) + if( space_parser.ParseSpace(value_str) != pt::SpaceParser::ok ) { field_value.clear(); if( log ) { - (*log) << PT::Log::log2 << "Morm: I cannot correctly parse the Space struct from the datebase" - << ", the raw string is: " << value_str << PT::Log::logend; + (*log) << pt::Log::log2 << "Morm: I cannot correctly parse the Space struct from the datebase" + << ", the raw string is: " << value_str << pt::Log::logend; } } } diff --git a/src/dbconnector.h b/src/dbconnector.h index a87a896..e4f76e5 100644 --- a/src/dbconnector.h +++ b/src/dbconnector.h @@ -55,29 +55,29 @@ public: DbConnector(const DbConnector &); virtual ~DbConnector(); - virtual void set_logger(PT::Log * log); - virtual void set_logger(PT::Log & log); + virtual void set_logger(pt::Log * log); + virtual void set_logger(pt::Log & log); virtual void set_log_queries(bool log_queries); DbExpression * get_expression(); - virtual void generate_select_columns(PT::TextStream & stream, Model & model); - virtual void generate_insert_query(PT::TextStream & stream, Model & model); - virtual void generate_update_query(PT::TextStream & stream, Model & model); - virtual void generate_remove_query(PT::TextStream & stream, Model & model); + virtual void generate_select_columns(pt::TextStream & stream, Model & model); + virtual void generate_insert_query(pt::TextStream & stream, Model & model); + virtual void generate_update_query(pt::TextStream & stream, Model & model); + virtual void generate_remove_query(pt::TextStream & stream, Model & model); - virtual bool insert(PT::TextStream & stream, Model & model); - virtual bool update(PT::TextStream & stream, Model & model); - virtual bool remove(PT::TextStream & stream, Model & model); + virtual bool insert(pt::TextStream & stream, Model & model); + virtual bool update(pt::TextStream & stream, Model & model); + virtual bool remove(pt::TextStream & stream, Model & model); - virtual bool query(const PT::TextStream & stream); + virtual bool query(const pt::TextStream & stream); virtual bool query(const std::string & query_str); virtual bool query(const char * query_str); virtual QueryResult * create_query_result() = 0; - virtual bool query(const PT::TextStream & stream, QueryResult & query_result); + virtual bool query(const pt::TextStream & stream, QueryResult & query_result); virtual bool query(const std::string & query_str, QueryResult & query_result); virtual bool query(const char * query_str, QueryResult & query_result); @@ -86,10 +86,10 @@ public: virtual bool query_insert(const char * query_str, QueryResult & query_result); virtual bool query_remove(const char * query_str, QueryResult & query_result); - virtual bool query_select(const PT::TextStream & stream, QueryResult & query_result); - virtual bool query_update(const PT::TextStream & stream, QueryResult & query_result); - virtual bool query_insert(const PT::TextStream & stream, QueryResult & query_result); - virtual bool query_remove(const PT::TextStream & stream, QueryResult & query_result); + virtual bool query_select(const pt::TextStream & stream, QueryResult & query_result); + virtual bool query_update(const pt::TextStream & stream, QueryResult & query_result); + 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, 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); @@ -108,10 +108,10 @@ public: 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); + 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 + // add get_value for pt::TextStream and pt::WTextStream template bool get_last_sequence(const wchar_t * sequence_table_name, FieldValue & field_value) @@ -124,7 +124,7 @@ public: if( log && log_queries ) { - (*log) << PT::Log::log3 << "Morm: sequence value: " << field_value << PT::Log::logend; + (*log) << pt::Log::log3 << "Morm: sequence value: " << field_value << pt::Log::logend; } return true; @@ -138,7 +138,7 @@ protected: DbExpression * db_expression; bool expression_allocated; - PT::Log * log; + pt::Log * log; bool log_queries; diff --git a/src/dbexpression.cpp b/src/dbexpression.cpp index c7b08db..ac92a2e 100644 --- a/src/dbexpression.cpp +++ b/src/dbexpression.cpp @@ -251,7 +251,7 @@ void DbExpression::prepare_to_where_clause() } -DbExpression & DbExpression::group_or(PT::TextStream & stream) +DbExpression & DbExpression::group_or(pt::TextStream & stream) { out_stream = &stream; field_before(); @@ -263,7 +263,7 @@ DbExpression & DbExpression::group_or(PT::TextStream & stream) return *this; } -DbExpression & DbExpression::group_and(PT::TextStream & stream) +DbExpression & DbExpression::group_and(pt::TextStream & stream) { out_stream = &stream; field_before(); @@ -275,7 +275,7 @@ DbExpression & DbExpression::group_and(PT::TextStream & stream) return *this; } -DbExpression & DbExpression::group_end(PT::TextStream & stream) +DbExpression & DbExpression::group_end(pt::TextStream & stream) { out_stream = &stream; @@ -291,7 +291,7 @@ DbExpression & DbExpression::group_end(PT::TextStream & stream) } -DbExpression & DbExpression::page(PT::TextStream & stream, size_t page_number, size_t page_size) +DbExpression & DbExpression::page(pt::TextStream & stream, size_t page_number, size_t page_size) { stream << " limit " << page_number << "," << page_size << " "; return *this; diff --git a/src/dbexpression.h b/src/dbexpression.h index 81b1636..0de03ab 100644 --- a/src/dbexpression.h +++ b/src/dbexpression.h @@ -56,11 +56,11 @@ public: virtual void prepare_to_where_clause(); - virtual DbExpression & group_or(PT::TextStream & stream); - virtual DbExpression & group_and(PT::TextStream & stream); - virtual DbExpression & group_end(PT::TextStream & stream); + virtual DbExpression & group_or(pt::TextStream & stream); + virtual DbExpression & group_and(pt::TextStream & stream); + virtual DbExpression & group_end(pt::TextStream & stream); - virtual DbExpression & page(PT::TextStream & stream, size_t page_number, size_t page_size); + 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, const FT & field_type, ModelEnv * model_env) diff --git a/src/finder.h b/src/finder.h index c369da9..e37ebb9 100644 --- a/src/finder.h +++ b/src/finder.h @@ -66,7 +66,7 @@ public: } - Finder(PT::TextStream & out_stream) + Finder(pt::TextStream & out_stream) { this->out_stream = &out_stream; this->model_connector = nullptr; @@ -95,7 +95,7 @@ public: set_out_stream(); } - Finder(PT::TextStream & out_stream, ModelConnector & model_connector) + Finder(pt::TextStream & out_stream, ModelConnector & model_connector) { this->out_stream = &out_stream; this->model_connector = &model_connector; @@ -104,7 +104,7 @@ public: model_data = nullptr; } - Finder(PT::TextStream & out_stream, ModelConnector * model_connector) + Finder(pt::TextStream & out_stream, ModelConnector * model_connector) { this->out_stream = &out_stream; this->model_connector = model_connector; @@ -116,7 +116,7 @@ public: - Finder & set_out_stream(PT::TextStream * out_stream) + Finder & set_out_stream(pt::TextStream * out_stream) { this->out_stream = out_stream; return *this; @@ -204,7 +204,7 @@ public: return select(); } - Finder & select(PT::TextStream & out_stream, ModelConnector & model_connector) + Finder & select(pt::TextStream & out_stream, ModelConnector & model_connector) { this->out_stream = &out_stream; this->model_connector = &model_connector; @@ -213,7 +213,7 @@ public: return select(); } - Finder & select(PT::TextStream & out_stream, ModelConnector * model_connector) + Finder & select(pt::TextStream & out_stream, ModelConnector * model_connector) { this->out_stream = &out_stream; this->model_connector = model_connector; @@ -726,7 +726,7 @@ public: } - Finder & raw(PT::TextStream & sql, bool add_spaces = true) + Finder & raw(pt::TextStream & sql, bool add_spaces = true) { if( out_stream ) { @@ -855,7 +855,7 @@ protected: private: - PT::TextStream * out_stream; + pt::TextStream * out_stream; ModelConnector * model_connector; DbExpression * db_expression; ModelClass model; diff --git a/src/finderhelper.h b/src/finderhelper.h index 7a771ff..b0adf7b 100644 --- a/src/finderhelper.h +++ b/src/finderhelper.h @@ -46,7 +46,7 @@ class FinderHelper { public: - PT::TextStream join_tables_str; + pt::TextStream join_tables_str; std::map join_tables_map; @@ -72,7 +72,7 @@ public: } - virtual int add_join_table(const PT::WTextStream & table_name) + virtual int add_join_table(const pt::WTextStream & table_name) { std::wstring table_name_str; table_name.to_string(table_name_str); diff --git a/src/flatconnector.cpp b/src/flatconnector.cpp index 99bdb7d..2a0d2b8 100644 --- a/src/flatconnector.cpp +++ b/src/flatconnector.cpp @@ -68,7 +68,7 @@ FlatExpression * FlatConnector::get_expression() -void FlatConnector::to_text(PT::TextStream & stream, Model & model) +void FlatConnector::to_text(pt::TextStream & stream, Model & model) { allocate_default_expression_if_needed(); diff --git a/src/flatconnector.h b/src/flatconnector.h index d1e403a..a762b13 100644 --- a/src/flatconnector.h +++ b/src/flatconnector.h @@ -51,7 +51,7 @@ public: FlatConnector(); virtual ~FlatConnector(); - virtual void to_text(PT::TextStream & stream, Model & model); + virtual void to_text(pt::TextStream & stream, Model & model); virtual void set_expression(FlatExpression & expression); virtual FlatExpression * get_expression(); diff --git a/src/flatexpression.cpp b/src/flatexpression.cpp index 884604a..7a14d87 100644 --- a/src/flatexpression.cpp +++ b/src/flatexpression.cpp @@ -39,7 +39,7 @@ namespace morm { -void FlatExpression::esc(const PT::Date & date, PT::TextStream & stream, const 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 87e362e..075a14e 100644 --- a/src/flatexpression.h +++ b/src/flatexpression.h @@ -45,7 +45,7 @@ class FlatExpression : public BaseExpression { public: - void esc(const PT::Date & date, PT::TextStream & stream, const 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 6648df0..9b1db1b 100644 --- a/src/jsonexpression.cpp +++ b/src/jsonexpression.cpp @@ -117,7 +117,7 @@ void JSONExpression::after_field_value_list() } -void JSONExpression::esc(char val, PT::TextStream & stream, const FT & field_type) +void JSONExpression::esc(char val, pt::TextStream & stream, const FT & field_type) { if( field_type.is_hexadecimal() || field_type.is_binary() ) { @@ -129,7 +129,7 @@ void JSONExpression::esc(char val, PT::TextStream & stream, const FT & field_typ { char buf[10]; size_t len; - PT::Toa((unsigned char)val, buf, sizeof(buf)/sizeof(char), 16, &len); + pt::Toa((unsigned char)val, buf, sizeof(buf)/sizeof(char), 16, &len); stream << "\\u"; diff --git a/src/jsonexpression.h b/src/jsonexpression.h index 3ef6ab8..ebc78ca 100644 --- a/src/jsonexpression.h +++ b/src/jsonexpression.h @@ -66,7 +66,7 @@ protected: // 'morm::JSONExpression::esc' hides overloaded virtual function [-Woverloaded-virtual] using FlatExpression::esc; - void esc(char val, PT::TextStream & stream, const FT & field_type); + void esc(char val, pt::TextStream & stream, const FT & field_type); private: diff --git a/src/model.cpp b/src/model.cpp index d424819..c44bbac 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -132,11 +132,11 @@ void Model::table() { if( model_connector ) { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( plog ) { - (*plog) << PT::Log::log1 << "Morm: you should provide the table name e.g. provide table() method and call table(...) there" << PT::Log::logend; + (*plog) << pt::Log::log1 << "Morm: you should provide the table name e.g. provide table() method and call table(...) there" << pt::Log::logend; } } } @@ -178,7 +178,7 @@ bool Model::found() } -void Model::get_table_name(PT::WTextStream & stream, bool with_schema_name, ModelData * model_data, bool clear_stream) +void Model::get_table_name(pt::WTextStream & stream, bool with_schema_name, ModelData * model_data, bool clear_stream) { if( clear_stream ) { @@ -221,7 +221,7 @@ void Model::get_table_name(PT::WTextStream & stream, bool with_schema_name, Mode void Model::get_table_name(std::wstring & str, bool with_schema_name, ModelData * model_data, bool clear_string) { - PT::WTextStream stream; + pt::WTextStream stream; if( clear_string ) str.clear(); @@ -233,14 +233,14 @@ void Model::get_table_name(std::wstring & str, bool with_schema_name, ModelData void Model::get_table_name(std::string & str, bool with_schema_name, ModelData * model_data, bool clear_string) { - PT::WTextStream stream; + pt::WTextStream stream; get_table_name(stream, with_schema_name, model_data, false); - PT::WideStreamToUTF8(stream, str, clear_string); + pt::WideStreamToUTF8(stream, str, clear_string); } -void Model::to_text(PT::TextStream & stream, ModelData * model_data, bool clear_stream, bool dump_mode) +void Model::to_text(pt::TextStream & stream, ModelData * model_data, bool clear_stream, bool dump_mode) { if( clear_stream ) { @@ -278,13 +278,13 @@ void Model::to_text(PT::TextStream & stream, ModelData * model_data, bool clear_ } -void Model::to_text(PT::TextStream & stream, ModelData & model_data, bool clear_stream, bool dump_mode) +void Model::to_text(pt::TextStream & stream, ModelData & model_data, bool clear_stream, bool dump_mode) { to_text(stream, &model_data, clear_stream, dump_mode); } -void Model::to_text(PT::TextStream & stream, bool clear_stream, bool dump_mode) +void Model::to_text(pt::TextStream & stream, bool clear_stream, bool dump_mode) { to_text(stream, nullptr, clear_stream, dump_mode); } @@ -296,7 +296,7 @@ void Model::to_text(std::string & str, ModelData * model_data, bool clear_string if( model_connector ) { // CHECK ME what if the stream is being used by something other? - PT::TextStream * out_stream = model_connector->get_stream(); + pt::TextStream * out_stream = model_connector->get_stream(); if( out_stream ) { @@ -336,7 +336,7 @@ std::string Model::to_string() -void Model::generate_insert_query(PT::TextStream & stream, ModelData * model_data) +void Model::generate_insert_query(pt::TextStream & stream, ModelData * model_data) { ModelEnv model_env_local; model_env = &model_env_local; @@ -424,7 +424,7 @@ bool Model::insert_tree(bool insert_whole_tree) DbConnector * db_connector = model_connector->get_db_connector(); // CHECK ME what if the stream is being used by something other? - PT::TextStream * out_stream = model_connector->get_stream(); + pt::TextStream * out_stream = model_connector->get_stream(); if( db_connector && out_stream ) { @@ -470,7 +470,7 @@ bool Model::insert_tree(bool insert_whole_tree) -void Model::generate_update_query(PT::TextStream & stream, ModelData * model_data) +void Model::generate_update_query(pt::TextStream & stream, ModelData * model_data) { ModelEnv model_env_local; model_env = &model_env_local; @@ -555,7 +555,7 @@ bool Model::update_tree(bool update_whole_tree) DbConnector * db_connector = model_connector->get_db_connector(); // CHECK ME what if the stream is being used by something other? - PT::TextStream * out_stream = model_connector->get_stream(); + pt::TextStream * out_stream = model_connector->get_stream(); if( db_connector && out_stream ) { @@ -581,7 +581,7 @@ bool Model::update_tree(bool update_whole_tree) } -void Model::generate_remove_query(PT::TextStream & stream, ModelData * model_data) +void Model::generate_remove_query(pt::TextStream & stream, ModelData * model_data) { ModelEnv model_env_local; model_env = &model_env_local; @@ -667,7 +667,7 @@ bool Model::remove_tree(bool remove_whole_tree) DbConnector * db_connector = model_connector->get_db_connector(); // CHECK ME what if the stream is being used by something other? - PT::TextStream * out_stream = model_connector->get_stream(); + pt::TextStream * out_stream = model_connector->get_stream(); if( db_connector && out_stream ) { @@ -793,7 +793,7 @@ bool Model::save_tree(bool save_whole_tree) } -void Model::generate_select_columns(PT::TextStream & stream) +void Model::generate_select_columns(pt::TextStream & stream) { if( model_connector && model_env ) { @@ -979,7 +979,7 @@ void Model::log_table_name(bool put_schema_name) { if( model_connector && model_env ) { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( plog ) { @@ -1002,7 +1002,7 @@ void Model::log_table_name_with_field(const wchar_t * db_field_name, bool put_sc { if( model_connector && model_env ) { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( plog ) { @@ -1030,17 +1030,17 @@ void Model::put_to_log(const wchar_t * str) { if( model_connector ) { - PT::Log * log = model_connector->get_logger(); + pt::Log * log = model_connector->get_logger(); if( log ) { - (*log) << str << PT::Log::logend; + (*log) << str << pt::Log::logend; } } } -void Model::put_fields_to_log(PT::Log & log, const wchar_t * db_field_name, const wchar_t * flat_field_name) +void Model::put_fields_to_log(pt::Log & log, const wchar_t * db_field_name, const wchar_t * flat_field_name) { bool was_db_field_put = false; bool was_flat_field_put = false; @@ -1077,12 +1077,12 @@ void Model::field_model_left_join(const wchar_t * db_field_name, Model & field_m if( model_env && field_model.model_env && model_env->finder_helper ) { model_env->finder_helper->foreign_keys.clear(); - PT::TextStream & join_tables_str = model_env->finder_helper->join_tables_str; + pt::TextStream & join_tables_str = model_env->finder_helper->join_tables_str; field_model.model_env->add_table_name_to_finder_helper(); join_tables_str << "LEFT JOIN "; - PT::TextStream * db_expression_stream = db_expression->get_text_stream(); + pt::TextStream * db_expression_stream = db_expression->get_text_stream(); int expr_work_mode = db_expression->get_work_mode(); int expr_output_type = db_expression->get_output_type(); bool expr_allow_prefix = db_expression->get_allow_to_use_prefix(); @@ -1149,7 +1149,7 @@ void Model::field_model_left_join(const wchar_t * db_field_name, Model & field_m void Model::field_model_save_key(const wchar_t * db_field_name) { DbConnector * db_connector = model_connector->get_db_connector(); - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( db_connector ) { @@ -1165,9 +1165,9 @@ void Model::field_model_save_key(const wchar_t * db_field_name) if( model_env->field_value_helper_tab->empty() && plog ) { - (*plog) << PT::Log::log1 << "Morm: I cannot find a primary key in "; + (*plog) << pt::Log::log1 << "Morm: I cannot find a primary key in "; log_table_name(); - (*plog) << PT::Log::logend; + (*plog) << pt::Log::logend; } } } @@ -1180,7 +1180,7 @@ void Model::field_model_save_key(const wchar_t * db_field_name) void Model::field_model_set_parent_key_in_child(const wchar_t * db_field_name, Model & field_model) { DbConnector * db_connector = model_connector->get_db_connector(); - PT::Log * log = model_connector->get_logger(); + pt::Log * log = model_connector->get_logger(); if( db_connector ) { @@ -1207,19 +1207,19 @@ void Model::field_model_set_parent_key_in_child(const wchar_t * db_field_name, M { if( field_model.model_env->field_index == 0 ) { - (*log) << PT::Log::log1 << "Morm: there is no a foreign key in "; + (*log) << pt::Log::log1 << "Morm: there is no a foreign key in "; field_model.log_table_name(); (*log) << " called " << db_field_name << " pointing to "; log_table_name(); - (*log) << PT::Log::logend; + (*log) << pt::Log::logend; } else { - (*log) << PT::Log::log1 << "Morm: primary key in "; + (*log) << pt::Log::log1 << "Morm: primary key in "; log_table_name(); (*log) << " consists of " << model_env->field_index << " column(s) but foreign key in "; field_model.log_table_name(); - (*log) << " consists of " << field_model.model_env->field_index << " column(s)" << PT::Log::logend; + (*log) << " consists of " << field_model.model_env->field_index << " column(s)" << pt::Log::logend; } } @@ -1228,10 +1228,10 @@ void Model::field_model_set_parent_key_in_child(const wchar_t * db_field_name, M else if( log ) { - (*log) << PT::Log::log1 << "Morm: primary key in "; + (*log) << pt::Log::log1 << "Morm: primary key in "; log_table_name(); (*log) << " consists of incorrect number of columns, expected " << helper_tab.size() - << " column(s) but got " << model_env->field_index << PT::Log::logend; + << " column(s) but got " << model_env->field_index << pt::Log::logend; } } } @@ -1439,13 +1439,13 @@ void Model::field_model(const wchar_t * db_field_name, const wchar_t * flat_fiel } else { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( plog ) { - (*plog) << PT::Log::log1 << "Morm: error in "; + (*plog) << pt::Log::log1 << "Morm: error in "; log_table_name_with_field(db_field_name); - (*plog) << " field, you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag for a model child object" << PT::Log::logend; + (*plog) << " field, you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag for a model child object" << pt::Log::logend; } } } @@ -1543,7 +1543,7 @@ bool Model::db_query(const std::string & raw_sql) } -bool Model::db_query(const PT::TextStream & raw_sql) +bool Model::db_query(const pt::TextStream & raw_sql) { bool status = false; diff --git a/src/model.h b/src/model.h index b1c6334..f3f93e3 100644 --- a/src/model.h +++ b/src/model.h @@ -86,13 +86,13 @@ public: void set_connector(ModelConnector * connector); ModelConnector * get_connector(); - virtual void get_table_name(PT::WTextStream & stream, bool with_schema_name = true, ModelData * model_data = nullptr, bool clear_stream = true); + virtual void get_table_name(pt::WTextStream & stream, bool with_schema_name = true, ModelData * model_data = nullptr, bool clear_stream = true); virtual void get_table_name(std::wstring & str, bool with_schema_name = true, ModelData * model_data = nullptr, bool clear_string = true); virtual void get_table_name(std::string & str, bool with_schema_name = true, ModelData * model_data = nullptr, bool clear_string = true); - virtual void to_text(PT::TextStream & stream, ModelData * model_data, bool clear_stream = true, bool dump_mode = false); - virtual void to_text(PT::TextStream & stream, ModelData & model_data, bool clear_stream = true, bool dump_mode = false); - virtual void to_text(PT::TextStream & stream, bool clear_stream = true, bool dump_mode = false); + virtual void to_text(pt::TextStream & stream, ModelData * model_data, bool clear_stream = true, bool dump_mode = false); + virtual void to_text(pt::TextStream & stream, ModelData & model_data, bool clear_stream = true, bool dump_mode = false); + virtual void to_text(pt::TextStream & stream, bool clear_stream = true, bool dump_mode = false); virtual void to_text(std::string & str, ModelData * model_data, bool clear_string = true, bool dump_mode = false); virtual void to_text(std::string & str, ModelData & model_data, bool clear_string = true, bool dump_mode = false); @@ -101,17 +101,17 @@ public: virtual std::string to_text(); virtual std::string to_string(); - virtual void generate_insert_query(PT::TextStream & stream, ModelData * model_data = nullptr); + virtual void generate_insert_query(pt::TextStream & stream, ModelData * model_data = nullptr); virtual bool insert(ModelData * model_data, bool insert_whole_tree = true); virtual bool insert(ModelData & model_data, bool insert_whole_tree = true); virtual bool insert(bool insert_whole_tree = true); - virtual void generate_update_query(PT::TextStream & stream, ModelData * model_data = nullptr); + virtual void generate_update_query(pt::TextStream & stream, ModelData * model_data = nullptr); virtual bool update(ModelData * model_data, bool update_whole_tree = true); virtual bool update(ModelData & model_data, bool update_whole_tree = true); virtual bool update(bool update_whole_tree = true); - virtual void generate_remove_query(PT::TextStream & stream, ModelData * model_data = nullptr); + virtual void generate_remove_query(pt::TextStream & stream, ModelData * model_data = nullptr); virtual bool remove(ModelData * model_data, bool remove_whole_tree = true); virtual bool remove(ModelData & model_data, bool remove_whole_tree = true); virtual bool remove(bool remove_whole_tree = true); @@ -121,7 +121,7 @@ public: virtual bool save(bool save_whole_tree = true); - virtual void generate_select_columns(PT::TextStream & stream); + virtual void generate_select_columns(pt::TextStream & stream); // set object to default values virtual void clear(); @@ -154,13 +154,13 @@ public: if( !helper_tab.back().found && model_connector ) { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( plog ) { - (*plog) << PT::Log::log1 << "Morm: I cannot find such a property: "; + (*plog) << pt::Log::log1 << "Morm: I cannot find such a property: "; put_fields_to_log(*plog, db_field_name, flat_field_name); - (*plog) << PT::Log::logend; + (*plog) << pt::Log::logend; } } @@ -219,7 +219,7 @@ protected: virtual bool db_query(const char * raw_sql); virtual bool db_query(const std::string & raw_sql); - virtual bool db_query(const PT::TextStream & raw_sql); + virtual bool db_query(const pt::TextStream & raw_sql); ///////////////////////////////// /* @@ -312,12 +312,12 @@ protected: field_generic(field_name, field_name, field_value, field_type); } - void field(const wchar_t * field_name, PT::Date & field_value, const 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, const 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); } @@ -431,12 +431,12 @@ protected: 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, const 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, const 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); } @@ -474,7 +474,7 @@ protected: if( model_env->field_index >= 0 && (size_t)model_env->field_index < model_env->field_value_helper_tab->size() ) { FieldValueHelper & helper = (*model_env->field_value_helper_tab)[model_env->field_index]; - PT::Log * log = model_connector->get_logger(); + pt::Log * log = model_connector->get_logger(); if( (!helper.compare_db_field_name || is_the_same_field(db_field_name, helper.db_field_name)) && (!helper.compare_flat_field_name || is_the_same_field(flat_field_name, helper.flat_field_name)) ) @@ -489,12 +489,12 @@ protected: { if( log ) { - (*log) << PT::Log::log1 << "Morm: incorrect type of a field in "; + (*log) << pt::Log::log1 << "Morm: incorrect type of a field in "; log_table_name(); (*log) << ", "; put_fields_to_log(*log, db_field_name, flat_field_name); (*log) << ", type expected " << typeid(field_value).name() - << " got " << helper.value_type_info->name() << PT::Log::logend; + << " got " << helper.value_type_info->name() << pt::Log::logend; } } } @@ -749,7 +749,7 @@ protected: { if( model_connector && model_env ) { - PT::Log * plog = model_connector->get_logger(); + pt::Log * plog = model_connector->get_logger(); if( !is_empty_field(db_field_name) ) { @@ -762,7 +762,7 @@ protected: { if( plog ) { - (*plog) << PT::Log::log1 << "Morm: error: FT::is_foreign_key is not implemented for a list/vector yet" << PT::Log::logend; + (*plog) << pt::Log::log1 << "Morm: error: FT::is_foreign_key is not implemented for a list/vector yet" << pt::Log::logend; return; } } @@ -785,9 +785,9 @@ protected: { if( plog ) { - (*plog) << PT::Log::log1 << "Morm: ignoring "; + (*plog) << pt::Log::log1 << "Morm: ignoring "; log_table_name_with_field(db_field_name); - (*plog) << " as this is not a container with Model objects" << PT::Log::logend; + (*plog) << " as this is not a container with Model objects" << pt::Log::logend; } } } @@ -795,9 +795,9 @@ protected: { if( plog ) { - (*plog) << PT::Log::log1 << "Morm: error in "; + (*plog) << pt::Log::log1 << "Morm: error in "; log_table_name_with_field(db_field_name); - (*plog) << " field, you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag for a list of child objects" << PT::Log::logend; + (*plog) << " field, you should set FT::is_foreign_key or FT::is_foreign_key_in_child flag for a list of child objects" << pt::Log::logend; } } } @@ -861,7 +861,7 @@ protected: if( db_expression ) { std::wstring table_field_name; - PT::TextStream table_field_name_str; + pt::TextStream table_field_name_str; // CHECK ME not tested yet after changing to db_expression->table_with_index_and_field_to_stream() db_expression->table_with_index_and_field_to_stream(table_field_name_str, model_env->table_name, model_env->table_index, field_name, field_type); @@ -977,7 +977,7 @@ protected: virtual bool is_the_same_field(const wchar_t * field1, const wchar_t * field2); virtual void put_to_log(const wchar_t * str); - virtual void put_fields_to_log(PT::Log & log, const wchar_t * db_field_name, const wchar_t * flat_field_name); + virtual void put_fields_to_log(pt::Log & log, const wchar_t * db_field_name, const wchar_t * flat_field_name); virtual void log_table_name(bool put_schema_name = true); virtual void log_table_name_with_field(const wchar_t * db_field_name = nullptr, bool put_schema_name = true); diff --git a/src/modelconnector.cpp b/src/modelconnector.cpp index 51a6c06..9c7a2fa 100644 --- a/src/modelconnector.cpp +++ b/src/modelconnector.cpp @@ -60,17 +60,17 @@ ModelConnector::~ModelConnector() } -void ModelConnector::set_logger(PT::Log * log) +void ModelConnector::set_logger(pt::Log * log) { this->log = log; } -void ModelConnector::set_logger(PT::Log & log) +void ModelConnector::set_logger(pt::Log & log) { this->log = &log; } -PT::Log * ModelConnector::get_logger() +pt::Log * ModelConnector::get_logger() { return log; } @@ -91,7 +91,7 @@ void ModelConnector::deallocate_stream() void ModelConnector::allocate_default_stream() { deallocate_stream(); - out_stream = new PT::TextStream(); + out_stream = new pt::TextStream(); out_stream_allocated = true; } @@ -133,14 +133,14 @@ void ModelConnector::allocate_default_clearer_if_needed() } -void ModelConnector::set_stream(PT::TextStream & stream) +void ModelConnector::set_stream(pt::TextStream & stream) { deallocate_stream(); this->out_stream = &stream; } -PT::TextStream * ModelConnector::get_stream() +pt::TextStream * ModelConnector::get_stream() { allocate_default_stream_if_needed(); return out_stream; diff --git a/src/modelconnector.h b/src/modelconnector.h index f28dfc3..9e20547 100644 --- a/src/modelconnector.h +++ b/src/modelconnector.h @@ -59,13 +59,13 @@ public: ModelConnector(const ModelConnector &) = delete; virtual ~ModelConnector(); - virtual void set_logger(PT::Log * log); - virtual void set_logger(PT::Log & log); + virtual void set_logger(pt::Log * log); + virtual void set_logger(pt::Log & log); - virtual PT::Log * get_logger(); + virtual pt::Log * get_logger(); - virtual void set_stream(PT::TextStream & stream); - virtual PT::TextStream * get_stream(); + virtual void set_stream(pt::TextStream & stream); + virtual pt::TextStream * get_stream(); virtual void set_flat_connector(FlatConnector & flat_connector); virtual FlatConnector * get_flat_connector(); @@ -80,12 +80,12 @@ public: protected: - PT::Log * log; + pt::Log * log; FlatConnector * flat_connector; DbConnector * db_connector; - PT::TextStream * out_stream; // IMPROVE ME give here an interface to the base stream (implement him) + pt::TextStream * out_stream; // IMPROVE ME give here an interface to the base stream (implement him) bool out_stream_allocated; Clearer * clearer; diff --git a/src/modelenv.h b/src/modelenv.h index c68adbc..7b72405 100644 --- a/src/modelenv.h +++ b/src/modelenv.h @@ -61,8 +61,8 @@ public: int model_work_submode; bool dump_mode; - PT::WTextStream schema_name; - PT::WTextStream table_name; + pt::WTextStream schema_name; + pt::WTextStream table_name; int table_index; /* diff --git a/src/postgresqlconnector.cpp b/src/postgresqlconnector.cpp index 4a31f89..78b78b6 100644 --- a/src/postgresqlconnector.cpp +++ b/src/postgresqlconnector.cpp @@ -92,7 +92,7 @@ bool PostgreSQLConnector::do_query(const char * query_str, PostgreSQLQueryResult if( log_queries && log ) { - (*log) << PT::Log::log3 << "Morm: query: " << query_str << PT::Log::logend; + (*log) << pt::Log::log3 << "Morm: query: " << query_str << pt::Log::logend; } psql_result->psql_result = PQexec(pg_conn, query_str); @@ -119,15 +119,15 @@ bool PostgreSQLConnector::do_query(const char * query_str, PostgreSQLQueryResult if( err_msg ) { - PT::UTF8ToWide(err_msg, psql_result->error_msg); + pt::UTF8ToWide(err_msg, psql_result->error_msg); } if( log ) { - (*log) << PT::Log::log1 << "Morm: Problem with this query: \"" << query_str << '\"' << PT::Log::logend; + (*log) << pt::Log::log1 << "Morm: Problem with this query: \"" << query_str << '\"' << pt::Log::logend; if( err_msg ) - (*log) << PT::Log::log1 << "Morm: " << err_msg << PT::Log::logend; + (*log) << pt::Log::log1 << "Morm: " << err_msg << pt::Log::logend; } } else @@ -171,8 +171,8 @@ const char * PostgreSQLConnector::query_last_sequence(const wchar_t * sequence_t { if( log ) { - (*log) << PT::Log::log1 << "Morm: expected only one row in sequence result, has: " << psql_result.result_rows - << PT::Log::logend; + (*log) << pt::Log::log1 << "Morm: expected only one row in sequence result, has: " << psql_result.result_rows + << pt::Log::logend; } } } @@ -180,8 +180,8 @@ const char * PostgreSQLConnector::query_last_sequence(const wchar_t * sequence_t { if( pg_conn && log ) { - (*log) << PT::Log::log1 << "Morm: error (currval) for table: " << sequence_table_name << ", " - << PQerrorMessage(pg_conn) << PT::Log::logend; + (*log) << pt::Log::log1 << "Morm: error (currval) for table: " << sequence_table_name << ", " + << PQerrorMessage(pg_conn) << pt::Log::logend; } } } @@ -191,7 +191,7 @@ const char * PostgreSQLConnector::query_last_sequence(const wchar_t * sequence_t -bool PostgreSQLConnector::query(const PT::TextStream & stream, QueryResult & query_result) +bool PostgreSQLConnector::query(const pt::TextStream & stream, QueryResult & query_result) { stream.to_string(query_str); return query(query_str.c_str(), query_result); @@ -264,25 +264,25 @@ bool PostgreSQLConnector::query_remove(const char * query_str, QueryResult & que } -bool PostgreSQLConnector::query_select(const PT::TextStream & stream, QueryResult & query_result) +bool PostgreSQLConnector::query_select(const pt::TextStream & stream, QueryResult & query_result) { stream.to_string(query_str); return query_select(query_str.c_str(), query_result); } -bool PostgreSQLConnector::query_update(const PT::TextStream & stream, QueryResult & query_result) +bool PostgreSQLConnector::query_update(const pt::TextStream & stream, QueryResult & query_result) { stream.to_string(query_str); return query_update(query_str.c_str(), query_result); } -bool PostgreSQLConnector::query_insert(const PT::TextStream & stream, QueryResult & query_result) +bool PostgreSQLConnector::query_insert(const pt::TextStream & stream, QueryResult & query_result) { stream.to_string(query_str); return query_insert(query_str.c_str(), query_result); } -bool PostgreSQLConnector::query_remove(const PT::TextStream & stream, QueryResult & query_result) +bool PostgreSQLConnector::query_remove(const pt::TextStream & stream, QueryResult & query_result) { stream.to_string(query_str); return query_remove(query_str.c_str(), query_result); @@ -400,9 +400,9 @@ void PostgreSQLConnector::set_conn_param(const std::wstring & database_name, con } -void PostgreSQLConnector::overwrite(PT::TextStream & stream) +void PostgreSQLConnector::overwrite(pt::TextStream & stream) { - PT::TextStream::iterator i = stream.begin(); + pt::TextStream::iterator i = stream.begin(); for( ; i != stream.end() ; ++i) { @@ -455,9 +455,9 @@ void PostgreSQLConnector::log_connection_socket() { if( pg_conn && log ) { - (*log) << PT::Log::log2 << "Morm: connection to the database works fine" << PT::Log::logend; - (*log) << PT::Log::log3 << "Morm: connection socket: " << PQsocket(pg_conn) << PT::Log::logend; - (*log) << PT::Log::logsave; + (*log) << pt::Log::log2 << "Morm: connection to the database works fine" << pt::Log::logend; + (*log) << pt::Log::log3 << "Morm: connection socket: " << PQsocket(pg_conn) << pt::Log::logend; + (*log) << pt::Log::logsave; } } @@ -467,7 +467,7 @@ void PostgreSQLConnector::wait_for_connection() { if( log ) { - (*log) << PT::Log::log3 << "Morm: waiting for the db to be ready...." << PT::Log::logend << PT::Log::logsave; + (*log) << pt::Log::log3 << "Morm: waiting for the db to be ready...." << pt::Log::logend << pt::Log::logsave; } while( !assert_connection(false) ) @@ -498,7 +498,7 @@ bool was_connection = true; { if( put_log && log ) { - (*log) << PT::Log::log2 << "Morm: connection to the database is lost, trying to recover" << PT::Log::logend << PT::Log::logsave; + (*log) << pt::Log::log2 << "Morm: connection to the database is lost, trying to recover" << pt::Log::logend << pt::Log::logsave; } was_connection = false; @@ -522,7 +522,7 @@ bool was_connection = true; { if( put_log && log ) { - (*log) << PT::Log::log1 << "Morm: connection to db server cannot be established" << PT::Log::logend << PT::Log::logsave; + (*log) << pt::Log::log1 << "Morm: connection to db server cannot be established" << pt::Log::logend << pt::Log::logsave; } // if( throw_if_no_connection ) @@ -543,7 +543,7 @@ void PostgreSQLConnector::set_db_parameters() { if( log ) { - (*log) << PT::Log::log1 << "Morm: Can't set the proper client encoding" << PT::Log::logend << PT::Log::logsave; + (*log) << pt::Log::log1 << "Morm: Can't set the proper client encoding" << pt::Log::logend << pt::Log::logsave; } } } @@ -554,7 +554,7 @@ void PostgreSQLConnector::log_unsupported_bin_format() { if( log ) { - (*log) << PT::Log::log1 << "Morm: unsupported binary format (skipping)" << PT::Log::logend; + (*log) << pt::Log::log1 << "Morm: unsupported binary format (skipping)" << pt::Log::logend; } } diff --git a/src/postgresqlconnector.h b/src/postgresqlconnector.h index 0f771d1..9f21165 100644 --- a/src/postgresqlconnector.h +++ b/src/postgresqlconnector.h @@ -55,7 +55,7 @@ public: virtual ~PostgreSQLConnector(); - bool query(const PT::TextStream & stream, QueryResult & query_result); + bool query(const pt::TextStream & stream, QueryResult & query_result); bool query(const char * query_str, QueryResult & query_result); bool query(const std::string & query_str, QueryResult & query_result); @@ -64,10 +64,10 @@ public: bool query_insert(const char * query_str, QueryResult & query_result); bool query_remove(const char * query_str, QueryResult & query_result); - bool query_select(const PT::TextStream & stream, QueryResult & query_result); - bool query_update(const PT::TextStream & stream, QueryResult & query_result); - bool query_insert(const PT::TextStream & stream, QueryResult & query_result); - bool query_remove(const PT::TextStream & stream, QueryResult & query_result); + bool query_select(const pt::TextStream & stream, QueryResult & query_result); + bool query_update(const pt::TextStream & stream, QueryResult & query_result); + bool query_insert(const pt::TextStream & stream, QueryResult & query_result); + bool query_remove(const pt::TextStream & stream, QueryResult & query_result); virtual void set_conn_param(const std::wstring & database, const std::wstring & user, const std::wstring & pass); @@ -85,7 +85,7 @@ public: protected: PGconn * pg_conn; - PT::TextStream stream; + pt::TextStream stream; std::string query_str; std::wstring db_database; @@ -94,7 +94,7 @@ protected: virtual bool do_query(const char * query_str, PostgreSQLQueryResult * psql_result); virtual void allocate_default_expression(); - virtual void overwrite(PT::TextStream & stream); + virtual void overwrite(pt::TextStream & stream); virtual const char * query_last_sequence(const wchar_t * sequence_table_name); virtual QueryResult * create_query_result(); diff --git a/src/postgresqlexpression.cpp b/src/postgresqlexpression.cpp index 4aaa3f7..c9b4ccd 100644 --- a/src/postgresqlexpression.cpp +++ b/src/postgresqlexpression.cpp @@ -64,7 +64,7 @@ void PostgreSQLExpression::after_field_value_string(const FT & field_type) -void PostgreSQLExpression::esc(char val, PT::TextStream & stream, const FT & field_type) +void PostgreSQLExpression::esc(char val, pt::TextStream & stream, const FT & field_type) { if( field_type.is_hexadecimal() || field_type.is_binary() ) { @@ -86,13 +86,13 @@ void PostgreSQLExpression::esc(char val, PT::TextStream & stream, const FT & fie } -void PostgreSQLExpression::esc(const PT::Date & date, PT::TextStream & stream, const FT & field_type) +void PostgreSQLExpression::esc(const pt::Date & date, pt::TextStream & stream, const FT & field_type) { stream << date << "+00"; } -DbExpression & PostgreSQLExpression::page(PT::TextStream & stream, size_t page_number, size_t page_size) +DbExpression & PostgreSQLExpression::page(pt::TextStream & stream, size_t page_number, size_t page_size) { stream << " offset " << page_number << " limit " << page_size << " "; return *this; diff --git a/src/postgresqlexpression.h b/src/postgresqlexpression.h index 0001171..d3c8346 100644 --- a/src/postgresqlexpression.h +++ b/src/postgresqlexpression.h @@ -45,10 +45,10 @@ class PostgreSQLExpression : public DbExpression { public: - void esc(char val, PT::TextStream & stream, const FT & field_type); - void esc(const PT::Date & date, PT::TextStream & stream, const 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); + DbExpression & page(pt::TextStream & stream, size_t page_number, size_t page_size); protected: diff --git a/src/postgresqlqueryresult.cpp b/src/postgresqlqueryresult.cpp index 61c3209..22eeb5f 100644 --- a/src/postgresqlqueryresult.cpp +++ b/src/postgresqlqueryresult.cpp @@ -184,7 +184,7 @@ bool PostgreSQLQueryResult::is_null(int row, int col) } -void PostgreSQLQueryResult::dump_column_names(PT::Log & log) +void PostgreSQLQueryResult::dump_column_names(pt::Log & log) { if( psql_result ) { @@ -192,7 +192,7 @@ void PostgreSQLQueryResult::dump_column_names(PT::Log & log) for(int i = 0 ; i < cols ; ++i) { - log << i << ' ' << PQfname(psql_result, i) << PT::Log::logend; + log << i << ' ' << PQfname(psql_result, i) << pt::Log::logend; } } } @@ -255,20 +255,20 @@ void PostgreSQLQueryResult::dump_column_names(PT::Log & log) //} -//bool PostgreSQLConnector::AssertValueSpace(PGresult * r, int row, int col, PT::Space & space) +//bool PostgreSQLConnector::AssertValueSpace(PGresult * r, int row, int col, pt::Space & space) //{ // const char * res = AssertValue(r, row, col); // // conf_parser.SetSpace(space); // space.Clear(); // -// PT::SpaceParser::Status status = conf_parser.ParseString(res); +// pt::SpaceParser::Status status = conf_parser.ParseString(res); // -// if( status != PT::SpaceParser::ok ) +// if( status != pt::SpaceParser::ok ) // { -// log << log1 << "Morm: a problem with parsing a PT::Space"; +// log << log1 << "Morm: a problem with parsing a pt::Space"; // -// if( status == PT::SpaceParser::syntax_error ) +// if( status == pt::SpaceParser::syntax_error ) // log << ", syntax error at line: " << conf_parser.line; // // log << logend; diff --git a/src/postgresqlqueryresult.h b/src/postgresqlqueryresult.h index ca80482..fcc5758 100644 --- a/src/postgresqlqueryresult.h +++ b/src/postgresqlqueryresult.h @@ -68,7 +68,7 @@ struct PostgreSQLQueryResult : public QueryResult bool is_null(int row, int col); - void dump_column_names(PT::Log & log); + void dump_column_names(pt::Log & log); }; diff --git a/src/queryresult.cpp b/src/queryresult.cpp index cdac798..a5e19de 100644 --- a/src/queryresult.cpp +++ b/src/queryresult.cpp @@ -85,7 +85,7 @@ const char * QueryResult::get_field_string_value(const char * column_name) const char * QueryResult::get_field_string_value(const wchar_t * column_name) { - PT::WideToUTF8(column_name, temp_column_name); + pt::WideToUTF8(column_name, temp_column_name); return get_field_string_value(temp_column_name.c_str()); } @@ -98,7 +98,7 @@ int QueryResult::get_column_index(const char * column_name) int QueryResult::get_column_index(const wchar_t * column_name) { - PT::WideToUTF8(column_name, temp_column_name); + pt::WideToUTF8(column_name, temp_column_name); return get_column_index(temp_column_name.c_str()); } @@ -125,7 +125,7 @@ bool QueryResult::is_null(int row, int col) } -void QueryResult::dump_column_names(PT::Log & log) +void QueryResult::dump_column_names(pt::Log & log) { } diff --git a/src/queryresult.h b/src/queryresult.h index f18e032..fdabfb5 100644 --- a/src/queryresult.h +++ b/src/queryresult.h @@ -76,7 +76,7 @@ struct QueryResult virtual int get_value_length(int row, int col); virtual bool is_null(int row, int col); - virtual void dump_column_names(PT::Log & log); + virtual void dump_column_names(pt::Log & log); };