22
33[ ![ build] ( https://github.com/fbdtemme/bencode/workflows/build/badge.svg?branch=master )] ( https://github.com/fbdtemme/bencode/actions?query=workflow%3Abuild )
44[ ![ docs] ( https://github.com/fbdtemme/bencode/workflows/documentation/badge.svg?branch=master )] ( https://fbdtemme.github.io/bencode/ )
5+ [ ![ santizers] ( https://github.com/fbdtemme/bencode/workflows/sanitizers/badge.svg?branch=master )] ( https://github.com/fbdtemme/bencode/actions?query=workflow%3Asanitizers )
56[ ![ GitHub release (latest SemVer)] ( https://img.shields.io/github/v/release/fbdtemme/bencode )] ( https://github.com/fbdtemme/bencode/releases )
67[ ![ C++ standard] ( https://img.shields.io/badge/C%2B%2B-20-blue )] ( https://isocpp.org/ )
78[ ![ 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 )
1011
1112[ ** Features** ] ( #Features ) |
1213[ ** Status** ] ( #Status ) |
13- [ ** Documentation** ] ( #Documentation ) |
14+ [ ** Documentation** ] ( #Documentation ) |
15+ [ ** Performance** ] ( #Performance ) |
1416[ ** Examples** ] ( #Examples ) |
1517[ ** Building** ] ( #Building ) |
1618[ ** Integration** ] ( #Integration ) |
@@ -29,19 +31,28 @@ A header-only C++20 bencode serialization/deserialization library. Inspired by t
2931
3032## Features
3133
32- * Convenient owning representation of bencoded data with ` bvalue ` .
33- * Fast and memory efficient read-only, non-owning representation into stable buffers of bencoded data with ` bview ` .
34- * Build-in serialization/deserializaton for most standard containers.
35- * Support for serializing/deserializing to/from user-defined types.
36- * Parse directly to custom types by satisfying the ` EventConsumer ` concept.
37- * Throwing and non throwing variants of common functions.
38- * Iterative parsing to protect against stack overflow attacks.
39- * Bencode pointer similar to json pointer.
40-
34+ * ** Feature-rich** . The main goal of this library is to provide a complete bencode library that
35+ provides optimal solutions for all common use cases. ` bvalue ` is an owning representation of bencoded data
36+ and is usefull for creating and modifying bencoded documents.
37+ ` bview ` is a fast and memory efficient, read-only, non-owning representation into a stable buffer of bencoded data.
38+ ` bpointer ` can be used to access both ` bvalue ` and ` bview ` types.
39+ * ** Extensibility** . This library provides built-in serialization and deserialization from/to most standard containers.
40+ Support for user-defined types can be added by implementing the necessary extension points.
41+ Users can parse directly to their data type of preference by implementing a class satisfying
42+ the EventConsumer concept.
43+ * ** Conformance** . This library is 100% conforming to the bencode specification.
44+ All parsers validate the input and provide exact error messages.
45+ * ** Security** . Parsing arbitrary user data can be dangerous and you do not want your bittorrent tracker
46+ to crash when a user sends malformed data. All parsers are recursion-free to protect against
47+ stack-based buffer overflow attacks. Integer parsing throws when overflows are encountered.
48+ * ** Speed** . While not the primary goal of this project this library provides optimized integer parsing with
49+ SWAR techniques. Benchmarks show this library performs well in comparison with other libraries
50+
4151## Status
4252
43- This library is under active development, but should be fairly stable.
44- The API may change at any release prior to 1.0.0.
53+ This library is under active development. The API may change at any release prior to 1.0.0.
54+ Versioning follows the Semantic Versioning Specification.
55+
4556
4657## Documentation
4758
@@ -54,6 +65,19 @@ Value types own the data they refer to and thus need to copy data from the buffe
5465View types try to minimize copies from the buffer with bencoded data and instead point
5566to data directly inside the buffer.
5667
68+ Decoding speed was compared for these libraries in alphabetical order:
69+
70+ * [ Aetf/QBencode] ( https://github.com/Aetf/QBencode )
71+ * [ arvidn/libtorrent] ( https://github.com/arvidn/libtorrent )
72+ * [ iRajul/bencode] ( https://github.com/iRajul/bencode )
73+ * [ jimporter/bencode.hpp] ( https://github.com/jimporter/bencode.hpp )
74+ * [ kriben/bencode] ( https://github.com/kriben/bencode )
75+ * [ outputenable/bencode] ( https://gitlab.com/outputenable/bencode )
76+ * [ rakshasa/libtorrent] ( https://github.com/rakshasa/libtorrent )
77+ * [ s3ponia/BencodeParser] ( https://github.com/s3ponia/BencodeParser )
78+ * [ s3rvac/cpp-bencoding] ( https://github.com/s3rvac/cpp-bencoding )
79+ * [ theanti9/cppbencode] ( https://github.com/theanti9/cppbencode )
80+
5781#### Parsing to value types
5882
5983![ benchmark-decoding-value] ( docs/images/benchmark-decoding-value.svg )
@@ -62,7 +86,15 @@ to data directly inside the buffer.
6286
6387![ benchmark-decoding-view] ( docs/images/benchmark-decoding-view.svg )
6488
65- Note: libtorrent does not decode integers until they are actually accessed.
89+ All benchmarks were build with GCC 10.2.1 with -O3 and run on an intel i7-7700hq.
90+
91+ Notes:
92+ * arvidn/libtorrent does not decode integers until they are actually accessed.
93+ This gives a performance benefit when decoding but results in slower
94+ access times when retrieving integral values.
95+ * kriben/bencode support only 32-bit integers and fails on the
96+ camelyon17, integers and pneumomia benchmarks
97+ * iRajul/bencode fails all benchmarks and was excluded from the results.
6698
6799## Examples
68100
@@ -186,7 +218,7 @@ See the [documentation](https://fbdtemme.github.io/bencode/) for more examples.
186218This project requires C++20.
187219Currently only GCC 10 and later is supported.
188220
189- This library depends on following projects:
221+ This library uses following projects:
190222* [ fmt] ( https://github.com/fmtlib/fmt )
191223* [ gsl-lite] ( https://github.com/gsl-lite/gsl-lite )
192224* [ expected-lite] ( https://github.com/martinmoene/expected-lite )
@@ -196,23 +228,29 @@ When building tests:
196228
197229When building benchmarks:
198230* [ google/benchmark] ( https://github.com/google/benchmark )
199- * [ libtorrent ] ( https://github.com/arvidn/libtorrent )
200- * [ jimporter/bencode ] ( https://github.com/jimporter/bencode )
201- * [ s3rvac/cpp-bencoding ] ( https://github.com/s3rvac/cpp-bencoding )
231+ * [ Boost ] ( https://www.boost.org/ )
232+ * [ Qt5 ] ( https://www.qt.io/ )
233+
202234
203235When building documentation:
204236* [ doxygen] ( https://github.com/doxygen/doxygen> )
205237* [ sphinx] ( https://github.com/sphinx-doc/sphinx> )
206238* [ breathe] ( https://github.com/michaeljones/breathe> )
239+ * [ shphinx-rtd-theme] ( https://github.com/readthedocs/sphinx_rtd_theme )
207240
208- All dependencies for building tests and benchmarks can be fetched from github using
241+ All dependencies except for boost, Qt5 and documentation dependencies can be fetched from github using
209242cmake FetchContent during configuration if no local installation is found.
210243
211244The tests can be built as every other project which makes use of the CMake build system.
212245
213246``` {bash}
214247mkdir build; cd build;
215- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBENCODE_BUILD_TESTS=ON -DBENCODE_BUILD_BENCHMARKS=OFF =DBENCODE_BUILD_DOCS=OFF
248+ cmake \
249+ -DCMAKE_BUILD_TYPE=Debug \
250+ -DBENCODE_BUILD_TESTS=ON \
251+ -DBENCODE_BUILD_BENCHMARKS=OFF \
252+ -DBENCODE_BUILD_DOCS=OFF \
253+ --build . --target ..
216254make bencode-tests
217255```
218256
0 commit comments