Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vovk committed Mar 4, 2020
0 parents commit 1533bed
Show file tree
Hide file tree
Showing 42 changed files with 6,392 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 22
PenaltyBreakBeforeFirstCallParameter: 120
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# macOS folder view
**/.DS_Store

# toolchain env
.idea/
.gradle/
build/
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## 1.1.3 (2020-03-03)

### Bug Fixes

* get_session(timeout_or_deadline) return invalid socket

## 1.1.2 (2020-03-02)

### Features

* Add throwing get_session(timeout_or_deadline) function to the pool

## 1.1.1 (2020-03-02)

### Features

* Require standard openssl on macos (1.1+)
* Add Apache 2.0 LICENSE file

### Misc

* Small README fixes
* Style-related fixes

# 1.1.0 (2020-01-27)

### Features

* Apply clang-format as code style guard
* Add doxygen-format docs
* Add IPv4/IPV6/Any selector to stream_client::resolver::base_resolver<>
* Allow boost::asio::ip::basic_resolver_query::flags pass-through
* Separate TCP/UDP implementation since they are based on boost::asio::basic_stream_socket/basic_datagram_socket
* Add tests
* Add readme

### Bug Fixes

* Remove redundant ssl-handshake type parameter. Use client one

# 1.0.0 (2019-12-11)

- initial release
129 changes: 129 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

set(STREAMCLIENT_VERSION_MAJOR "1")
set(STREAMCLIENT_VERSION_MINOR "1")
set(STREAMCLIENT_VERSION_RELEASE "3")
set(STREAMCLIENT_VERSION_STRING "${STREAMCLIENT_VERSION_MAJOR}.${STREAMCLIENT_VERSION_MINOR}.${STREAMCLIENT_VERSION_RELEASE}")
set(STREAMCLIENT_LIB_VERSION ${STREAMCLIENT_VERSION_STRING})
mark_as_advanced(STREAMCLIENT_VERSION_MAJOR STREAMCLIENT_VERSION_MINOR STREAMCLIENT_VERSION_RELEASE STREAMCLIENT_VERSION_STRING STREAMCLIENT_LIB_VERSION)

project(stream-client VERSION "${STREAMCLIENT_VERSION_STRING}" LANGUAGES CXX)
include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 14) # todo: upgrade to 17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_UUID_RANDOM_GENERATOR_COMPAT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unneeded-internal-declaration")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef")

# compile in release with debug info mode by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

option(BUILD_SHARED_LIBS "Build shared library" ON)
option(STREAMCLIENT_BUILD_EXAMPLES "Build stream-client examples" OFF)

# If streamclient is being bundled in another project, we don't want to
# install anything.
if(NOT DEFINED STREAMCLIENT_BUNDLED_MODE)
if("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
set(STREAMCLIENT_BUNDLED_MODE OFF)
else()
set(STREAMCLIENT_BUNDLED_MODE ON)
endif()
endif()
set(STREAMCLIENT_BUNDLED_MODE ${STREAMCLIENT_BUNDLED_MODE} CACHE BOOL "" FORCE)
mark_as_advanced(STREAMCLIENT_BUNDLED_MODE)

# Allow people to choose whether to build shared or static libraries
# via the BUILD_SHARED_LIBS option unless we are in bundled mode, in
# which case we always use static libraries.
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT STREAMCLIENT_BUNDLED_MODE" OFF)

# libstream-client
add_library(stream-client INTERFACE)
add_library(${PROJECT_NAME}::stream-client ALIAS stream-client)

if (NOT BUILD_SHARED_LIBS)
set(OPENSSL_USE_STATIC_LIBS ON)
endif()

if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
find_program(HOMEBREW brew)
if (NOT HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
execute_process(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
find_package(Threads)
find_package(OpenSSL 1.0 REQUIRED)
find_package(Boost 1.65 COMPONENTS system REQUIRED)

target_include_directories(stream-client
INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
INTERFACE ${Boost_INCLUDE_DIRS}
)

target_link_libraries(stream-client INTERFACE OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(stream-client INTERFACE Threads::Threads)
target_link_libraries(stream-client INTERFACE Boost::system)
if (NOT BUILD_SHARED_LIBS)
target_link_libraries(stream-client INTERFACE ${CMAKE_DL_LIBS})
endif()

if(NOT STREAMCLIENT_BUNDLED_MODE)
include(GNUInstallDirs)

install(TARGETS stream-client
EXPORT streamclientTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")

install(DIRECTORY include/stream-client
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

include(CMakePackageConfigHelpers)

set(streamclient_VERSION_CONFIG "${PROJECT_BINARY_DIR}/streamclientConfigVersion.cmake")
set(streamclient_PROJECT_CONFIG "${PROJECT_BINARY_DIR}/streamclientConfig.cmake")
set(streamclient_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/streamclient/")
write_basic_package_version_file(${streamclient_VERSION_CONFIG}
VERSION ${STREAMCLIENT_VERSION_STRING}
COMPATIBILITY AnyNewerVersion)
configure_package_config_file(
${PROJECT_SOURCE_DIR}/streamclientConfig.cmake.in
${streamclient_PROJECT_CONFIG}
INSTALL_DESTINATION ${streamclient_CONFIG_INSTALL_DIR})


install(FILES ${streamclient_PROJECT_CONFIG} ${streamclient_VERSION_CONFIG}
DESTINATION ${streamclient_CONFIG_INSTALL_DIR})
install(EXPORT streamclientTargets
DESTINATION ${streamclient_CONFIG_INSTALL_DIR}
NAMESPACE ${PROJECT_NAME}::)
endif(NOT STREAMCLIENT_BUNDLED_MODE)

set(streamclient_TARGETS_CONFIG "${PROJECT_BINARY_DIR}/streamclientTargets.cmake")
export(EXPORT streamclientTargets
FILE ${streamclient_TARGETS_CONFIG}
NAMESPACE ${PROJECT_NAME}::)

if (STREAMCLIENT_BUILD_EXAMPLES)
add_subdirectory(example)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(test)
endif()
Loading

0 comments on commit 1533bed

Please sign in to comment.