From f1d1d0849ef372a966cd07044936bc8d9c9694cd Mon Sep 17 00:00:00 2001 From: miaodx Date: Mon, 29 May 2017 09:34:40 +0800 Subject: [PATCH 1/2] reorganize the include files according to the `SSL_ENABLED` flag. So that we can build without ssl support. --- src/SSLListener.cpp | 3 ++- src/SSLSocket.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SSLListener.cpp b/src/SSLListener.cpp index 1c0d4fc..cb6db1e 100644 --- a/src/SSLListener.cpp +++ b/src/SSLListener.cpp @@ -3,11 +3,12 @@ // #include -#include #include #include "frnetlib/SSLListener.h" #ifdef SSL_ENABLED +#include + namespace fr { SSLListener::SSLListener(std::shared_ptr ssl_context_, const std::string &crt_path, const std::string &pem_path, const std::string &private_key_path) noexcept diff --git a/src/SSLSocket.cpp b/src/SSLSocket.cpp index 283b3cb..cae2aed 100644 --- a/src/SSLSocket.cpp +++ b/src/SSLSocket.cpp @@ -4,10 +4,11 @@ #include "frnetlib/SSLSocket.h" #include -#include #ifdef SSL_ENABLED +#include + namespace fr { SSLSocket::SSLSocket(std::shared_ptr ssl_context_) noexcept From 1de53ef6e85e4c2db3028f8f0c8cedec609624dc Mon Sep 17 00:00:00 2001 From: miaodx Date: Mon, 29 May 2017 09:42:01 +0800 Subject: [PATCH 2/2] add some examples. --- examples/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ examples/packet.cpp | 14 ++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/packet.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..7b32747 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.5) +project(frnetlib_test) + +if( WIN32 ) + set( ADDITIONAL_LIB ws2_32 ) # Ws2_32.lib + + set( FRNETLIB_ROOT_PATH "C:/tools/cmake_install_libs/frnetlib/" ) # change it to your install directory + + set( FRNETLIB_INCLUDE_PATH ${FRNETLIB_ROOT_PATH}/include ) + set( FRNETLIB_LIB ${FRNETLIB_ROOT_PATH}/lib/frnetlib-s-d.lib ) + + include_directories( ${FRNETLIB_INCLUDE_PATH} ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -std=c++14") + +elseif(APPLE) + set( ADDITIONAL_LIB "" ) +else() + set( ADDITIONAL_LIB "" ) + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -m64 -fPIC -std=c++14 -pthread -lmbedtls -lmbedx509 -lmbedcrypto") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -m64 -fPIC -std=c++14 -pthread") +endif() + + +add_executable(${PROJECT_NAME} ../main.cpp) +add_executable(packet packet.cpp) + + +target_link_libraries(${PROJECT_NAME} ${FRNETLIB_LIB} ${ADDITIONAL_LIB}) +target_link_libraries(packet ${FRNETLIB_LIB} ${ADDITIONAL_LIB}) \ No newline at end of file diff --git a/examples/packet.cpp b/examples/packet.cpp new file mode 100644 index 0000000..1897773 --- /dev/null +++ b/examples/packet.cpp @@ -0,0 +1,14 @@ +#include +#include "frnetlib/Packet.h" + + +int main() +{ + fr::Packet packet; + std::vector> bob = {{1, 2}, {3, 4}}; + packet << bob; + bob.clear(); + + packet >> bob; + std::cout << bob[0].first << ", " << bob[0].second << ", " << bob[1].first << ", " << bob[1].second << std::endl; +} \ No newline at end of file