mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-08 18:09:52 -05:00
tom removed unused methods and used std::span<>
This commit is contained in:
@@ -13,8 +13,6 @@ TINY_SYSTEM_HEADER
|
||||
|
||||
#include <range/v3/view/slice.hpp>
|
||||
|
||||
#include <orm/utils/notnull.hpp>
|
||||
|
||||
#include "tom/config.hpp" // IWYU pragma: keep
|
||||
|
||||
#include "tom/concerns/guesscommandname.hpp"
|
||||
@@ -77,13 +75,10 @@ namespace Concerns
|
||||
using ConnectionResolverInterface = Orm::ConnectionResolverInterface;
|
||||
/*! Alias for the DatabaseManager. */
|
||||
using DatabaseManager = Orm::DatabaseManager;
|
||||
/*! Alias for the NotNull. */
|
||||
template<typename T>
|
||||
using NotNull = Orm::Utils::NotNull<T>;
|
||||
|
||||
public:
|
||||
/*! Constructor. */
|
||||
Application(int &argc, char **argv, std::shared_ptr<DatabaseManager> db,
|
||||
Application(int &argc, char *argv[], std::shared_ptr<DatabaseManager> db,
|
||||
const char *environmentEnvName = "TOM_ENV",
|
||||
QString migrationTable = QStringLiteral("migrations"),
|
||||
std::vector<std::shared_ptr<Migration>> migrations = {},
|
||||
@@ -157,11 +152,6 @@ namespace Concerns
|
||||
/*! Alias for the commands' base class. */
|
||||
using Command = Commands::Command;
|
||||
|
||||
/*! Fix m_argc/m_argv data members if the argv is empty. */
|
||||
void fixEmptyArgv();
|
||||
/*! Processes the specified function at application's normal exit. */
|
||||
// static void initializeAtExit();
|
||||
|
||||
/*! Initialize the command-line parser. */
|
||||
void initializeParser(QCommandLineParser &parser);
|
||||
/*! Save a copy of application options passed to the Qt's parser. */
|
||||
@@ -268,9 +258,9 @@ namespace Concerns
|
||||
void throwIfEmptyDefaultConnection() const;
|
||||
|
||||
/*! Current application argc. */
|
||||
NotNull<int *> m_argc;
|
||||
int m_argc;
|
||||
/*! Current application argv. */
|
||||
char **m_argv;
|
||||
std::span<const char *> m_argv;
|
||||
|
||||
/*! DatabaseManager instance. */
|
||||
std::shared_ptr<DatabaseManager> m_db;
|
||||
|
||||
@@ -165,12 +165,14 @@ namespace
|
||||
|
||||
/* public */
|
||||
|
||||
Application::Application(int &argc, char **argv, std::shared_ptr<DatabaseManager> db,
|
||||
/* Can't change it to const char *argv[] and const int argc because we are passing them
|
||||
down to the QCoreApplication() and it needs non-const values. */
|
||||
Application::Application(int &argc, char *argv[], std::shared_ptr<DatabaseManager> db, // NOLINT(modernize-avoid-c-arrays)
|
||||
const char *const environmentEnvName, QString migrationTable,
|
||||
std::vector<std::shared_ptr<Migration>> migrations,
|
||||
std::vector<std::shared_ptr<Seeder>> seeders)
|
||||
: m_argc(&argc)
|
||||
, m_argv(argv)
|
||||
: m_argc(argc)
|
||||
, m_argv(const_cast<const char **>(argv), argc)
|
||||
, m_db(std::move(db))
|
||||
, m_qtApplication(createQCoreApplication(argc, argv))
|
||||
, m_environmentEnvName(environmentEnvName)
|
||||
@@ -189,12 +191,6 @@ Application::Application(int &argc, char **argv, std::shared_ptr<DatabaseManager
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("tinyorm.org"));
|
||||
QCoreApplication::setApplicationVersion(TINYTOM_VERSION_STR);
|
||||
|
||||
// Print a newline at application's normal exit
|
||||
// initializeAtExit();
|
||||
|
||||
// Fix m_argc/m_argv data members if the argv is empty
|
||||
fixEmptyArgv();
|
||||
|
||||
// Initialize the command-line parser
|
||||
initializeParser(m_parser);
|
||||
}
|
||||
@@ -277,25 +273,6 @@ void Application::enableInUnitTests() noexcept
|
||||
|
||||
/* protected */
|
||||
|
||||
void Application::fixEmptyArgv()
|
||||
{
|
||||
constexpr static const auto *const empty = "";
|
||||
|
||||
if (*m_argc == 0 || m_argv == nullptr) {
|
||||
*m_argc = 0;
|
||||
m_argv = const_cast<char **>(&empty); // NOLINT(cppcoreguidelines-pro-type-const-cast)
|
||||
}
|
||||
}
|
||||
|
||||
// CUR tom, remove? silverqx
|
||||
//void Application::initializeAtExit()
|
||||
//{
|
||||
// std::atexit([]
|
||||
// {
|
||||
// std::cout << std::endl;
|
||||
// });
|
||||
//}
|
||||
|
||||
void Application::initializeParser(QCommandLineParser &parser)
|
||||
{
|
||||
parser.setApplicationDescription(
|
||||
@@ -650,10 +627,10 @@ std::shared_ptr<Migrator> Application::createMigrator() const
|
||||
QStringList Application::prepareArguments() const
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments.reserve(*m_argc);
|
||||
arguments.reserve(m_argc);
|
||||
|
||||
for (QStringList::size_type i = 0; i < *m_argc; ++i)
|
||||
arguments << QString::fromUtf8(m_argv[i]); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
for (const auto *const argv : m_argv)
|
||||
arguments << QString::fromUtf8(argv);
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user