diff --git a/Interfaces/ORM/intfActionLogs.cpp b/Interfaces/ORM/intfActionLogs.cpp index 1e3cb01d..064c9c2e 100644 --- a/Interfaces/ORM/intfActionLogs.cpp +++ b/Interfaces/ORM/intfActionLogs.cpp @@ -33,14 +33,14 @@ intfActionLogs::intfActionLogs( const QString& _module, const QString& _schema ) : -intfSQLBasedModule( - _module, - _schema, - tblActionLogs::Name, - tblActionLogs::Private::ORMFields, - tblActionLogs::Private::Relations, - tblActionLogs::Private::Indexes -) { ; } + intfSQLBasedModule( + _module, + _schema, + tblActionLogs::Name, + tblActionLogs::Private::ORMFields, + tblActionLogs::Private::Relations, + tblActionLogs::Private::Indexes + ) { ; } QVariant IMPL_ORMGET_USER(intfActionLogs) { // Authorization::checkPriv(APICALLBOOM_PARAM, { this->ModuleName + ":ActionLogs:CRUD~0100" }); diff --git a/Interfaces/ORM/intfAlerts.cpp b/Interfaces/ORM/intfAlerts.cpp index 09e733b4..58dfb830 100644 --- a/Interfaces/ORM/intfAlerts.cpp +++ b/Interfaces/ORM/intfAlerts.cpp @@ -37,6 +37,7 @@ intfAlerts::intfAlerts( intfSQLBasedModule( _module, _schema, + tblAlerts::Name, tblAlerts::Private::ORMFields, tblAlerts::Private::Relations, tblAlerts::Private::Indexes diff --git a/Interfaces/ORM/intfConfigurations.cpp b/Interfaces/ORM/intfConfigurations.cpp index a7592bfa..111b7168 100644 --- a/Interfaces/ORM/intfConfigurations.cpp +++ b/Interfaces/ORM/intfConfigurations.cpp @@ -34,14 +34,14 @@ intfConfigurations::intfConfigurations( const QString &_module, const QString &_schema ) : -intfSQLBasedModule( - _module, - _schema, - tblConfigurations::Name, - tblConfigurations::Private::ORMFields, - tblConfigurations::Private::Relations, - tblConfigurations::Private::Indexes -) { ; } + intfSQLBasedModule( + _module, + _schema, + tblConfigurations::Name, + tblConfigurations::Private::ORMFields, + tblConfigurations::Private::Relations, + tblConfigurations::Private::Indexes + ) { ; } QVariant IMPL_ORMGET_ANONYMOUSE(intfConfigurations) { return this->Select(GET_METHOD_ARGS_CALL_VALUES); diff --git a/Interfaces/ORM/intfFAQ.cpp b/Interfaces/ORM/intfFAQ.cpp index 6f312875..f220c535 100644 --- a/Interfaces/ORM/intfFAQ.cpp +++ b/Interfaces/ORM/intfFAQ.cpp @@ -37,14 +37,14 @@ intfFaqQuestions::intfFaqQuestions( const QString& _module, const QString& _schema ) : -intfSQLBasedModule( - _module, - _schema, - tblFaqQuestions::Name, - tblFaqQuestions::Private::ORMFields, - tblFaqQuestions::Private::Relations(_schema), - tblFaqQuestions::Private::Indexes -) { ; } + intfSQLBasedModule( + _module, + _schema, + tblFaqQuestions::Name, + tblFaqQuestions::Private::ORMFields, + tblFaqQuestions::Private::Relations(_schema), + tblFaqQuestions::Private::Indexes + ) { ; } QVariant IMPL_ORMGET_ANONYMOUSE(intfFaqQuestions) { return this->Select(GET_METHOD_ARGS_CALL_VALUES); diff --git a/Interfaces/ORM/intfI18N.cpp b/Interfaces/ORM/intfI18N.cpp index dd3ffe9d..0930f17b 100644 --- a/Interfaces/ORM/intfI18N.cpp +++ b/Interfaces/ORM/intfI18N.cpp @@ -37,14 +37,14 @@ intfI18N::intfI18N( const QString &_module, const QString &_schema ) : -intfSQLBasedModule( - _module, - _schema, - tblI18N::Name, - tblI18N::Private::ORMFields, - tblI18N::Private::Relations, - tblI18N::Private::Indexes -) { ; } + intfSQLBasedModule( + _module, + _schema, + tblI18N::Name, + tblI18N::Private::ORMFields, + tblI18N::Private::Relations, + tblI18N::Private::Indexes + ) { ; } QString intfI18N::translated( INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM, diff --git a/Interfaces/ORM/intfMigrations.cpp b/Interfaces/ORM/intfMigrations.cpp index 8dfcc757..c77c8f5f 100644 --- a/Interfaces/ORM/intfMigrations.cpp +++ b/Interfaces/ORM/intfMigrations.cpp @@ -34,14 +34,14 @@ intfMigrations::intfMigrations( const QString& _module, const QString& _schema ) : -intfSQLBasedModule( - _module, - _schema, - tblMigrations::Name, - tblMigrations::Private::ORMFields, - tblMigrations::Private::Relations, - tblMigrations::Private::Indexes -) { ; } + intfSQLBasedModule( + _module, + _schema, + tblMigrations::Name, + tblMigrations::Private::ORMFields, + tblMigrations::Private::Relations, + tblMigrations::Private::Indexes + ) { ; } QVariant IMPL_ORMGET_ANONYMOUSE(intfMigrations) { // Authorization::checkPriv(APICALLBOOM_PARAM, { this->ModuleName + ":Migrations:CRUD~0100" }); diff --git a/devtools/checkQObject.py b/devtools/checkQObject.py new file mode 100644 index 00000000..68f89249 --- /dev/null +++ b/devtools/checkQObject.py @@ -0,0 +1,46 @@ +# check_code v1.0 +# run from root of repository +from subprocess import check_output + +_qt_autogen_macro_list = (\ +'signals:', \ +'Q_CLASSINFO', \ +'Q_PLUGIN_METADATA', \ +'Q_INTERFACES', \ +'Q_PROPERTY', \ +'Q_PRIVATE_PROPERTY', \ +'Q_REVISION', \ +'Q_OVERRIDE', \ +'Q_ENUM', \ +'Q_FLAGS', \ +'Q_SCRIPTABLE', \ +'Q_INVOKABLE', \ +'Q_SIGNAL', \ +'Q_SLOT' \ +) +_qt_autogen_macro_regexp = '({0})'.format('|'.join(_qt_autogen_macro_list)) + +def _FnamesToBaseFileNames(fnames_list): + result = [] + for fn in fnames_list: + start = fn.rfind('/') + end = fn.rfind('.') + if end > start: + result.append(fn[start + 1 : end]) + return result + +def CheckQObject(): + def get_files(pattern): + files = check_output('git grep -E "{0}"'.format(pattern)).split('\n') + files = [s[:s.find(':')] for s in files] + return set([s for s in files if len(s) > 0]) + qobject_files = _FnamesToBaseFileNames(get_files('Q_OBJECT')) + macro_files = _FnamesToBaseFileNames(get_files(_qt_autogen_macro_regexp)) + include_moc_files = _FnamesToBaseFileNames(get_files('#include \\"moc_.*?\.cpp\\"')) + for fn in qobject_files: + if fn not in include_moc_files: + print 'looks like {0} misses include for moc_* file'.format(fn) + if fn not in macro_files: + print 'probably {0} has redundant Q_OBJECT macro'.format(fn) + +CheckQObject() diff --git a/devtools/gdb-runTargomanAPI-dev.sh b/devtools/gdb-runTargomanAPI-dev.sh new file mode 100755 index 00000000..9c750fb0 --- /dev/null +++ b/devtools/gdb-runTargomanAPI-dev.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=../out/lib:../out/lib64 +export AWS_EC2_METADATA_DISABLED=true + +gdb --args \ + ../out/bin/targomanAPI --plugins ../out/modules -c ../conf/api.conf --dbprefix dev_ $@ diff --git a/devtools/valgrind-runTargomanAPI-dev.sh b/devtools/valgrind-runTargomanAPI-dev.sh new file mode 100755 index 00000000..780df643 --- /dev/null +++ b/devtools/valgrind-runTargomanAPI-dev.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=../out/lib:../out/lib64 +export AWS_EC2_METADATA_DISABLED=true + +#valgrind --log-file=val.log --show-leak-kinds=all --leak-check=full --undef-value-errors=yes + +valgrind --leak-check=full --undef-value-errors=yes --log-file=val.log \ + ../out/bin/targomanAPI --plugins ../out/modules -c ../conf/api.conf --dbprefix dev_ $@ diff --git a/runTargomanAPI-dev.sh b/runTargomanAPI-dev.sh index e59f80ec..35378273 100755 --- a/runTargomanAPI-dev.sh +++ b/runTargomanAPI-dev.sh @@ -1,4 +1,6 @@ #!/bin/bash export LD_LIBRARY_PATH=out/lib:out/lib64 -AWS_EC2_METADATA_DISABLED=true out/bin/targomanAPI --plugins out/modules -c conf/api.conf --dbprefix dev_ $@ +export AWS_EC2_METADATA_DISABLED=true + +out/bin/targomanAPI --plugins out/modules -c conf/api.conf --dbprefix dev_ $@ diff --git a/runTargomanAPI.sh b/runTargomanAPI.sh index 41e9c8df..82d4daf1 100755 --- a/runTargomanAPI.sh +++ b/runTargomanAPI.sh @@ -1,4 +1,6 @@ #!/bin/bash export LD_LIBRARY_PATH=out/lib:out/lib64 -AWS_EC2_METADATA_DISABLED=true out/bin/targomanAPI --plugins out/modules -c conf/api.conf $@ +export AWS_EC2_METADATA_DISABLED=true + +out/bin/targomanAPI --plugins out/modules -c conf/api.conf $@ diff --git a/unitTest/testNullable.hpp b/unitTest/testNullable.hpp new file mode 100644 index 00000000..f1b2f1d9 --- /dev/null +++ b/unitTest/testNullable.hpp @@ -0,0 +1,139 @@ +#ifndef TESTMACROS_HPP +#define TESTMACROS_HPP + +//#include +//#include +#include +//#include +using namespace std; + +#include "Interfaces/Common/APIArgHelperMacros.hpp" +#include "Interfaces/Common/QtTypes.hpp" +#include "Interfaces/Common/GenericTypes.h" +#include "Interfaces/Helpers/IteratorHelper.hpp" +#include "Interfaces/Helpers/URLHelper.h" + +using namespace Targoman; +using namespace Targoman::API::Helpers; +using namespace TAPI; + +class Code_t : public QString { +public: + Code_t() { ; } + Code_t(const QString& _other) : QString(_other) { ; } +}; + +class testNullable : public QObject +{ + Q_OBJECT + +private: + void func1(tmplNullable s = NULLABLE_NULL_VALUE) { + } + + void func2() { + QString s = "aaa"; + + func1(s); + + tmplNullable s2; + s2 = s; + + tmplNullable s3 = s; + + bool b = s3 == nullopt; + + if ("aaa" == s2) { + + } + } + +private slots: + void testOptional() { + optional a; + a = 1234; + } + + void testQSharedPointer() { + QSharedPointer a = QSharedPointer::create(); + *a = 1234; + } + + void test_bad_Nullable() { + std::optional i1 = 1000; + + //-> OK : stored 1000 + std::map> aa; + aa.insert({ "b_1", i1 }); + + //-> OK : stored 1000 + std::map> bb; + bb.insert({ "b_1", i1 }); + + //-> FAILED : stored null + QMap> cc; + cc.insert( "b_1", i1 ); + + //-> FAILED : stored null + QList> dd; + dd.append(i1); + } + + void test_tmplNullable() { + tmplNullable a; + + a = std::nullopt; + qDebug() << "a=null" << a; + + a = 1234; + qDebug() << "a=1234" << a; + + quint32 b = a.value(); + qDebug() << "b=a.val" << b; + + tmplNullable c = a; + qDebug() << "c=a" << c; + + bool z = a > c; + qDebug() << "a > c : z" << z; + qDebug() << "a > c" << (a > c); + + quint32 o = (a < c) + ? NULLABLE_VALUE(a) + : NULLABLE_VALUE(c); + + QMap> aa; + aa.insert("a", a); + aa.insert("b", b); + aa.insert("c", c); + tmplNullable d; + aa.insert("d", d); + qDebug() << "a,b,c,d(null)" << aa; + + +// TAPI::setFromVariant(a, QVariant()); + + const tmplNullable a2 = std::nullopt; + +// const std::optional a3 = std::nullopt; + + tmplNullable u1, u2; + if (u1 < u2) { + u1 = u2; + } + + if (u1 < 12) { ; } + + if (34 < u2) { ; } + } + +// void test_tmplNullable_JWT_t() { +// tmplNullable