Skip to content

Commit

Permalink
Remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
beckdave committed Jan 22, 2024
1 parent a648867 commit 917bc38
Show file tree
Hide file tree
Showing 107 changed files with 8,329 additions and 8,933 deletions.
22 changes: 10 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ cmake_minimum_required(VERSION 3.11)

project(finalmq)

option(FINALMQ_FETCH_HL7 "Fetches HL7" ON)
option(FINALMQ_BUILD_EXAMPLES "Build examples" ON)
option(FINALMQ_BUILD_TESTS "Build tests" OFF)
option(FINALMQ_BUILD_COVERAGE "Enable gcov" OFF)
option(FINALMQ_BUILD_DOXYGEN "Enable doxygen" OFF)
option(FINALMQ_HAS_NOT_WEAK_FROM_THIS "Has weak_from_this" OFF)

if (WIN32)
# option(FINALMQ_BUILD_FMQFCGI "Build fmqfcgi" OFF) # avoid dependency to fcgi for windows
Expand All @@ -21,8 +23,8 @@ SET(FINALMQ_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(FINALMQ_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})


if (FINALMQ_FETCH_HL7)
include(FetchContent)

function(CloneRepository repositoryURL branchName projectName sourceDir)
#Commands are left empty so that we only checkout the source and no not perform any kind of build
message("Starting to clone ${projectName} into ${sourceDir}")
Expand All @@ -37,8 +39,8 @@ function(CloneRepository repositoryURL branchName projectName sourceDir)
)
FetchContent_MakeAvailable(${projectName})
endfunction(CloneRepository)

CloneRepository("https://github.com/beckdave/hl7-dictionary.git" "beckdave-fix-compounds" "hl7-dictionary" "${FINALMQ_BINARY_DIR}/hl7-dictionary")
endif(FINALMQ_FETCH_HL7)

# Add compile flags to determine coverage
if (FINALMQ_BUILD_COVERAGE)
Expand All @@ -60,14 +62,15 @@ endif(FINALMQ_USE_SSL)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -DNOMINMAX" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )

if (FINALMQ_HAS_NOT_WEAK_FROM_THIS)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFINALMQ_HAS_NOT_WEAK_FROM_THIS" )
endif(FINALMQ_HAS_NOT_WEAK_FROM_THIS)

set(CMAKE_CXX_STANDARD 14)

# this target needs to be set before digging into subdirectories
add_custom_target( verify ${CMAKE_CURRENT_BINARY_DIR}/test/testfinalmq)

message(${CMAKE_CURRENT_BINARY_DIR})

if (FINALMQ_BUILD_COVERAGE)
# go for the latest gcovr version locally installed via pip if available
# since latest only gcov 3.4 supports branch coverage display in html details
Expand Down Expand Up @@ -143,9 +146,6 @@ add_custom_command(
)


#Bring the headers into the project
#include_directories(inc)

#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp" "inc/finalmq/*.h"
"src/helpers/*.cpp" "inc/finalmq/helpers/*.h"
Expand Down Expand Up @@ -189,7 +189,7 @@ target_include_directories(finalmq PUBLIC ${FINALMQ_SOURCE_DIR}/inc)
#target_include_directories(finalmqStatic PUBLIC ${FINALMQ_SOURCE_DIR}/inc)

if (WIN32)
message("== WIN32 ==")
# message("== WIN32 ==")
set(LINKLIBS ${LINKLIBS} wsock32 ws2_32 Rpcrt4)
if (FINALMQ_USE_SSL)
SET(OPENSSL_DIR "$ENV{OPENSSL_ROOT_DIR}")
Expand All @@ -198,13 +198,11 @@ if (WIN32)
set(LINKLIBS ${LINKLIBS} wsock32 ws2_32 Rpcrt4 "${OPENSSL_DIR}/lib/libssl.lib" "${OPENSSL_DIR}/lib/libcrypto.lib")
endif()
target_compile_options(finalmq PRIVATE -DEXPORT_finalmq)
# target_compile_options(finalmqStatic PRIVATE -DEXPORT_finalmq)
elseif(UNIX)
message("== UNIX ==")
# message("== UNIX ==")
target_compile_options(finalmq PRIVATE -Werror -Wall -Wextra)
# target_compile_options(finalmqStatic PRIVATE -Werror -Wall -Wextra)
if (${CMAKE_SYSTEM_NAME} MATCHES "QNX")
message("== QNX ==")
# message("== QNX ==")
else()
set(LINKLIBS ${LINKLIBS} uuid pthread)
endif()
Expand Down
8 changes: 8 additions & 0 deletions codegenerator/cpp/cpp_cpp.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ std::shared_ptr<finalmq::StructBase> <%- plaintype %>::clone() const
return std::make_shared<<%- plaintype %>>(*this);
}
#ifndef WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
bool <%- plaintype %>::operator ==(const <%- plaintype %>& <% if (stru.fields.length == 0) { %>/*<% } %>rhs<% if (stru.fields.length == 0) { %>*/<% } %>) const
{
<% if (stru.fields.length > 0) { %>
Expand All @@ -124,6 +128,10 @@ bool <%- plaintype %>::operator ==(const <%- plaintype %>& <% if (stru.fields.le
return true;
<% } -%>
}
#ifndef WIN32
#pragma GCC diagnostic pop
#endif
bool <%- plaintype %>::operator !=(const <%- plaintype %>& rhs) const
{
return !(*this == rhs);
Expand Down
2 changes: 1 addition & 1 deletion codegenerator/cpp/cpp_h.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SYMBOLEXP <%- plaintype %> : public finalmq::StructBase
public:<% -%>
<% for (var n = 0; n < stru.fields.length; n++) {
field = stru.fields[n] %>
<%- helper.tid2type(data, field) %> <%- helper.avoidCppKeyWords(field.name) %><% if (helper.tid2default(field.tid)){%> = <%- helper.tid2default(field.tid)%><% } %>;<% -%>
<%- helper.tid2type(data, field) %> <%- helper.avoidCppKeyWords(field.name) %>{};<% -%>
<% } %>
<%- plaintype %>();
Expand Down
67 changes: 0 additions & 67 deletions codegenerator/cpp/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,73 +185,6 @@ module.exports = {
}
},

tid2default : function(tid) {

switch (tid)
{
case 'bool':
case 'TYPE_BOOL': return 'false'
case 'int8':
case 'TYPE_INT8': return '0'
case 'uint8':
case 'TYPE_UINT8': return '0'
case 'int16':
case 'TYPE_INT16': return '0'
case 'uint16':
case 'TYPE_UINT16': return '0'
case 'int32':
case 'TYPE_INT32': return '0'
case 'uint32':
case 'TYPE_UINT32': return '0'
case 'int64':
case 'TYPE_INT64': return '0'
case 'uint64':
case 'TYPE_UINT64': return '0'
case 'float':
case 'TYPE_FLOAT': return '0.0'
case 'double':
case 'TYPE_DOUBLE': return '0.0'
case 'string':
case 'TYPE_STRING': return null
case 'bytes':
case 'TYPE_BYTES': return null
case 'struct':
case 'TYPE_STRUCT': return null
case 'enum':
case 'TYPE_ENUM': return null
case 'variant':
case 'TYPE_VARIANT': return null
case 'bool[]':
case 'TYPE_ARRAY_BOOL': return null
case 'int8[]':
case 'TYPE_ARRAY_INT8': return null
case 'int16[]':
case 'TYPE_ARRAY_INT16': return null
case 'uint16[]':
case 'TYPE_ARRAY_UINT16': return null
case 'int32[]':
case 'TYPE_ARRAY_INT32': return null
case 'uint32[]':
case 'TYPE_ARRAY_UINT32': return null
case 'int64[]':
case 'TYPE_ARRAY_INT64': return null
case 'uint64[]':
case 'TYPE_ARRAY_UINT64': return null
case 'float[]':
case 'TYPE_ARRAY_FLOAT': return null
case 'double[]':
case 'TYPE_ARRAY_DOUBLE': return null
case 'string[]':
case 'TYPE_ARRAY_STRING': return null
case 'bytes[]':
case 'TYPE_ARRAY_BYTES': return null
case 'struct[]':
case 'TYPE_ARRAY_STRUCT': return null
case 'enum[]':
case 'TYPE_ARRAY_ENUM': return null
}
},

convertFlags : function(flagArray)
{
var flags = 'finalmq::METAFLAG_NONE'
Expand Down
5 changes: 4 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
add_subdirectory(cpp/helloworld)
add_subdirectory(cpp/timer)
add_subdirectory(cpp/restapi)
add_subdirectory(cpp/hl7)
add_subdirectory(cpp/experimental/registry)
add_subdirectory(cpp/experimental/http)

if (FINALMQ_FETCH_HL7)
add_subdirectory(cpp/hl7)
endif(FINALMQ_FETCH_HL7)
34 changes: 14 additions & 20 deletions inc/finalmq/connectionhub/ConnectionHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@

#include "finalmq/protocolsession/ProtocolSessionContainer.h"


namespace finalmq {


namespace finalmq
{
struct IConnectionHub
{
virtual ~IConnectionHub() {}
virtual ~IConnectionHub()
{}

virtual void init(int cycleTime = 100, int checkReconnectInterval = 1000) = 0;
virtual int bind(const std::string& endpoint, const BindProperties& bindProperties = {}) = 0;
virtual void unbind(const std::string& endpoint) = 0;
virtual IProtocolSessionPtr connect(const std::string& endpoint, const ConnectProperties& connectProperties = {}) = 0;
virtual std::vector< IProtocolSessionPtr > getAllSessions() const = 0;
virtual std::vector<IProtocolSessionPtr> getAllSessions() const = 0;
virtual IProtocolSessionPtr getSession(std::int64_t sessionId) const = 0;
virtual void run() = 0;
virtual void waitForTerminationOfPollerLoop() = 0;
Expand All @@ -46,11 +45,7 @@ struct IConnectionHub
virtual void stopForwardingToSession(std::int64_t sessionId) = 0;
};




class SYMBOLEXP ConnectionHub : public IConnectionHub
, private IProtocolSessionCallback
class SYMBOLEXP ConnectionHub : public IConnectionHub, private IProtocolSessionCallback
{
public:
ConnectionHub();
Expand All @@ -61,7 +56,7 @@ class SYMBOLEXP ConnectionHub : public IConnectionHub
virtual int bind(const std::string& endpoint, const BindProperties& bindProperties = {}) override;
virtual void unbind(const std::string& endpoint) override;
virtual IProtocolSessionPtr connect(const std::string& endpoint, const ConnectProperties& connectProperties = {}) override;
virtual std::vector< IProtocolSessionPtr > getAllSessions() const override;
virtual std::vector<IProtocolSessionPtr> getAllSessions() const override;
virtual IProtocolSessionPtr getSession(std::int64_t sessionId) const override;
virtual void run() override;
virtual void waitForTerminationOfPollerLoop() override;
Expand All @@ -78,14 +73,13 @@ class SYMBOLEXP ConnectionHub : public IConnectionHub
virtual void socketConnected(const IProtocolSessionPtr& session) override;
virtual void socketDisconnected(const IProtocolSessionPtr& session) override;

std::unique_ptr<IProtocolSessionContainer> m_protocolSessionContainer;
std::vector<std::int64_t> m_sessionIdsStopForwardingFromSession;
std::vector<std::int64_t> m_sessionIdsStopForwardingToSession;
bool m_startMessageForwarding = false;
std::vector<std::pair<IProtocolSessionPtr, IMessagePtr>> m_messagesForForwarding;

std::recursive_mutex m_mutex;
std::unique_ptr<IProtocolSessionContainer> m_protocolSessionContainer{};
std::vector<std::int64_t> m_sessionIdsStopForwardingFromSession{};
std::vector<std::int64_t> m_sessionIdsStopForwardingToSession{};
bool m_startMessageForwarding = false;
std::vector<std::pair<IProtocolSessionPtr, IMessagePtr>> m_messagesForForwarding{};

std::recursive_mutex m_mutex{};
};

} // namespace finalmq
} // namespace finalmq
41 changes: 23 additions & 18 deletions inc/finalmq/conversions/Conversions.h
Original file line number Diff line number Diff line change
@@ -1,88 +1,93 @@
#pragma once


#include "finalmq/helpers/FmqDefines.h"
#include <cstdint>
#include <string>

#include "finalmq/helpers/FmqDefines.h"

template <class T>
template<class T>
void string2Number(const std::string& str, T& number)
{
}


template <>
template<>
void string2Number(const std::string& str, bool& number)
{
static const std::string STR_TRUE = "true";
if (str != STR_TRUE)
{
double value = strtof64(str.c_str(), nullptr);
#ifndef WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
if (value == 0)
#ifndef WIN32
#pragma GCC diagnostic pop
#endif
{
number = false;
}
}
number = true;
}

template <>
template<>
void string2Number(const std::string& str, std::int8_t& number)
{
number = static_cast<std::int8_t>(strtol(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::uint8_t& number)
{
number = static_cast<std::uint8_t>(strtoul(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::int16_t& number)
{
number = static_cast<std::int16_t>(strtol(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::uint16_t& number)
{
number = static_cast<std::uint16_t>(strtoul(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::int32_t& number)
{
number = strtol(str.c_str(), nullptr, 10);
number = static_cast<std::int32_t>(strtol(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::uint32_t& number)
{
number = strtoul(str.c_str(), nullptr, 10);
number = static_cast<std::uint32_t>(strtoul(str.c_str(), nullptr, 10));
}

template <>
template<>
void string2Number(const std::string& str, std::int64_t& number)
{
number = strtoll(str.c_str(), nullptr, 10);
}

template <>
template<>
void string2Number(const std::string& str, std::uint64_t& number)
{
number = strtoull(str.c_str(), nullptr, 10);
}

template <>
template<>
void string2Number(const std::string& str, float& number)
{
number = strtof32(str.c_str(), nullptr);
}

template <>
template<>
void string2Number(const std::string& str, double& number)
{
number = strtof64(str.c_str(), nullptr);
}

Loading

0 comments on commit 917bc38

Please sign in to comment.