mirror of
https://github.com/silverqx/TinyORM.git
synced 2025-12-30 07:19:34 -06:00
used using enum everywhere
Excluding the ColumnType because it have a lot of names which can collide (it needs more work). Excluding the IncrementOrDecrement in Model as using enum can't name dependent type. See: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1099r5.html
This commit is contained in:
@@ -77,17 +77,13 @@ namespace Concerns
|
||||
/*! Restore all trashed models (call update on deleted_at column, set to null). */
|
||||
std::tuple<int, TSqlQuery> restore();
|
||||
|
||||
/*! Alias for the WithoutTrashed constraint. */
|
||||
constexpr static auto WithoutTrashed = TrashedType::WITHOUT_TRASHED;
|
||||
/*! Alias for the WithTrashed constraint. */
|
||||
constexpr static auto WithTrashed = TrashedType::WITH_TRASHED;
|
||||
/*! Alias for the OnlyTrashed constraint. */
|
||||
constexpr static auto OnlyTrashed = TrashedType::ONLY_TRASHED;
|
||||
|
||||
/*! Get the currently applied soft deletes constraint on the TinyBuilder. */
|
||||
inline TrashedType currentSoftDeletes() const noexcept;
|
||||
|
||||
protected:
|
||||
/*! Expose the TrashedType enum. */
|
||||
using enum TrashedType;
|
||||
|
||||
/*! Get the "deleted at" column for the builder (fully qualified if joins
|
||||
are defined). */
|
||||
QString getDeletedAtColumn(Builder<Model> &builder) const;
|
||||
@@ -96,7 +92,7 @@ namespace Concerns
|
||||
Builder<Model> &applySoftDeletes();
|
||||
|
||||
/*! Stores the currently applied soft deletes constraint on the TinyBuilder. */
|
||||
TrashedType m_trashed = WithoutTrashed;
|
||||
TrashedType m_trashed = WITHOUT_TRASHED;
|
||||
/*! Is the default soft deletes constraint on the TinyBuilder enabled? */
|
||||
bool m_withSoftDeletes = false;
|
||||
|
||||
@@ -162,7 +158,7 @@ namespace Concerns
|
||||
Builder<Model> &
|
||||
BuildsSoftDeletes<Model, T>::withoutTrashed()
|
||||
{
|
||||
m_trashed = WithoutTrashed;
|
||||
m_trashed = WITHOUT_TRASHED;
|
||||
|
||||
/* Disable the default soft deletes constraint on the TinyBuilder because
|
||||
manually overridden and we are applying another whereNull clause here. */
|
||||
@@ -182,7 +178,7 @@ namespace Concerns
|
||||
if (!withTrashed)
|
||||
return withoutTrashed();
|
||||
|
||||
m_trashed = WithTrashed;
|
||||
m_trashed = WITH_TRASHED;
|
||||
|
||||
// Disable the default soft deletes constraint on the TinyBuilder (withoutTrashed)
|
||||
disableSoftDeletes();
|
||||
@@ -194,7 +190,7 @@ namespace Concerns
|
||||
Builder<Model> &
|
||||
BuildsSoftDeletes<Model, T>::onlyTrashed()
|
||||
{
|
||||
m_trashed = OnlyTrashed;
|
||||
m_trashed = ONLY_TRASHED;
|
||||
|
||||
/* Disable the default soft deletes constraint on the TinyBuilder because
|
||||
manually overridden and we are applying another whereNotNull clause here. */
|
||||
|
||||
@@ -423,13 +423,17 @@ namespace Orm::Tiny
|
||||
/*! Method to call in the incrementOrDecrement(). */
|
||||
enum struct IncrementOrDecrement : quint8
|
||||
{
|
||||
/*! Call the increment() method. */
|
||||
INCREMENT,
|
||||
/*! Call the decrement() method. */
|
||||
DECREMENT,
|
||||
};
|
||||
/*! Call the increment() method. */
|
||||
constexpr static auto Increment = IncrementOrDecrement::INCREMENT;
|
||||
/*! Call the decrement() method. */
|
||||
constexpr static auto Decrement = IncrementOrDecrement::DECREMENT;
|
||||
/* Don't use using enum here as it can't name dependent type.
|
||||
See: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1099r5.html */
|
||||
|
||||
/*! Run the increment or decrement method on the model. */
|
||||
template<typename T> requires std::is_arithmetic_v<T>
|
||||
|
||||
@@ -179,12 +179,8 @@ namespace Concerns
|
||||
/*! Show a command not defined error wall. */
|
||||
ShowErrorWall,
|
||||
};
|
||||
/*! Show all commands list using the list command. */
|
||||
constexpr static CommandNotFound
|
||||
ShowCommandsList = CommandNotFound::ShowCommandsList;
|
||||
/*! Show a command not defined error wall. */
|
||||
constexpr static CommandNotFound
|
||||
ShowErrorWall = CommandNotFound::ShowErrorWall;
|
||||
/*! Expose the CommandNotFound enum. */
|
||||
using enum CommandNotFound;
|
||||
|
||||
/*! Get the command name including the guess command name logic. */
|
||||
QString getCommandName(const QString &name, CommandNotFound notFound);
|
||||
|
||||
@@ -81,18 +81,20 @@ namespace Tom::Commands
|
||||
getCommandOptionsSignature(const std::optional<QString> &command) const;
|
||||
|
||||
/*! Option type (long/short). */
|
||||
enum struct OptionType : qint8
|
||||
enum struct OptionType : quint8
|
||||
{
|
||||
UNDEFINED = -1,
|
||||
/*! Consider both long and short option arguments. */
|
||||
ANY,
|
||||
/*! Long option argument. */
|
||||
LONG,
|
||||
/*! Short option argument. */
|
||||
SHORT,
|
||||
};
|
||||
constexpr static auto UNDEFINED = OptionType::UNDEFINED;
|
||||
constexpr static auto LONG = OptionType::LONG;
|
||||
constexpr static auto SHORT = OptionType::SHORT;
|
||||
/*! Expose the OptionType enum. */
|
||||
using enum OptionType;
|
||||
|
||||
/*! Determine whether the given word is an option argument. */
|
||||
static bool isOptionArgument(const QString &wordArg, OptionType type = UNDEFINED);
|
||||
static bool isOptionArgument(const QString &wordArg, OptionType type = ANY);
|
||||
/*! Determine whether the given word is a long option argument. */
|
||||
inline static bool isLongOption(const QString &wordArg);
|
||||
/*! Determine whether the given word is a short option argument. */
|
||||
|
||||
@@ -78,22 +78,19 @@ namespace Concerns
|
||||
/*! Verbosity levels. */
|
||||
enum struct Verbosity : quint8
|
||||
{
|
||||
/*! Quiet verbosity. */
|
||||
Quiet = 0x0001,
|
||||
/*! Normal verbosity (default). */
|
||||
Normal = 0x0002,
|
||||
/*! Verbose verbosity. */
|
||||
Verbose = 0x0004,
|
||||
/*! Very verbose verbosity. */
|
||||
VeryVerbose = 0x0008,
|
||||
/*! Debug verbosity. */
|
||||
Debug = 0x0010,
|
||||
};
|
||||
/*! Quiet verbosity. */
|
||||
constexpr static Verbosity Quiet = Verbosity::Quiet;
|
||||
/*! Normal verbosity (default). */
|
||||
constexpr static Verbosity Normal = Verbosity::Normal;
|
||||
/*! Verbose verbosity. */
|
||||
constexpr static Verbosity Verbose = Verbosity::Verbose;
|
||||
/*! Very verbose verbosity. */
|
||||
constexpr static Verbosity VeryVerbose = Verbosity::VeryVerbose;
|
||||
/*! Debug verbosity. */
|
||||
constexpr static Verbosity Debug = Verbosity::Debug;
|
||||
/*! Expose the Verbosity enum. */
|
||||
using enum Verbosity;
|
||||
|
||||
/*! Write a string as standard output. */
|
||||
const InteractsWithIO &line(const QString &string, bool newline = true,
|
||||
|
||||
@@ -666,7 +666,8 @@ bool CompleteCommand::isOptionArgument(const QString &wordArg, const OptionType
|
||||
const auto isLong = wordArg.startsWith(DoubleDash);
|
||||
const auto isShort = isLong ? false : wordArg.startsWith(DASH);
|
||||
|
||||
if (type == UNDEFINED)
|
||||
// Consider both long and short option arguments
|
||||
if (type == ANY)
|
||||
return isLong || isShort;
|
||||
|
||||
if (type == LONG)
|
||||
|
||||
Reference in New Issue
Block a user