Skip to content

Commit

Permalink
Added projstdafx.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio3rs committed Jan 12, 2024
1 parent a47f12c commit 72cca8f
Show file tree
Hide file tree
Showing 35 changed files with 114 additions and 95 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ if (NOT DEFINED USING_COMPILER_FLAGS)
# Clang-tidy
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "Setting clang-tidy flags")
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-header-filter=${CMAKE_CURRENT_SOURCE_DIR}/src;--warnings-as-errors=\"*\";-extra-arg=-std=gnu++20;-extra-arg=-Wno-gnu;-export-fixes=clang-tidy-sugested-fixes.txt")
#set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-header-filter=${CMAKE_CURRENT_SOURCE_DIR}/src;--warnings-as-errors=\"*\";-extra-arg=-std=gnu++20;-extra-arg=-Wno-gnu;-export-fixes=clang-tidy-sugested-fixes.txt")
endif()
endif()
endif()

target_precompile_headers(${projectname} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/stdafx.hpp")
target_precompile_headers(${projectname} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/projstdafx.hpp")

# verifica se o poco foi encontrado e faz o link com a lib
if(Poco_FOUND)
Expand Down
6 changes: 1 addition & 5 deletions src/CacheUtils/Cache.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include "Cache.hpp"
#include "../utils/RedisService.hpp"
#include "../utils/Strutils.hpp"
#include <Poco/Redis/Type.h>
#include <string>
#include "../projstdafx.hpp"

namespace cache_utils {
std::string Cache::prefix = "apicache:";
Expand Down
4 changes: 1 addition & 3 deletions src/Database/CSql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* @copyright Copyright (c) 2021
*
*/
#include "CSql.hpp"
#include <iomanip>
#include <utility>
#include "../projstdafx.hpp"

auto CSql::instance() -> CSql & {
static CSql sql;
Expand Down
6 changes: 1 addition & 5 deletions src/Database/DBMigrate.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include "DBMigrate.hpp"
#include "../stdafx.hpp"
#include <cppconn/prepared_statement.h>
#include <memory>
#include <utility>
#include "../projstdafx.hpp"

namespace Database {
static auto connect_db(const DatabaseAddress &info) {
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Migration.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "Migration.hpp"
#include "../projstdafx.hpp"

Database::Migration::~Migration() = default;
2 changes: 1 addition & 1 deletion src/JSON/StructParser.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StructParser.hpp"
#include "../projstdafx.hpp"

JSONStructParser::StructFiller::~StructFiller() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/PistacheCustomHttpHeaders/LastModified.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "LastModified.hpp"
#include "../projstdafx.hpp"

PistacheCustomHttpHeaders::LastModified::~LastModified() = default;
8 changes: 1 addition & 7 deletions src/WebInterface/CController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
* @copyright Copyright (c) 2021
*
*/
#include "CController.hpp"
#include "../utils/DocAPI.hpp"
#include "../utils/PocoJsonStringify.hpp"
#include "../utils/Validator.hpp"
#include <Poco/Crypto/CryptoException.h>
#include <exception>
#include <fstream>
#include "../projstdafx.hpp"

const Pistache::Http::Mime::MediaType CController::JSON_RETURN =
Pistache::Http::Mime::MediaType(Pistache::Http::Mime::Type::Application,
Expand Down
2 changes: 1 addition & 1 deletion src/WebInterface/CPistacheEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @copyright Copyright (c) 2021
*
*/
#include "CPistacheEndpoint.hpp"
#include "../projstdafx.hpp"

CPistacheEndpoint::CPistacheEndpoint() = default;

Expand Down
2 changes: 1 addition & 1 deletion src/WebInterface/JsonResponse.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "JsonResponse.hpp"
#include "../projstdafx.hpp"

namespace httpwrappers {
JsonResponse::~JsonResponse() = default;
Expand Down
2 changes: 1 addition & 1 deletion src/WebInterface/WebApp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "WebApp.hpp"
#include "../projstdafx.hpp"

namespace webapp {
WebApp::~WebApp() { stop(); }
Expand Down
3 changes: 1 addition & 2 deletions src/WebInterface/WebInputValidator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "WebInputValidator.hpp"
#include "CController.hpp"
#include "../projstdafx.hpp"

auto WebInputValidator::validate() -> bool {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/WebInterface/httpwrappers.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "httpwrappers.hpp"
#include "../projstdafx.hpp"

namespace httpwrappers {

Expand Down
4 changes: 2 additions & 2 deletions src/WebSocket/HandshakeWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Library for hashing and base64 functions
*/

#include "HandshakeWebSocket.hpp"
#include <Poco/Base64Encoder.h>
#include "../projstdafx.hpp"

#include <cassert>
#include <openssl/ssl.h>

Expand Down
12 changes: 1 addition & 11 deletions src/WebSocket/RouterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
* @brief Test/dev code for websockets with pistache rest websever
*/

#include "RouterHandler.hpp"
#include "../stdafx.hpp"
#include "../utils/LogUtils.hpp"
#include "WebSocketHandler.hpp"
#include <cstddef>
#include <cstdint>
#include <exception>
#include <memory>
#include <pistache/http.h>
#include <pistache/peer.h>
#include <utility>
#include "../projstdafx.hpp"

void RouterHandlerProxy::onConnection(
const std::shared_ptr<Pistache::Tcp::Peer> &peer) {
Expand Down
6 changes: 1 addition & 5 deletions src/WebSocket/WebSocketHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/*
* @brief Test/dev code for websockets with pistache rest websever
*/

#include "WebSocketHandler.hpp"
#include <cstddef>
#include <pistache/peer.h>
#include <tuple>
#include "../projstdafx.hpp"

// NOLINTNEXTLINE
auto WebSocketHandler::frame::receiveData(const char *buffer, size_t lenraw)
Expand Down
3 changes: 1 addition & 2 deletions src/boot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "boot.hpp"
#include "utils/CConfig.hpp"
#include "projstdafx.hpp"

// NOLINTNEXTLINE(hicpp-avoid-c-arrays, modernize-avoid-c-arrays)
auto apiframework::mainboot(int /* argc */, char * /* argv */[], char **envp) -> int {
Expand Down
5 changes: 1 addition & 4 deletions src/jobhandler/JobsHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include "JobsHandler.hpp"
#include "../utils/ScopedStreamRedirect.hpp"
#include <Poco/Exception.h>
#include <fstream>
#include "../projstdafx.hpp"

auto job::JobsHandler::default_instance() -> std::shared_ptr<JobsHandler> {
static std::shared_ptr<JobsHandler> instance(
Expand Down
8 changes: 2 additions & 6 deletions src/jobhandler/QueueWorker.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "QueueWorker.hpp"
#include "../utils/LogDefines.hpp"
#include "JobsHandler.hpp"
#include <Poco/Exception.h>
#include <exception>
#include <string>
#include "../projstdafx.hpp"

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion src/jobhandler/QueueableJob.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "QueueableJob.hpp"
#include "../projstdafx.hpp"

job::QueueableJob::QueueableJob() = default;

Expand Down
62 changes: 62 additions & 0 deletions src/projstdafx.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#pragma once

#include "stdafx.hpp"

#include "CacheUtils/Cache.hpp"
#include "Database/CSql.hpp"
#include "Database/DBMigrate.hpp"
#include "Database/GenericDBConnection.hpp"
#include "Database/Migration.hpp"
#include "Mail/Mail.hpp"
#include "PistacheCustomHttpHeaders/LastModified.hpp"
#include "SSLUtils/InitClient.hpp"
#include "Storage/Storage.hpp"
#include "WebControllers/CStorageController.hpp"
#include "WebInterface/CController.hpp"
#include "WebInterface/CPistacheEndpoint.hpp"
#include "WebInterface/JsonResponse.hpp"
#include "WebInterface/WebApp.hpp"
#include "WebInterface/WebInputValidator.hpp"
#include "WebInterface/httpwrappers.hpp"
#include "WebInterface/pistache.hpp"
#include "WebSocket/HandshakeWebSocket.hpp"
#include "WebSocket/RouterHandler.hpp"
#include "WebSocket/WebSocketHandler.hpp"
#include "boot.hpp"
#include "jobhandler/JobsHandler.hpp"
#include "jobhandler/QueueWorker.hpp"
#include "jobhandler/QueueableJob.hpp"
#include "queues/GenericQueue.hpp"
#include "queues/LuaScripts.hpp"
#include "queues/RedisQueue.hpp"
#include "queues/StdQueue.hpp"
#include "short_types.hpp"
#include "stdafx.hpp"
#include "utils/BorrowPool.hpp"
#include "utils/CConfig.hpp"
#include "utils/CHttpPool.hpp"
#include "utils/CLog.hpp"
#include "utils/ChronoUtils.hpp"
#include "utils/CircleMTIO.hpp"
#include "utils/ControllerInputModifier.hpp"
#include "utils/ControllerInputValidator.hpp"
#include "utils/DocAPI.hpp"
#include "utils/InputValidators.hpp"
#include "utils/LogDefines.hpp"
#include "utils/LogUtils.hpp"
#include "utils/NestedJson.hpp"
#include "utils/PocoJsonStringify.hpp"
#include "utils/PocoJsonStringifyBorrowed.hpp"
#include "utils/ProcessHelper.hpp"
#include "utils/RedisService.hpp"
#include "utils/Result.hpp"
#include "utils/ResultMacros.hpp"
#include "utils/ScopedStreamRedirect.hpp"
#include "utils/ShortValidationsName.hpp"
#include "utils/StrFormat.hpp"
#include "utils/Strutils.hpp"
#include "utils/Validator.hpp"
#include "utils/primitivepairhash.hpp"
#include "utils/stringviewstream.hpp"
#include "JSON/StructParser.hpp"
#include "JSON/StructParserMacros.hpp"
2 changes: 1 addition & 1 deletion src/queues/GenericQueue.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "GenericQueue.hpp"
#include "../projstdafx.hpp"

GenericQueue::GenericQueue() = default;

Expand Down
12 changes: 1 addition & 11 deletions src/queues/RedisQueue.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#include "RedisQueue.hpp"
#include "../utils/RedisService.hpp"
#include <Poco/Redis/Array.h>
#include <Poco/Redis/Command.h>
#include <Poco/Redis/Type.h>
#include <chrono>
#include <cstdint>
#include <ctime>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include "../projstdafx.hpp"

namespace {
auto RedisToBulkString(const Poco::Redis::RedisType::Ptr &element)
Expand Down
2 changes: 1 addition & 1 deletion src/queues/StdQueue.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "StdQueue.hpp"
#include "../projstdafx.hpp"

void StdQueue::push(const std::string &queue, const std::string &data) {
queue_map[queue].push_back(data);
Expand Down
1 change: 1 addition & 0 deletions src/stdafx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Database/GenericDBConnection.hpp"
#include "utils/CConfig.hpp"
#include <Poco/Base64Encoder.h>
#include <Poco/Crypto/DigestEngine.h>
#include <Poco/Dynamic/Var.h>
#include <Poco/HMACEngine.h>
Expand Down
3 changes: 1 addition & 2 deletions src/utils/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* @version 0.1
*
*/
#include "CConfig.hpp"
#include <algorithm>
#include "../projstdafx.hpp"

auto CConfig::config() -> CConfig & {
static CConfig conf;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CHttpPool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CHttpPool.hpp"
#include "../projstdafx.hpp"

auto CHttpPool::default_inst() -> CHttpPool & {
static CHttpPool pool;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/CLog.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../projstdafx.hpp"

#include "CLog.hpp"
#include "ChronoUtils.hpp"
#include "CircleMTIO.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/utils/DocAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DocAPI.hpp"
#include "../projstdafx.hpp"

#include <Poco/UTF8Encoding.h>
#include <Poco/UTF8String.h>

Expand Down
4 changes: 1 addition & 3 deletions src/utils/InputValidators.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "InputValidators.hpp"
#include "ControllerInputValidator.hpp"
#include <utility>
#include "../projstdafx.hpp"

auto ObjectValidator::validate(std::string_view fieldname,
const Poco::Dynamic::Var &valchk)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ProcessHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ProcessHelper.hpp"
#include "../utils/CLog.hpp"
#include "../projstdafx.hpp"

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
Expand Down
6 changes: 1 addition & 5 deletions src/utils/RedisService.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include "RedisService.hpp"
#include "CConfig.hpp"
#include "PocoJsonStringify.hpp"
#include <exception>
#include <string>
#include "../projstdafx.hpp"

auto RedisService::default_inst() -> RedisService & {
static RedisService instance;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/Validator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "Validator.hpp"
#include "CConfig.hpp"
#include "../projstdafx.hpp"

auto ValidatorException::to_json() const -> Poco::JSON::Object::Ptr {
Poco::JSON::Object::Ptr result = new Poco::JSON::Object;
Expand Down
8 changes: 8 additions & 0 deletions tests/allocation_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
void operator delete(void *ptr, size_t blksize) noexcept;

static std::atomic<std::size_t> allocations{0};
static std::atomic<std::size_t> allocationSize{0};
static std::atomic<std::size_t> deallocations{0};

auto operator new(std::size_t n) -> void * {
++allocations;
allocationSize += n;
return malloc(n); // NOLINT(hicpp-no-malloc)
}

Expand All @@ -26,6 +28,12 @@ auto AllocationCount::getAllocationCount() -> std::atomic<std::size_t> & {
return allocations;
}

auto AllocationCount::getAllocationSize() -> std::atomic<std::size_t> & {
return allocationSize;
}

auto AllocationCount::getDeallocationCount() -> std::atomic<std::size_t> & {
return deallocations;
}

auto AllocationCount::optimizationBarrier(void *ptr) -> void { (void)ptr; }
10 changes: 6 additions & 4 deletions tests/allocation_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#include <atomic>
#include <cstdint>

class AllocationCount{
class AllocationCount {

public:
static auto getAllocationCount() -> std::atomic<std::size_t>&;
static auto getDeallocationCount() -> std::atomic<std::size_t>&;
public:
static auto getAllocationCount() -> std::atomic<std::size_t> &;
static auto getAllocationSize() -> std::atomic<std::size_t> &;
static auto getDeallocationCount() -> std::atomic<std::size_t> &;

static auto optimizationBarrier(void *ptr) -> void;
};

0 comments on commit 72cca8f

Please sign in to comment.