Skip to content

Commit 4d13b95

Browse files
committed
Upgrade Eigen version and code format
1 parent bd65656 commit 4d13b95

22 files changed

+71
-34
lines changed

.clang-format

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ BraceWrapping:
2020
AfterExternBlock: true
2121
BeforeCatch: false
2222
BeforeElse: false
23-
# BeforeLambdaBody: false
24-
# BeforeWhile: false
2523
IndentBraces: false
2624
SplitEmptyFunction: false
2725
SplitEmptyRecord: false

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323
*.so binary
2424
*.zip binary
2525
*.gz binary
26+
*.bz2 binary
2627

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.18)
22

33
project(cppbase CXX)
44

@@ -11,12 +11,18 @@ endif()
1111

1212
option(CPPBASE_BUILD_TESTING "Build unit tests" ${CPPBASE_STANDALONE_PROJECT})
1313
option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" OFF)
14-
option(CPPBASE_BUILD_GTEST "Build google test" ON)
14+
option(CPPBASE_BUILD_ASIO "Build Asio" ON)
15+
option(CPPBASE_BUILD_CXXOPTS "Build cxxopts" ON)
16+
option(CPPBASE_BUILD_EIGEN "Build Eigen" ON)
17+
option(CPPBASE_BUILD_FMT "Build FMT" ON)
18+
option(CPPBASE_BUILD_GTEST "Build Google Test" ON)
19+
option(CPPBASE_BUILD_RAPIDJSON "Build RapidJson" ON)
20+
option(CPPBASE_BUILD_RAPIDXML "Build RapidXml" ON)
21+
option(CPPBASE_BUILD_SIGSLOT "Build sigslot" ON)
22+
option(CPPBASE_BUILD_SPDLOG "Build spdlog" ON)
23+
option(CPPBASE_BUILD_STDUUID "Build stduuid" ON)
1524

16-
# set(CMAKE_INCLUDE_CURRENT_DIR ON) # this causes capnproto build to fail
1725
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18-
19-
# set(BUILD_SHARED ON)
2026
set(CXX_STD cxx_std_17)
2127

2228
# Custom CMake modules/scripts
@@ -32,7 +38,7 @@ else()
3238
endif()
3339
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
3440

35-
# MODULE_NAME is useful for logger naming
41+
# MODULE_NAME is for logger module name
3642
add_compile_definitions(MODULE_NAME="cppbase")
3743

3844
if(GLIBCXX_USE_CXX11_ABI)

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
[![pipeline status](http://192.168.10.1/lidar/cppbase/badges/master/pipeline.svg)](http://192.168.10.1/lidar/cppbase/commits/master)
2-
31
# cppbase
42
cppbase是一个跨平台C++17基础库,提供一些C++项目常用的功能,如日志、线程池、TCP/UDP客户端以及服务端等。采用CMake编译和集成一系列第三封库(详见thirdparty)。
53

6-
Cross-platform C++17 base library providing common features for C++ projects, such as logging, thread pool, TCP/UDP clien and server, etc. It uses CMake to build and integrate a set of thirdparty libraries (see thirdparty folder for details).
4+
Cross-platform C++17 base library providing common features for C++ projects, such as logging, thread pool, TCP/UDP clien and server, etc. It uses CMake [DownloadProject](https://github.com/Crascit/DownloadProject) to build and integrate a set of thirdparty libraries (see thirdparty folder for details).
75

86
## 在QtCreator里配置clang-format (Setup clang-format in QtCreator)
97
* 帮助->关于插件->勾选Beautifier 重启QtCreator (Help->Plugin->Beautifier Restart QtCreator)

common/FileSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**************************************************************************
2-
* @file: FileSyste.h
3-
* @brief:
2+
* @file: FileSystem.h
3+
* @brief: std::filesystem adapter
44
*
55
* Copyright (c) 2021 O-Net Technologies (Group) Limited.
66
*************************************************************************/

logging/Logging.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**************************************************************************
22
* @file: Logging.h
3-
* @brief:
3+
* @brief: spdlog based Logger
44
*
55
* Copyright (c) 2021 O-Net Technologies (Group) Limited.
66
*************************************************************************/
@@ -27,7 +27,7 @@ typedef std::shared_ptr<spdlog::logger> LoggerPtr;
2727
* @note
2828
* By default, in Debug mode, all logs will be logged into std::cout,
2929
* while in Release mode, all logs will be logged into a log file.
30-
* But the configuration can be changed in the log.conf file.
30+
* But the configuration can be changed in the \b log.conf file.
3131
*/
3232
static LoggerPtr GetLogger(const std::string& logger_name = "") noexcept;
3333
static LoggerPtr GetLoggerForCurrentModule() noexcept;

logging/Logging_intl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**************************************************************************
22
* @file: Logging_intl.h
3-
* @brief:
3+
* @brief: Logging internal implementations
44
*
55
* Copyright (c) 2021 O-Net Technologies (Group) Limited.
66
**************************************************************************/

logging/spdlog_setup/conf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace spdlog_setup {
2020
* @throw setup_error
2121
*/
2222
template <class... Ps>
23-
void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&...ps);
23+
void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&... ps);
2424

2525
/**
2626
* Performs spdlog configuration setup from both base and override files, with
@@ -35,7 +35,7 @@ void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&...ps
3535
template <class... Ps>
3636
auto from_file_and_override_with_tag_replacement(const std::string &base_pre_toml_path,
3737
const std::string &override_pre_toml_path,
38-
const Ps &...ps) -> bool;
38+
const Ps &... ps) -> bool;
3939

4040
/**
4141
* Performs spdlog configuration setup from file.
@@ -87,7 +87,7 @@ auto delete_logger_in_file(const std::string &logger_name, const std::string &to
8787
// implementation section
8888

8989
template <class... Ps>
90-
void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&...ps)
90+
void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&... ps)
9191
{
9292
// std
9393
using std::exception;
@@ -116,7 +116,7 @@ void from_file_with_tag_replacement(const std::string &pre_toml_path, Ps &&...ps
116116
template <class... Ps>
117117
auto from_file_and_override_with_tag_replacement(const std::string &base_pre_toml_path,
118118
const std::string &override_pre_toml_path,
119-
const Ps &...ps) -> bool
119+
const Ps &... ps) -> bool
120120
{
121121
// std
122122
using std::exception;

logging/spdlog_setup/details/conf_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ inline void write_to_config_file(const cpptoml::table &config, const std::string
317317

318318
template <class... Ps>
319319
void read_template_file_into_stringstream(std::stringstream &toml_ss, const std::string &file_path,
320-
Ps &&...ps)
320+
Ps &&... ps)
321321
{
322322
// fmt
323323
using fmt::format;

logging/spdlog_setup/details/third_party/cpptoml.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class base : public std::enable_shared_from_this<base>
522522
std::shared_ptr<const value<T>> as() const;
523523

524524
template <class Visitor, class... Args>
525-
void accept(Visitor &&visitor, Args &&...args) const;
525+
void accept(Visitor &&visitor, Args &&... args) const;
526526

527527
#if defined(CPPTOML_NO_RTTI)
528528
base_type type() const { return type_; }
@@ -2932,7 +2932,7 @@ template <class T, class... Ts>
29322932
struct value_accept<T, Ts...>
29332933
{
29342934
template <class Visitor, class... Args>
2935-
static void accept(const base &b, Visitor &&visitor, Args &&...args)
2935+
static void accept(const base &b, Visitor &&visitor, Args &&... args)
29362936
{
29372937
if (auto v = b.as<T>())
29382938
{
@@ -2950,7 +2950,7 @@ struct value_accept<T, Ts...>
29502950
* class.
29512951
*/
29522952
template <class Visitor, class... Args>
2953-
void base::accept(Visitor &&visitor, Args &&...args) const
2953+
void base::accept(Visitor &&visitor, Args &&... args) const
29542954
{
29552955
if (is_value())
29562956
{

network/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**************************************************************************
22
* @file: Common.h
3-
* @brief:
3+
* @brief: Network common header
44
*
55
* Copyright (c) 2021 O-Net Technologies (Group) Limited.
66
*************************************************************************/

network/TcpClient.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace cppbase {
1313

14+
/**
15+
* @brief TCP Client class
16+
*/
1417
class TcpClient
1518
{
1619
public:

network/TcpServer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace cppbase {
1313

14+
/**
15+
* @brief TCP Connection class
16+
*/
1417
class TcpConnection
1518
{
1619
public:
@@ -63,6 +66,9 @@ class TcpConnection
6366
tcp::socket m_socket;
6467
};
6568

69+
/**
70+
* @brief TCP Server class
71+
*/
6672
class TcpServer
6773
{
6874
public:

network/UdpClient.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace cppbase {
1313

14+
/**
15+
* @brief UDP Client class
16+
*/
1417
class UdpClient
1518
{
1619
public:

network/UdpServer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace cppbase {
1515

16+
/**
17+
* @brief UDP Server class
18+
*/
1619
class UdpServer
1720
{
1821
public:

tests/common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.18)
22

33
set(SOURCE
44
main.cpp

tests/logging/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.18)
22

33
set(SOURCE
44
main.cpp

tests/network/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.18)
22

33
set(SOURCE
44
main.cpp

thirdparty/CMakeLists.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.10...3.20 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.18)
22

33
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
44
include(DownloadProject)
@@ -13,6 +13,7 @@ set(BUILD_TESTING OFF CACHE BOOL "")
1313
# asio
1414
# ============================================================
1515
#
16+
if(CPPBASE_BUILD_ASIO)
1617
message("==> Configuring asio")
1718
download_project(
1819
PROJ asio
@@ -22,6 +23,7 @@ download_project(
2223
)
2324
add_library(asio INTERFACE)
2425
target_include_directories(asio INTERFACE ${asio_SOURCE_DIR}/include)
26+
endif()
2527

2628
##
2729
# For encoding/decoding and client/server communications, following options
@@ -37,6 +39,7 @@ target_include_directories(asio INTERFACE ${asio_SOURCE_DIR}/include)
3739
# cxxopts
3840
# ============================================================
3941
#
42+
if(CPPBASE_BUILD_CXXOPTS)
4043
message("==> Configuring cxxopts")
4144
download_project(
4245
PROJ cxxopts
@@ -46,24 +49,28 @@ download_project(
4649
)
4750
add_library(cxxopts INTERFACE)
4851
target_include_directories(cxxopts INTERFACE ${cxxopts_SOURCE_DIR}/include)
52+
endif()
4953

5054
# ============================================================
5155
# eigen
5256
# ============================================================
5357
#
58+
if(CPPBASE_BUILD_EIGEN)
5459
message("==> Configuring eigen")
5560
download_project(
5661
PROJ eigen
57-
URL ${CMAKE_CURRENT_SOURCE_DIR}/eigen/eigen-v2.8.5.tar.gz
58-
URL_HASH MD5=8115d08b9089fe861b9288d9facd3bdd
62+
URL ${CMAKE_CURRENT_SOURCE_DIR}/eigen/eigen-3.3.9.tar.gz
63+
URL_HASH MD5=609286804b0f79be622ccf7f9ff2b660
5964
QUIET
6065
)
6166
add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR})
67+
endif()
6268

6369
# ============================================================
6470
# fmt
6571
# ============================================================
6672
#
73+
if(CPPBASE_BUILD_FMT)
6774
message("==> Configuring fmt")
6875
set(BUILD_SHARED_LIBS ON CACHE BOOL "")
6976
download_project(
@@ -73,6 +80,7 @@ download_project(
7380
QUIET
7481
)
7582
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR})
83+
endif()
7684

7785
# ============================================================
7886
# googletest
@@ -98,6 +106,7 @@ endif()
98106
# rapidjson
99107
# ============================================================
100108
#
109+
if(CPPBASE_BUILD_RAPIDJSON)
101110
message("==> Configuring rapidjson")
102111
download_project(
103112
PROJ rapidjson
@@ -107,11 +116,13 @@ download_project(
107116
)
108117
add_library(rapidjson INTERFACE)
109118
target_include_directories(rapidjson INTERFACE ${rapidjson_SOURCE_DIR}/include)
119+
endif()
110120

111121
# ============================================================
112122
# rapidxml
113123
# ============================================================
114124
#
125+
if(CPPBASE_BUILD_RAPIDXML)
115126
message("==> Configuring rapidxml")
116127
download_project(
117128
PROJ rapidxml
@@ -121,11 +132,13 @@ download_project(
121132
)
122133
add_library(rapidxml INTERFACE)
123134
target_include_directories(rapidxml INTERFACE ${rapidxml_SOURCE_DIR})
135+
endif()
124136

125137
# ============================================================
126138
# sigslot
127139
# ============================================================
128140
#
141+
if(CPPBASE_BUILD_SIGSLOT)
129142
message("==> Configuring sigslot")
130143
download_project(
131144
PROJ sigslot
@@ -135,11 +148,13 @@ download_project(
135148
)
136149
add_library(sigslot INTERFACE)
137150
target_include_directories(sigslot INTERFACE ${sigslot_SOURCE_DIR}/include)
151+
endif()
138152

139153
# ============================================================
140154
# spdlog
141155
# ============================================================
142156
#
157+
if(CPPBASE_BUILD_SPDLOG)
143158
message("==> Configuring spdlog")
144159
set(SPDLOG_FMT_EXTERNAL_HO ON CACHE BOOL "")
145160
download_project(
@@ -149,11 +164,13 @@ download_project(
149164
QUIET
150165
)
151166
add_subdirectory(${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR})
167+
endif()
152168

153169
# ============================================================
154170
# stduuid
155171
# ============================================================
156172
#
173+
if(CPPBASE_BUILD_STDUUID)
157174
message("==> Configuring stduuid")
158175
set(UUID_BUILD_TESTS OFF CACHE BOOL "")
159176
download_project(
@@ -164,5 +181,6 @@ download_project(
164181
)
165182
add_library(stduuid INTERFACE)
166183
target_include_directories(stduuid INTERFACE ${stduuid_SOURCE_DIR}/include)
167-
install(DIRECTORY ${stduuid_SOURCE_DIR}/include/gsl DESTINATION include)
168-
install(FILES ${stduuid_SOURCE_DIR}/include/uuid.h DESTINATION include)
184+
# install(DIRECTORY ${stduuid_SOURCE_DIR}/include/gsl DESTINATION include)
185+
# install(FILES ${stduuid_SOURCE_DIR}/include/uuid.h DESTINATION include)
186+
endif()

thirdparty/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 第三方软件
1+
## Thirdparty libraries
22
* asio (https://github.com/chriskohlhoff/asio) provides cross-platform network socket and serial port APIs
33
* cxxopts (https://github.com/jarro2783/cxxopts) provides cross-platform command line options support
4+
* eigen (https://gitlab.com/libeigen/eigen) C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
45
* fmt (https://github.com/fmtlib/fmt) provides cross-platform C++ string formatting
56
* Google Test (https://github.com/google/googletest) C++ unit test framework
67
* rapidjson (https://github.com/Tencent/rapidjson) provides JSON encoding/decoding functionalities

thirdparty/eigen/eigen-3.3.9.tar.gz

2.04 MB
Binary file not shown.

thirdparty/eigen/eigen-v2.8.5.tar.gz

-1.59 MB
Binary file not shown.

0 commit comments

Comments
 (0)