Skip to content

Commit 8384be3

Browse files
committed
Add docs build
1 parent 189f692 commit 8384be3

File tree

7 files changed

+2604
-4
lines changed

7 files changed

+2604
-4
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ option(CPPBASE_BUILD_RAPIDJSON "Build RapidJson" ${CPPBASE_STANDALONE_PROJECT}
2323
option(CPPBASE_BUILD_RAPIDXML "Build RapidXml" ${CPPBASE_STANDALONE_PROJECT})
2424
option(CPPBASE_BUILD_SIGSLOT "Build sigslot" ${CPPBASE_STANDALONE_PROJECT})
2525
option(CPPBASE_BUILD_YAML_CPP "Build YAML-CPP" OFF)
26+
option(CPPBASE_BUILD_DOCS "Build document" ${CPPBASE_STANDALONE_PROJECT})
2627
option(CPPBASE_USE_RTTR "Use RTTR library (default=ON)" ON)
2728

2829
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -70,6 +71,10 @@ if(CPPBASE_BUILD_TESTING)
7071
add_subdirectory(tests)
7172
endif()
7273

74+
if(CPPBASE_BUILD_DOCS)
75+
add_subdirectory(docs)
76+
endif()
77+
7378
include(ClangFormat)
7479
clang_format_recurse("common" "logging" "network" "tests")
7580

LICENSE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
Copyright 2022 O-Net Communications (USA) Inc.
1+
Apache License (Apache-2.0)
2+
3+
Copyright (c) 2022 O-Net Communications (USA) Inc.
24

35
Licensed under the Apache License, Version 2.0 (the "License");
46
you may not use this file except in compliance with the License.
57
You may obtain a copy of the License at
68

7-
http://www.apache.org/licenses/LICENSE-2.0
9+
https://www.apache.org/licenses/LICENSE-2.0.txt
810

911
Unless required by applicable law or agreed to in writing, software
1012
distributed under the License is distributed on an "AS IS" BASIS,

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
![workflow](https://github.com/o-netusa/cppbase/actions/workflows/build.yml/badge.svg)
2+
![Language: C++17](https://img.shields.io/badge/Language-C%2B%2B17-yellow)
3+
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![Open in Visual Studio Code](https://img.shields.io/badge/-Open%20in%20Visual%20Studio%20Code-007acc)](https://vscode.dev/github/o-netusa/cppbase)
25

36
# cppbase
47
C++17 cross-platform header-only library providing common features for C++ projects, such as variant, logging, serialization, task sequence, thread pool, TCP/UDP client and server, etc.
@@ -12,6 +15,8 @@ C++17 cross-platform header-only library providing common features for C++ proje
1215
**Serialization** internally uses [cereal](https://github.com/USCiLab/cereal) to serialize and deserialize data. [Serializer](common/Serializer.h) provides a set of convenient functions to serialize and deserialize objects to/from a string or a file in binary format, which can be easily changed to JSON or XML.
1316
### Sequence
1417
**Sequence** is a set of classes ([Processor](sequence/Processor.h), [Sequence](sequence/Sequence.h), [Link](sequence/Link.h)) that allows user to execute a series of processing unit. It internally uses [taskflow](https://github.com/taskflow/taskflow) as the execution engine. Together with **Variant**, it provides an easy way to create a sequence that contains multiple processors with different functionalities to finish complex tasks. Refer to [tests/common/SequenceTests.cpp](tests/sequence/SequenceTests.cpp) and [tests/sequence/ProcessorTests.cpp] for examples.
18+
19+
![Processor, Sequence and link](docs/images/sequence_processor.png)
1520
### Thread Pool
1621
There are two threadpools in this library: **ThreadPool** and **ForkJoinPool**. The former is based on https://github.com/progschj/ThreadPool.git and the latter is based on [asio's fork join pool](https://raw.githubusercontent.com/boostorg/asio/develop/example/cpp14/executors/fork_join.cpp).
1722
### TCP/UDP Client and Server

common/Serializer.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Serializer
7979
/**
8080
* @brief Deserialize an object from a string
8181
*
82-
* @param str String representation of the object
82+
* @param archive String representation of the object
8383
* @return The loaded object
8484
*/
8585
template <typename InArchive, typename T>
@@ -88,27 +88,53 @@ class Serializer
8888
std::stringstream ss;
8989
ss << archive;
9090
InArchive arch(ss);
91-
// std::shared_ptr<T> obj;
9291
T obj;
9392
arch(obj);
9493
return obj;
9594
}
9695

96+
/**
97+
* @brief Serialize an object to a binary archive file
98+
*
99+
* @param obj Object to be serialized
100+
* @param archive_path Path to the archive file to be created
101+
*/
97102
template<typename T>
98103
static void SaveObjectToFileBinary(const T& obj, const std::string& archive_path)
99104
{
100105
SaveObjectToFile<BinaryOutputArchive, T>(obj, archive_path);
101106
}
107+
108+
/**
109+
* @brief Serialize an object to a binary archive string
110+
*
111+
* @param obj Object to be serialized
112+
* @return std::string String that contains the archive data
113+
*/
102114
template<typename T>
103115
static std::string SaveObjectToStringBinary(const T& obj)
104116
{
105117
return SaveObjectToString<BinaryOutputArchive, T>(obj);
106118
}
119+
120+
/**
121+
* @brief Deserialize an object from a binary archive file
122+
*
123+
* @param archive_path Path to the archive file to be loaded
124+
* @return The loaded object
125+
*/
107126
template<typename T>
108127
static T LoadObjectFromFileBinary(const std::string& archive_path)
109128
{
110129
return LoadObjectFromFile<BinaryInputArchive, T>(archive_path);
111130
}
131+
132+
/**
133+
* @brief Deserialize an object from a binary archive string
134+
*
135+
* @param archive String that contains the archive data
136+
* @return The loaded object
137+
*/
112138
template<typename T>
113139
static T LoadObjectFromStringBinary(const std::string& archive)
114140
{

docs/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
find_package(Doxygen)
2+
3+
if(NOT DOXYGEN_FOUND)
4+
message(STATUS "No Doxygen found. Documentation won't be built")
5+
else()
6+
set(OUT_DOXYFILE ${CMAKE_BINARY_DIR}/Doxyfile)
7+
8+
configure_file(Doxyfile.in ${OUT_DOXYFILE} @ONLY)
9+
10+
add_custom_target(docs ALL
11+
COMMAND ${DOXYGEN_EXECUTABLE} ${OUT_DOXYFILE}
12+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
13+
COMMENT "Generating API documentation with doxygen"
14+
VERBATIM
15+
)
16+
17+
install(DIRECTORY ${CMAKE_BINARY_DIR}/docs/html
18+
DESTINATION docs
19+
)
20+
endif()

0 commit comments

Comments
 (0)