Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 13, 2024
1 parent b8ee185 commit a406060
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 92 deletions.
5 changes: 3 additions & 2 deletions Cutelyst/Plugins/Utils/Validator/validatordigitsbetween.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ ValidatorReturnType ValidatorDigitsBetween::validate(Context *c, const ParamsMul

if (_min > _max) {
result.errorMessage = validationDataError(c);
qCWarning(C_VALIDATOR).noquote() << debugString(c) << "Minimum comparison length" << _min
<< "is larger than" << "maximum comparison length" << _max;
qCWarning(C_VALIDATOR).noquote()
<< debugString(c) << "Minimum comparison length" << _min << "is larger than"
<< "maximum comparison length" << _max;
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions Cutelyst/Plugins/Utils/Validator/validatordomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ ValidatorReturnType ValidatorDomain::validate(Context *c, const ParamsMultiMap &
case LabelTooLong:
qCDebug(C_VALIDATOR).noquote()
<< debugString(c)
<< "At least on of the domain name labels exceeds the maximum" << "size of"
<< ValidatorDomainPrivate::maxDnsLabelLength << "characters";
<< "At least on of the domain name labels exceeds the maximum"
<< "size of" << ValidatorDomainPrivate::maxDnsLabelLength << "characters";
break;
case TooLong:
qCDebug(C_VALIDATOR).noquote()
Expand Down
5 changes: 3 additions & 2 deletions Cutelyst/Plugins/Utils/Validator/validatorfilesize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ bool ValidatorFileSize::validate(const QString &value,
(startsWith == ValidatorFileSizePrivate::StartsWith::SymbolPart))) {
digitPart.append(ch);
} else {
qCDebug(C_VALIDATOR).nospace() << "ValidatorFileSize: Validation failed for "
<< value << ": " << "symbol inside digit part";
qCDebug(C_VALIDATOR).nospace()
<< "ValidatorFileSize: Validation failed for " << value << ": "
<< "symbol inside digit part";
valid = false;
break;
}
Expand Down
261 changes: 175 additions & 86 deletions cmd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,41 @@ bool buildApplicationImplementation(const QString &filename, const QString &appN
if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
QFileInfo fileInfo(filename);
out << "#include \"" << fileInfo.baseName() << ".h\"" << "\n";
out << "#include \"" << fileInfo.baseName() << ".h\""
<< "\n";
out << "\n";
out << "#include \"root.h\"" << "\n";
out << "#include \"root.h\""
<< "\n";
out << "\n";
out << "using namespace Cutelyst;" << "\n";
out << "using namespace Cutelyst;"
<< "\n";
out << "\n";
out << appName << "::" << appName << "(QObject *parent) : Application(parent)" << "\n";
out << "{" << "\n";
out << "}" << "\n";
out << appName << "::" << appName << "(QObject *parent) : Application(parent)"
<< "\n";
out << "{"
<< "\n";
out << "}"
<< "\n";
out << "\n";
out << appName << "::~" << appName << "()" << "\n";
out << "{" << "\n";
out << "}" << "\n";
out << appName << "::~" << appName << "()"
<< "\n";
out << "{"
<< "\n";
out << "}"
<< "\n";
out << "\n";
out << "bool " << appName << "::init" << "()" << "\n";
out << "{" << "\n";
out << " new Root(this);" << "\n";
out << "bool " << appName << "::init"
<< "()"
<< "\n";
out << "{"
<< "\n";
out << " new Root(this);"
<< "\n";
out << "\n";
out << " return true;" << "\n";
out << "}" << "\n";
out << " return true;"
<< "\n";
out << "}"
<< "\n";
out << "\n";

std::cout << OUT_CREATED << qPrintable(filename) << std::endl;
Expand All @@ -125,25 +140,39 @@ bool buildApplicationHeader(const QString &filename, const QString &appName)

if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
out << "#ifndef " << appName.toUpper() << "_H" << "\n";
out << "#define " << appName.toUpper() << "_H" << "\n";
out << "#ifndef " << appName.toUpper() << "_H"
<< "\n";
out << "#define " << appName.toUpper() << "_H"
<< "\n";
out << "\n";
out << "#include <Cutelyst/Application>" << "\n";
out << "#include <Cutelyst/Application>"
<< "\n";
out << "\n";
out << "using namespace Cutelyst;" << "\n";
out << "using namespace Cutelyst;"
<< "\n";
out << "\n";
out << "class " << appName << " : public Application" << "\n";
out << "{" << "\n";
out << " Q_OBJECT" << "\n";
out << " CUTELYST_APPLICATION(IID \"" << appName << "\")" << "\n";
out << "public:" << "\n";
out << " Q_INVOKABLE explicit " << appName << "(QObject *parent = nullptr);" << "\n";
out << " ~" << appName << "();" << "\n";
out << "class " << appName << " : public Application"
<< "\n";
out << "{"
<< "\n";
out << " Q_OBJECT"
<< "\n";
out << " CUTELYST_APPLICATION(IID \"" << appName << "\")"
<< "\n";
out << "public:"
<< "\n";
out << " Q_INVOKABLE explicit " << appName << "(QObject *parent = nullptr);"
<< "\n";
out << " ~" << appName << "();"
<< "\n";
out << "\n";
out << " bool init();" << "\n";
out << "};" << "\n";
out << " bool init();"
<< "\n";
out << "};"
<< "\n";
out << "\n";
out << "#endif //" << appName.toUpper() << "_H" << "\n";
out << "#endif //" << appName.toUpper() << "_H"
<< "\n";
out << "\n";

std::cout << OUT_CREATED << qPrintable(filename) << std::endl;
Expand All @@ -170,35 +199,54 @@ bool buildControllerImplementation(const QString &filename,
if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
QFileInfo fileInfo(filename);
out << "#include \"" << fileInfo.baseName() << ".h\"" << "\n";
out << "#include \"" << fileInfo.baseName() << ".h\""
<< "\n";
out << "\n";
out << "using namespace Cutelyst;" << "\n";
out << "using namespace Cutelyst;"
<< "\n";
out << "\n";
out << controllerName << "::" << controllerName << "(QObject *parent) : Controller(parent)"
<< "\n";
out << "{" << "\n";
out << "}" << "\n";
out << "{"
<< "\n";
out << "}"
<< "\n";
out << "\n";
out << controllerName << "::~" << controllerName << "()" << "\n";
out << "{" << "\n";
out << "}" << "\n";
out << controllerName << "::~" << controllerName << "()"
<< "\n";
out << "{"
<< "\n";
out << "}"
<< "\n";
out << "\n";
out << "void " << controllerName << "::index" << "(Context *c)" << "\n";
out << "{" << "\n";
out << "void " << controllerName << "::index"
<< "(Context *c)"
<< "\n";
out << "{"
<< "\n";
if (helpers) {
out << " c->response()->body() = \"Welcome to Cutelyst!\";" << "\n";
out << " c->response()->body() = \"Welcome to Cutelyst!\";"
<< "\n";
} else {
out << " c->response()->body() = \"Matched Controller::" << controllerName << " in "
<< controllerName << ".\";" << "\n";
<< controllerName << ".\";"
<< "\n";
}
out << "}" << "\n";
out << "}"
<< "\n";
out << "\n";
if (helpers) {
out << "void " << controllerName << "::defaultPage" << "(Context *c)" << "\n";
out << "{" << "\n";
out << " c->response()->body() = \"Page not found!\";" << "\n";
out << " c->response()->setStatus(404);" << "\n";
out << "}" << "\n";
out << "void " << controllerName << "::defaultPage"
<< "(Context *c)"
<< "\n";
out << "{"
<< "\n";
out << " c->response()->body() = \"Page not found!\";"
<< "\n";
out << " c->response()->setStatus(404);"
<< "\n";
out << "}"
<< "\n";
out << "\n";
}

Expand All @@ -223,37 +271,56 @@ bool buildControllerHeader(const QString &filename, const QString &controllerNam

if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
out << "#ifndef " << controllerName.toUpper() << "_H" << "\n";
out << "#define " << controllerName.toUpper() << "_H" << "\n";
out << "#ifndef " << controllerName.toUpper() << "_H"
<< "\n";
out << "#define " << controllerName.toUpper() << "_H"
<< "\n";
out << "\n";
out << "#include <Cutelyst/Controller>" << "\n";
out << "#include <Cutelyst/Controller>"
<< "\n";
out << "\n";
out << "using namespace Cutelyst;" << "\n";
out << "using namespace Cutelyst;"
<< "\n";
out << "\n";
out << "class " << controllerName << " : public Controller" << "\n";
out << "{" << "\n";
out << " Q_OBJECT" << "\n";
out << "class " << controllerName << " : public Controller"
<< "\n";
out << "{"
<< "\n";
out << " Q_OBJECT"
<< "\n";
if (helpers) {
out << " C_NAMESPACE(\"\")" << "\n";
out << " C_NAMESPACE(\"\")"
<< "\n";
}
out << "public:" << "\n";
out << " explicit " << controllerName << "(QObject *parent = nullptr);" << "\n";
out << " ~" << controllerName << "();" << "\n";
out << "public:"
<< "\n";
out << " explicit " << controllerName << "(QObject *parent = nullptr);"
<< "\n";
out << " ~" << controllerName << "();"
<< "\n";
out << "\n";
out << " C_ATTR(index, :Path :AutoArgs)" << "\n";
out << " void index(Context *c);" << "\n";
out << " C_ATTR(index, :Path :AutoArgs)"
<< "\n";
out << " void index(Context *c);"
<< "\n";
if (helpers) {
out << "\n";
out << " C_ATTR(defaultPage, :Path)" << "\n";
out << " void defaultPage(Context *c);" << "\n";
out << " C_ATTR(defaultPage, :Path)"
<< "\n";
out << " void defaultPage(Context *c);"
<< "\n";
out << "\n";
out << "private:\n";
out << " C_ATTR(End, :ActionClass(\"RenderView\"))" << "\n";
out << " void End(Context *c) { Q_UNUSED(c); }" << "\n";
out << " C_ATTR(End, :ActionClass(\"RenderView\"))"
<< "\n";
out << " void End(Context *c) { Q_UNUSED(c); }"
<< "\n";
}
out << "};" << "\n";
out << "};"
<< "\n";
out << "\n";
out << "#endif //" << controllerName.toUpper() << "_H" << "\n";
out << "#endif //" << controllerName.toUpper() << "_H"
<< "\n";
out << "\n";

std::cout << OUT_CREATED << qPrintable(filename) << std::endl;
Expand All @@ -277,22 +344,34 @@ bool buildSrcCMakeLists(const QString &name, const QString &appName)

if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
out << "file(GLOB_RECURSE " << appName << "_SRCS *.cpp *.h)" << "\n";
out << "file(GLOB_RECURSE " << appName << "_SRCS *.cpp *.h)"
<< "\n";
out << "\n";
out << "set(" << appName << "_SRCS" << "\n";
out << " ${" << appName << "_SRCS}" << "\n";
out << " ${TEMPLATES_SRC}" << "\n";
out << ")" << "\n";
out << "set(" << appName << "_SRCS"
<< "\n";
out << " ${" << appName << "_SRCS}"
<< "\n";
out << " ${TEMPLATES_SRC}"
<< "\n";
out << ")"
<< "\n";
out << "\n";
out << "# Create the application" << "\n";
out << "add_library(" << appName << " SHARED ${" << appName << "_SRCS})" << "\n";
out << "# Create the application"
<< "\n";
out << "add_library(" << appName << " SHARED ${" << appName << "_SRCS})"
<< "\n";
out << "\n";
out << "# Link to Cutelyst" << "\n";
out << "# Link to Cutelyst"
<< "\n";
out << "target_link_libraries(" << appName << "\n";
out << " Cutelyst::Core" << "\n";
out << " Qt::Core" << "\n";
out << " Qt::Network" << "\n";
out << ")" << "\n";
out << " Cutelyst::Core"
<< "\n";
out << " Qt::Core"
<< "\n";
out << " Qt::Network"
<< "\n";
out << ")"
<< "\n";
out << "\n";

std::cout << OUT_CREATED << qPrintable(name) << std::endl;
Expand All @@ -316,9 +395,11 @@ bool buildProjectCMakeLists(const QString &name, const QString &appName)

if (data.open(QFile::WriteOnly | QFile::Truncate)) {
QTextStream out(&data);
out << "cmake_minimum_required(VERSION 3.16 FATAL_ERROR)" << "\n";
out << "cmake_minimum_required(VERSION 3.16 FATAL_ERROR)"
<< "\n";
out << "\n";
out << "project(" << appName << ")" << "\n";
out << "project(" << appName << ")"
<< "\n";
out << "\n";
out << "if(WIN32)\n";
out << " if(MSVC)\n";
Expand All @@ -329,18 +410,26 @@ bool buildProjectCMakeLists(const QString &name, const QString &appName)
out << "find_package(Qt" << QT_VERSION_MAJOR << " COMPONENTS Core Network REQUIRED)"
<< "\n";
out << "find_package(Cutelyst" << CUTELYST_VERSION_MAJOR << "Qt" << QT_VERSION_MAJOR
<< " REQUIRED)" << "\n";
<< " REQUIRED)"
<< "\n";
out << "\n";
out << "# Auto generate moc files" << "\n";
out << "set(CMAKE_AUTOMOC ON)" << "\n";
out << "# Auto generate moc files"
<< "\n";
out << "set(CMAKE_AUTOMOC ON)"
<< "\n";
out << "\n";
out << "# As moc files are generated in the binary dir, tell CMake" << "\n";
out << "# to always look for includes there:" << "\n";
out << "set(CMAKE_INCLUDE_CURRENT_DIR ON)" << "\n";
out << "# As moc files are generated in the binary dir, tell CMake"
<< "\n";
out << "# to always look for includes there:"
<< "\n";
out << "set(CMAKE_INCLUDE_CURRENT_DIR ON)"
<< "\n";
out << "\n";
out << "file(GLOB_RECURSE TEMPLATES_SRC root/*)" << "\n";
out << "file(GLOB_RECURSE TEMPLATES_SRC root/*)"
<< "\n";
out << "\n";
out << "add_subdirectory(src)" << "\n";
out << "add_subdirectory(src)"
<< "\n";

std::cout << OUT_CREATED << qPrintable(name) << std::endl;

Expand Down

0 comments on commit a406060

Please sign in to comment.