Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Aug 9, 2024
1 parent ffd7f5a commit d102bb3
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
9 changes: 0 additions & 9 deletions include/AvailablePortQuery.hpp

This file was deleted.

9 changes: 9 additions & 0 deletions include/port_query.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#ifndef SIMPLE_SOCKET_PORT_QUERY_HPP
#define SIMPLE_SOCKET_PORT_QUERY_HPP

#include <vector>

int getAvailablePort(int startPort, int endPort, const std::vector<int>& excludePorts = {});

#endif//SIMPLE_SOCKET_PORT_QUERY_HPP
14 changes: 8 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@

set(sources
AvailablePortQuery.cpp
TCPSocket.cpp
UDPSocket.cpp
WebSocket.cpp
"port_query.cpp"
"TCPSocket.cpp"
"UDPSocket.cpp"
"WebSocket.cpp"
)

add_library(simple_socket ${sources})
add_library(simple_socket "${sources}")
target_compile_features(simple_socket PUBLIC "cxx_std_17")

if (WIN32)
target_link_libraries(simple_socket ws2_32)
target_link_libraries(simple_socket "ws2_32")
endif ()


target_include_directories(simple_socket
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
)
2 changes: 1 addition & 1 deletion src/TCPSocket.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "TCPSocket.hpp"

#include "SocketIncludes.hpp"
#include "common.hpp"


struct TCPSocket::Impl {
Expand Down
2 changes: 1 addition & 1 deletion src/UDPSocket.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "UDPSocket.hpp"

#include "SocketIncludes.hpp"
#include "common.hpp"


struct UDPSocket::Impl {
Expand Down
2 changes: 1 addition & 1 deletion src/WebSocket.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#include "WebSocket.hpp"
#include "SocketIncludes.hpp"
#include "TCPSocket.hpp"
#include "WebSocketHandshake.hpp"
#include "common.hpp"

#include <algorithm>
#include <atomic>
Expand Down
6 changes: 3 additions & 3 deletions src/SocketIncludes.hpp → src/common.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#ifndef SIMPLE_SOCKET_SOCKETINCLUDES_HPP
#define SIMPLE_SOCKET_SOCKETINCLUDES_HPP
#ifndef SIMPLE_SOCKET_COMMON_HPP
#define SIMPLE_SOCKET_COMMON_HPP


#ifdef _WIN32
Expand Down Expand Up @@ -42,4 +42,4 @@ inline void closeSocket(SOCKET socket) {
}


#endif//SIMPLE_SOCKET_SOCKETINCLUDES_HPP
#endif//SIMPLE_SOCKET_COMMON_HPP
4 changes: 2 additions & 2 deletions src/AvailablePortQuery.cpp → src/port_query.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#include "AvailablePortQuery.hpp"
#include "port_query.hpp"

#include "SocketIncludes.hpp"
#include "common.hpp"

#include <algorithm>

Expand Down
2 changes: 1 addition & 1 deletion tests/test_tcp.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "TCPSocket.hpp"
#include "AvailablePortQuery.hpp"
#include "port_query.hpp"

#include <thread>
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_udp.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "UDPSocket.hpp"
#include "AvailablePortQuery.hpp"
#include "port_query.hpp"

#include <catch2/catch_test_macros.hpp>

Expand Down

0 comments on commit d102bb3

Please sign in to comment.