Library for encoding and decoding using the Bencode protocol written in C++. Primarily used by BitTorrent protocol for encoding and decoding of data exchanged between a peer and the tracker.
- Parses bencode strings to C++ classes
- Support for input and output streams
- Provides a safe api with error support
I will assume you're using CMake
- Clone/download this repository into your own project folder
- Set CMake variable pointing to the include directory
set(BENCODE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/libs/bencode/include)
- Add bencode as a subdirectory to your project
add_subdirectory(libs/bencode)
- Link the include directories to a target
target_include_directors(MyProj PUBLIC ${BENCODE_INCLUDE_DIR})
- Link the bencode library
target_link_libraries(MyProj bencode)
#include <bencode/bencode.h>
stringstream test("d3:cowi7856e4:spam4:eggse");
auto i = decode<bencode::bdata>(test);
cout << encode(i.value()) << endl;