curl_wrapper/README.adoc

86 lines
2.7 KiB
Plaintext
Raw Permalink Normal View History

2020-11-08 15:53:43 +01:00
= curl_wrapper
2020-11-13 22:55:37 +01:00
:toc: preamble
2020-11-08 16:25:38 +01:00
:project: curl_wrapper
:uri-base: https://schlomp.space/tastytea/{project}
:uri-cmake: https://cmake.org/
:uri-libcurl: https://curl.haxx.se/libcurl/
:uri-catch: https://github.com/catchorg/Catch2
:uri-doxygen: http://www.doxygen.nl/
2020-11-13 22:55:37 +01:00
:uri-git-subtree: https://manpages.debian.org/testing/git-man/git-subtree.1.en.html
2020-11-08 15:53:43 +01:00
2020-11-08 15:50:14 +01:00
Light libcurl wrapper for when you need to GET a website with minimum effort.
2020-11-08 15:08:31 +01:00
This is _not_ supposed to be a package on its own, but a thing you drop into
your project.
I made this because the curl wrapper I used before is no longer maintained and
2020-11-08 16:28:31 +01:00
the other wrappers are either incomplete or unmaintained as well. _I do not
guarantee anything, use at your own risk._
2020-11-08 15:08:31 +01:00
2020-11-08 16:25:38 +01:00
URL: <{uri-base}>.
2020-11-08 15:08:31 +01:00
== Example program
[source,cpp]
--------------------------------------------------------------------------------
#include "curl_wrapper.hpp"
#include <iostream>
namespace cw = curl_wrapper;
2020-11-08 15:57:54 +01:00
int main()
2020-11-08 15:08:31 +01:00
{
2020-11-08 15:57:54 +01:00
cw::CURLWrapper curl;
const auto answer{curl.make_http_request(cw::http_method::GET,
"http://example.com/")};
if (answer)
{
std::cout << answer;
}
2020-11-08 15:08:31 +01:00
}
--------------------------------------------------------------------------------
== Use with CMake
Drop this project into a subfolder in your project tree. It will be compiled as
a static library.
[source,cmake]
--------------------------------------------------------------------------------
add_subdirectory(curl_wrapper)
add_executable(test)
target_link_libraries(test PRIVATE curl_wrapper)
--------------------------------------------------------------------------------
.CMake options:
2020-11-08 15:55:03 +01:00
* `-DWITH_CURL_WRAPPER_TESTS=YES` Compiles the tests.
* `-DWITH_CURL_WRAPPER_DOC=YES` Generate API reference.
2020-11-08 15:08:31 +01:00
2020-11-13 22:55:37 +01:00
== Add with `git subtree`
Replace `src/curl_wrapper` with the path you want it to be in. Consult
link:{uri-git-subtree}[git-subtree(1)] for more information.
[source,shell]
--------------------------------------------------------------------------------
git remote add curl_wrapper https://schlomp.space/tastytea/curl_wrapper.git
git subtree add --prefix=src/curl_wrapper curl_wrapper main --squash
--------------------------------------------------------------------------------
=== Update subtree
[source,shell]
--------------------------------------------------------------------------------
git subtree pull --prefix=src/curl_wrapper curl_wrapper main --squash
--------------------------------------------------------------------------------
2020-11-08 15:08:31 +01:00
== Dependencies
2020-11-08 15:55:03 +01:00
* C++17
2020-11-08 16:25:38 +01:00
* link:{uri-cmake}[CMake] >= 3.9
* link:{uri-libcurl}[libcurl] >= 7.52
2020-11-08 15:55:03 +01:00
* Optional:
2020-11-08 16:25:38 +01:00
** Tests: link:{uri-catch}[Catch] >= 1.2
** Documentation: link:{uri-doxygen}[Doxygen] >= 1.8