Skip to content

Commit 62686d6

Browse files
Merge pull request #1 from connectivecpp/develop
Merge develop to main
2 parents f412699 + d96a007 commit 62686d6

13 files changed

+4254
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build, run unit tests
2+
name: CMake build and run unit test matrix
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
env:
10+
BUILD_TYPE: Release
11+
jobs:
12+
build_matrix:
13+
strategy:
14+
matrix:
15+
# os: [ubuntu-latest, windows-latest, macos-14]
16+
os: [ubuntu-latest]
17+
runs-on: ${{ matrix.os }}
18+
defaults:
19+
run:
20+
shell: bash
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v4
24+
- name: create-build-dir
25+
run: mkdir build
26+
- name: configure-cmake
27+
run: cd build && cmake -D BINARY_SERIALIZE_BUILD_TESTS:BOOL=ON -D BINARY_SERIALIZE_BUILD_EXAMPLES:BOOL=ON ..
28+
- name: build
29+
run: cd build && cmake --build . --config $BUILD_TYPE
30+
- name: run-unit-test
31+
run: cd build && ctest -C $BUILD_TYPE

.github/workflows/gen_docs.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build, run unit tests
2+
name: Generate documentation
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
jobs:
9+
build_matrix:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest]
13+
runs-on: ${{ matrix.os }}
14+
defaults:
15+
run:
16+
shell: bash
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v4
20+
- name: run-doxygen
21+
uses: mattnotmitt/[email protected]
22+
with:
23+
working-directory: doc
24+
- name: deploy-pages
25+
uses: peaceiris/actions-gh-pages@v4
26+
with:
27+
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
publish_dir: ./doc/doc_output/html

CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) 2024 by Cliff Green
2+
#
3+
# https://github.com/connectivecpp/binary-serialize
4+
#
5+
# I'm still learning CMake, so improvement suggestions are always welcome.
6+
#
7+
# Distributed under the Boost Software License, Version 1.0.
8+
# (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9+
10+
cmake_minimum_required ( VERSION 3.14 FATAL_ERROR )
11+
12+
project ( binary_serialize
13+
LANGUAGES CXX
14+
DESCRIPTION "Binary serialization with std::format like syntax"
15+
HOMEPAGE_URL "https://github.com/connectivecpp/binary-serialize/" )
16+
17+
option ( BINARY_SERIALIZE_BUILD_TESTS "Build unit tests" OFF )
18+
option ( BINARY_SERIALIZE_BUILD_EXAMPLES "Build examples" OFF )
19+
option ( BINARY_SERIALIZE_INSTALL "Install header only library" OFF )
20+
21+
# add library targets
22+
23+
add_library ( binary_serialize INTERFACE )
24+
add_library ( chops::binary_serialize ALIAS binary_serialize )
25+
26+
# configure library target
27+
28+
target_include_directories ( binary_serialize INTERFACE
29+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
30+
$<INSTALL_INTERFACE:include/> )
31+
target_compile_features ( binary_serialize INTERFACE cxx_std_20 )
32+
33+
# check to build unit tests
34+
if ( ${BINARY_SERIALIZE_BUILD_TESTS} )
35+
enable_testing()
36+
add_subdirectory ( test )
37+
endif ()
38+
39+
# check to build example code
40+
if ( ${BINARY_SERIALIZE_BUILD_EXAMPLES} )
41+
add_subdirectory ( example )
42+
endif ()
43+
44+
# check to install
45+
if ( ${BINARY_SERIALIZE_INSTALL} )
46+
set ( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt )
47+
include ( CPack )
48+
endif ()
49+
50+
# end of file
51+

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# binary-serialize
2-
A minimal library for binary serialization, using compile time specifier strings similar to std::format
1+
# Binary Serialize, Header-Only C++ 20 Binary Serialization Classes and Functions
2+
3+
#### Unit Test and Documentation Generation Workflow Status
4+
5+
![GH Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/connectivecpp/binary-serialize/build_run_unit_test_cmake.yml?branch=main&label=GH%20Actions%20build,%20unit%20tests%20on%20main)
6+
7+
![GH Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/connectivecpp/binary-serialize/build_run_unit_test_cmake.yml?branch=develop&label=GH%20Actions%20build,%20unit%20tests%20on%20develop)
8+
9+
![GH Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/connectivecpp/binary-serialize/gen_docs.yml?branch=main&label=GH%20Actions%20generate%20docs)
10+
11+
![GH Tag](https://img.shields.io/github/v/tag/connectivecpp/binary-serialize?label=GH%20tag)
12+
13+
## Overview
14+
15+
The `binary_serialize` functions and classes provide serializing and unserializing of binary data. Serialization provides a way to transform application objects into and out of byte streams that can be sent over a network (or used for file IO).
16+
17+
The serialization functionality in this repository is useful when explicit control is needed for every bit and byte. This allows a developer to match an existing wire protocol or encoding scheme or to define his or her own wire protocol. Support is provided for fundamental arithmetic types as well as certain C++ vocabulary types such as `std::optional`. Both big and little endian support is provided.
18+
19+
## Generated Documentation
20+
21+
The generated Doxygen documentation for `binary_serialize` is [here](https://connectivecpp.github.io/binary-serialize/).
22+
23+
## Dependencies
24+
25+
The `binary_serialize` header files do not have any third-party dependencies. It uses C++ standard library headers only. The unit test code does have dependencies as noted below.
26+
27+
## C++ Standard
28+
29+
`binary_serialize` uses C++ 20 features, including ... (fill in details here) ... the "spaceship" operator (`<=>`), `std::span`, and `concepts` / `requires`.
30+
31+
## Supported Compilers
32+
33+
Continuous integration workflows build and unit test on g++ (through Ubuntu), MSVC (through Windows), and clang (through macOS).
34+
35+
## Unit Test Dependencies
36+
37+
The unit test code uses [Catch2](https://github.com/catchorg/Catch2). If the `BINARY_SERIALIZE_BUILD_TESTS` flag is provided to Cmake (see commands below) the Cmake configure / generate will download the Catch2 library as appropriate using the [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) dependency manager. If Catch2 (v3 or greater) is already installed using a different package manager (such as Conan or vcpkg), the `CPM_USE_LOCAL_PACKAGES` variable can be set which results in `find_package` being attempted. Note that v3 (or later) of Catch2 is required.
38+
39+
The unit test uses utilities from Connective C++'s [utility-rack](https://github.com/connectivecpp/utility-rack).
40+
41+
Specific version (or branch) specs for the dependenies are in `test/CMakeLists.txt`.
42+
43+
## Build and Run Unit Tests
44+
45+
To build and run the unit test program:
46+
47+
First clone the `binary-serialize` repository, then create a build directory in parallel to the `binary-serialize` directory (this is called "out of source" builds, which is recommended), then `cd` (change directory) into the build directory. The CMake commands:
48+
49+
```
50+
cmake -D BINARY_SERIALIZE_BUILD_TESTS:BOOL=ON ../binary-serialize
51+
52+
cmake --build .
53+
54+
ctest
55+
```
56+
57+
For additional test output, run the unit test individually, for example:
58+
59+
```
60+
test/binary_serialize_test -s
61+
```
62+
63+
The example can be built by adding `-D BINARY_SERIALIZE_BUILD_EXAMPLES:BOOL=ON` to the CMake configure / generate step.
64+

cmake/download_cpm.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# copied from CPM.cmake GitHub site
3+
# download CPM.cmake
4+
5+
file(
6+
DOWNLOAD
7+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.39.0/CPM.cmake
8+
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
9+
)
10+
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)

0 commit comments

Comments
 (0)