11![ ] ( docs/images/bencode.svg )
22
3- ![ build] ( https://github.com/fbdtemme/bencode/workflows/build/badge.svg?branch=master )
3+ [ ![ build] ( https://github.com/fbdtemme/bencode/workflows/build/badge.svg?branch=master )] ( https://github.com/fbdtemme/bencode/actions?query=workflow%3Abuild )
4+ [ ![ docs] ( https://github.com/fbdtemme/bencode/workflows/documentation/badge.svg?branch=master )] ( https://fbdtemme.github.io/bencode/ )
45[ ![ Codacy Badge] ( https://api.codacy.com/project/badge/Grade/5cc3eec94d8a486dab62afeab5130def )] ( https://app.codacy.com/manual/floriandetemmerman/bencode?utm_source=github.com&utm_medium=referral&utm_content=fbdtemme/bencode&utm_campaign=Badge_Grade_Dashboard )
56[ ![ codecov] ( https://codecov.io/gh/fbdtemme/bencode/branch/master/graph/badge.svg )] ( https://codecov.io/gh/fbdtemme/bencode )
67[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
78
9+ [ ** Features** ] ( #Features ) |
10+ [ ** Status** ] ( #Status ) |
11+ [ ** Documentation** ] ( #Documentation ) |
12+ [ ** Examples** ] ( #Examples ) |
13+ [ ** Building** ] ( #Building ) |
14+ [ ** Integration** ] ( #Integration ) |
15+ [ ** License** ] ( #License )
16+
817A header-only C++20 bencode serialization/deserialization library.
918
1019## Features
@@ -15,24 +24,16 @@ A header-only C++20 bencode serialization/deserialization library.
1524* Support for serializing/deserializing to/from user-defined types.
1625* Parse directly to custom types by satisfying the ` EventConsumer ` concept.
1726* Throwing and non throwing variants of common functions.
18- * Iterative parsing to be safe against stack overflow attacks.
19-
20- ## Documentation
27+ * Iterative parsing to protect against stack overflow attacks.
2128
22- Documentation is available on the [ bencode GitHub pages ] ( https://fbdtemme.github.io/bencode/ )
29+ ## Status
2330
24- ## Requirements
31+ This library is still under development, but should be fairly stable.
32+ The API may change at any release prior to 1.0.0.
2533
26- This project requires C++20.
27- Currently only GCC 10 is supported.
28-
29- This library depends on following projects:
30- * [ Catch2] ( https://github.com/catchorg/Catch2 )
31- * [ fmt] ( https://github.com/fmtlib/fmt )
32- * [ Microsoft GSL] ( https://github.com/microsoft/GSL )
33- * [ expected-lite] ( https://github.com/martinmoene/expected-lite )
34+ ## Documentation
3435
35- All dependencies can be fetched from github during configure time or can be installed manually.
36+ Documentation is available on the [ bencode GitHub pages ] ( https://fbdtemme.github.io/bencode/ )
3637
3738## Examples
3839
@@ -75,7 +76,9 @@ auto v2 = get_integer(b[1]);
7576
7677Serialize to bencode using `bvalue`.
7778```cpp
78- #include <bencode/bvalue.hpp>
79+ #include <iostream>
80+ #include <bencode/bvalue.hpp>
81+ #include <bencode/encode.hpp>
7982
8083bc::bvalue b {
8184 {"foo", 1},
@@ -90,8 +93,10 @@ bc::encode_to(std::cout, b);
9093Serialize to bencode using ` encoder `
9194
9295``` cpp
93- #include < bencode/encode.hpp>
94- #include < bencode/traits/vector.hpp>
96+ #include < iostream>
97+ #include < vector>
98+ #include < bencode/encode.hpp> // bc::encoder
99+ #include < bencode/traits/vector.hpp> // support for serializating std::vector
95100
96101bc::encoder es (std::cout);
97102
@@ -105,3 +110,75 @@ es << bc::begin_dict
105110```
106111
107112For more examples see the [documentation](https://fbdtemme.github.io/bencode/)
113+
114+ ## Building
115+
116+ This project requires C++20.
117+ Currently only GCC 10 is supported.
118+
119+ This library depends on following projects:
120+ * [Catch2](https://github.com/catchorg/Catch2)
121+ * [fmt](https://github.com/fmtlib/fmt)
122+ * [Microsoft GSL](https://github.com/microsoft/GSL)
123+ * [expected-lite](https://github.com/martinmoene/expected-lite)
124+
125+ All dependencies can be fetched from github during configure time or can be installed manually.
126+
127+ The tests can be built as every other project which makes use of the CMake build system.
128+
129+ ```{bash}
130+ mkdir build
131+ cd build
132+ cmake -DCMAKE_BUILD_TYPE=Debug ..
133+ make
134+ ```
135+
136+ ## Integration
137+
138+ You can use the ` bencode::bencode ` interface target in CMake.
139+ The library can be located with ` find_package ` .
140+
141+ ``` cmake
142+ # CMakeLists.txt
143+ find_package(bencode REQUIRED)
144+ ...
145+ add_library(foo ...)
146+ ...
147+ target_link_libraries(foo INTERFACE bencode::bencode)
148+ ```
149+
150+ The source tree can be included in your project and added to your build with ` add_subdirectory ` .
151+
152+ ``` cmake
153+ # CMakeLists.txt
154+ # Disable building tests and benchmarks.
155+ set(BENCODE_BUILD_TESTS OFF)
156+ set(BENCODE_BUILD_BENCHMARKS OFF)
157+
158+ add_subdirectory(bencode)
159+ ...
160+ add_library(foo ...)
161+ ...
162+ target_link_libraries(foo INTERFACE bencode::bencode)
163+ ```
164+
165+ You can also use ` FetchContent ` to download the code from github.
166+
167+ ``` cmake
168+ # CMakeLists.txt
169+ include(FetchContent)
170+
171+ FetchContent_Declare(bencode
172+ GIT_REPOSITORY https://github.com/fbdtemme/bencode.git
173+ GIT_TAG "master")
174+
175+ FetchContent_MakeAvailable(bencode)
176+ ...
177+ add_library(foo ...)
178+ ...
179+ target_link_libraries(foo INTERFACE bencode::bencode)
180+ ```
181+
182+ ## License
183+
184+ Distributed under the MIT license. See ` LICENSE ` for more information.
0 commit comments