diff --git a/samples/Makefile b/samples/Makefile index fdbcbd1..855226e 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -13,7 +13,7 @@ CXX = g++10 # -fsanitize=address # -Wl,-rpath=/usr/local/lib/gcc5 or just compile with -static-libstdc++ -CXXFLAGS = -Wl,-rpath=/usr/local/lib/gcc10 -Wfatal-errors -fPIC -Wall -pedantic -O0 -g3 -gdwarf-2 -pthread -std=c++20 -I/usr/local/include -I$(GLOBAL_WORKING_DIR)/pikotools -I$(GLOBAL_WORKING_DIR)/morm/src +CXXFLAGS = -Wl,-rpath=/usr/local/lib/gcc10 -Wfatal-errors -fPIC -Wall -pedantic -O0 -g3 -pthread -std=c++20 -I/usr/local/include -I$(GLOBAL_WORKING_DIR)/pikotools/src -I$(GLOBAL_WORKING_DIR)/morm/src LDFLAGS = -L/usr/local/lib @@ -32,8 +32,8 @@ global_relative_working_dir := $(shell relative_path $(current_path) $(GLOBAL_WO all: morm $(name) -$(name): morm $(o) - $(CXX) -o $(name) $(CXXFLAGS) $(LDFLAGS) $(o) $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(GLOBAL_WORKING_DIR)/pikotools/log/log.a $(GLOBAL_WORKING_DIR)/pikotools/space/space.a $(GLOBAL_WORKING_DIR)/pikotools/mainspaceparser/mainspaceparser.a $(GLOBAL_WORKING_DIR)/pikotools/date/date.a $(GLOBAL_WORKING_DIR)/pikotools/convert/convert.a $(GLOBAL_WORKING_DIR)/pikotools/utf8/utf8.a $(LDFLAGS) -lpq -lpthread +$(name): morm pikotools $(o) + $(CXX) -o $(name) $(CXXFLAGS) $(LDFLAGS) $(o) $(GLOBAL_WORKING_DIR)/morm/src/morm.a $(GLOBAL_WORKING_DIR)/pikotools/src/pikotools.a $(LDFLAGS) -lpq -lpthread .PHONY: morm @@ -43,12 +43,16 @@ morm: @cd $(GLOBAL_WORKING_DIR)/morm/src ; $(MAKE) -e +pikotools: + @cd $(GLOBAL_WORKING_DIR)/pikotools/src ; $(MAKE) -e + + %.o: %.cpp $(CXX) -c $(CXXFLAGS) $< depend: - makedepend -Y. -I$(global_relative_working_dir)/pikotools -I$(global_relative_working_dir)/morm/src -f- *.cpp > Makefile.dep + makedepend -Y. -I$(global_relative_working_dir)/pikotools/src -I$(global_relative_working_dir)/morm/src -f- *.cpp > Makefile.dep echo -n "o = " > Makefile.o.dep ls -1 *.cpp | xargs -I foo echo -n foo " " | sed -E "s/([^\.]*)\.cpp[ ]/\1\.o/g" >> Makefile.o.dep diff --git a/samples/Makefile.dep b/samples/Makefile.dep index dfcdfb0..65d4665 100644 --- a/samples/Makefile.dep +++ b/samples/Makefile.dep @@ -1,23 +1,17 @@ # DO NOT DELETE -main.o: ../../pikotools/mainspaceparser/mainspaceparser.h -main.o: ../../pikotools/space/space.h ../../pikotools/textstream/types.h -main.o: ../../pikotools/convert/inttostr.h sample01.h basesample.h -main.o: ../../morm/src/morm.h ../../morm/src/morm_types.h -main.o: ../../morm/src/model.h ../../pikotools/textstream/textstream.h -main.o: ../../pikotools/date/date.h ../../pikotools/membuffer/membuffer.h -main.o: ../../pikotools/textstream/types.h ../../morm/src/modelconnector.h -main.o: ../../morm/src/clearer.h ../../morm/src/dbconnector.h -main.o: ../../pikotools/log/log.h ../../pikotools/log/filelog.h -main.o: ../../morm/src/queryresult.h ../../morm/src/flatconnector.h +main.o: sample01.h basesample.h ../../morm/src/morm.h +main.o: ../../morm/src/morm_types.h ../../morm/src/model.h +main.o: ../../morm/src/modelconnector.h ../../morm/src/clearer.h +main.o: ../../morm/src/dbconnector.h ../../morm/src/queryresult.h +main.o: ../../morm/src/ft.h ../../morm/src/flatconnector.h main.o: ../../morm/src/dbexpression.h ../../morm/src/baseexpression.h main.o: ../../morm/src/modelenv.h ../../morm/src/modeldata.h main.o: ../../morm/src/cursorhelper.h ../../morm/src/finderhelper.h -main.o: ../../morm/src/fieldvaluehelper.h ../../morm/src/ft.h -main.o: ../../morm/src/flatexpression.h ../../morm/src/finder.h -main.o: ../../pikotools/utf8/utf8.h ../../pikotools/utf8/utf8_templates.h -main.o: ../../pikotools/utf8/utf8_private.h ../../morm/src/cursor.h -main.o: ../../morm/src/jsonexpression.h ../../morm/src/postgresqlexpression.h -main.o: ../../morm/src/jsonconnector.h ../../morm/src/postgresqlconnector.h +main.o: ../../morm/src/fieldvaluehelper.h ../../morm/src/flatexpression.h +main.o: ../../morm/src/modelwrapper.h ../../morm/src/finder.h +main.o: ../../morm/src/cursor.h ../../morm/src/jsonexpression.h +main.o: ../../morm/src/postgresqlexpression.h ../../morm/src/jsonconnector.h +main.o: ../../morm/src/postgresqlconnector.h main.o: ../../morm/src/postgresqlqueryresult.h person.h language.h main.o: attachment.h type.h attachment2.h diff --git a/samples/attachment.h b/samples/attachment.h index ca8e256..0a6c455 100644 --- a/samples/attachment.h +++ b/samples/attachment.h @@ -75,7 +75,7 @@ public: Language language; - void map_fields() + void fields() { field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key); field(L"person_id", person_id); @@ -87,9 +87,9 @@ public: field(L"language_id", L"language", language, FT::foreign_key); } - void prepare_table() + void table() { - table(L"public", L"attachment"); + table_name(L"public", L"attachment"); } void after_select() diff --git a/samples/attachment2.h b/samples/attachment2.h index 6961707..b99300e 100644 --- a/samples/attachment2.h +++ b/samples/attachment2.h @@ -75,7 +75,7 @@ public: Language language; - void map_fields() + void fields() { field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key); field(L"person_id", person_id); @@ -87,9 +87,9 @@ public: field(L"language_id", L"language", language, FT::foreign_key); } - void prepare_table() + void table() { - table(L"public", L"attachment2"); + table_name(L"public", L"attachment2"); } void after_select() diff --git a/samples/language.h b/samples/language.h index 4c79951..0256199 100644 --- a/samples/language.h +++ b/samples/language.h @@ -68,7 +68,7 @@ public: int code_int; - void map_fields() + void fields() { field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key); field(L"english_name", english_name); @@ -77,9 +77,9 @@ public: field(L"code_int", code_int); } - void prepare_table() + void table() { - table(L"public", L"language"); + table_name(L"public", L"language"); } void after_insert() diff --git a/samples/main.cpp b/samples/main.cpp index 063199e..8f4c492 100644 --- a/samples/main.cpp +++ b/samples/main.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2019, Tomasz Sowa + * Copyright (c) 2019-2021, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,7 @@ * */ -#include "mainspaceparser/mainspaceparser.h" +#include "mainoptions/mainoptionsparser.h" #include "sample01.h" @@ -61,23 +61,21 @@ void print_syntax() int main(int argc, const char ** argv) { -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::Space args, options; - pt::MainSpaceParser main_parser; - main_parser.UTF8(true); - main_parser.SetSpace(args); - pt::MainSpaceParser::Status args_status = main_parser.Parse(argc, argv); + options.add(L"c", 1); // one argument - config file + options.add(L"config", 1); - if( args_status != pt::MainSpaceParser::status_ok ) + pt::MainOptionsParser main_parser; + pt::MainOptionsParser::Status args_status = main_parser.parse(argc, argv, args, options); + + if( args_status != pt::MainOptionsParser::status_ok ) { std::cout << "Syntax error in arguments" << std::endl; return 1; } - if( args.GetFirstValue(L"h") || args.GetFirstValue(L"help") ) + if( args.has_key(L"h") || args.has_key(L"help") ) { morm::samples::print_syntax(); return 0; @@ -106,8 +104,8 @@ args_options.Add(L"config", 1); pt::WTextStream log_buffer; file_log.init(L"log.txt", true, 4, true); - log.SetLogBuffer(&log_buffer); - log.SetFileLog(&file_log); + log.set_log_buffer(&log_buffer); + log.set_file_log(&file_log); diff --git a/samples/person.h b/samples/person.h index 54a72c3..94bf2e9 100644 --- a/samples/person.h +++ b/samples/person.h @@ -75,7 +75,7 @@ public: Attachment2 attachment2; - void map_fields() + void fields() { field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key); field(L"language_id", L"language", language, FT::foreign_key); @@ -87,9 +87,9 @@ public: } - void prepare_table() + void table() { - table(L"public", L"person"); + table_name(L"public", L"person"); } diff --git a/samples/type.h b/samples/type.h index cfa1399..7328d78 100644 --- a/samples/type.h +++ b/samples/type.h @@ -63,16 +63,16 @@ public: long attachment_id; std::wstring name; - void map_fields() + void fields() { field(L"id", id, FT::no_insertable | FT::no_updatable | FT::primary_key); field(L"attachment_id", attachment_id); field(L"name", name); } - void prepare_table() + void table() { - table(L"public", L"types"); + table_name(L"public", L"types"); } void after_insert()