164 lines
17 KiB
HTML
164 lines
17 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.16"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>mastodonpp: include/curl_wrapper.hpp Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">mastodonpp
|
|
 <span id="projectnumber">0.0.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.16 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">curl_wrapper.hpp</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/* This file is part of mastodonpp.</span></div>
|
|
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
|
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * This program is free software: you can redistribute it and/or modify</span></div>
|
|
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * it under the terms of the GNU Affero General Public License as published by</span></div>
|
|
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * the Free Software Foundation, version 3.</span></div>
|
|
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * This program is distributed in the hope that it will be useful,</span></div>
|
|
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
|
|
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></div>
|
|
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * GNU Affero General Public License for more details.</span></div>
|
|
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * You should have received a copy of the GNU Affero General Public License</span></div>
|
|
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * along with this program. If not, see <http://www.gnu.org/licenses/>.</span></div>
|
|
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> */</span></div>
|
|
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span>  </div>
|
|
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#ifndef MASTODONPP_CURL_WRAPPER_HPP</span></div>
|
|
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#define MASTODONPP_CURL_WRAPPER_HPP</span></div>
|
|
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  </div>
|
|
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include "return_types.hpp"</span></div>
|
|
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  </div>
|
|
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include "curl/curl.h"</span></div>
|
|
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  </div>
|
|
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include <string></span></div>
|
|
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include <string_view></span></div>
|
|
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  </div>
|
|
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="keyword">namespace </span><a class="code" href="namespacemastodonpp.html">mastodonpp</a></div>
|
|
<div class="line"><a name="l00028"></a><span class="lineno"> 28</span> {</div>
|
|
<div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  </div>
|
|
<div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">using</span> std::string;</div>
|
|
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="keyword">using</span> std::string_view;</div>
|
|
<div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  </div>
|
|
<div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100"> 38</a></span> <span class="keyword">enum class</span> <a class="code" href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100">http_method</a></div>
|
|
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span> {</div>
|
|
<div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  GET,</div>
|
|
<div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  POST,</div>
|
|
<div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  PATCH,</div>
|
|
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  PUT,</div>
|
|
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  DELETE</div>
|
|
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> };</div>
|
|
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  </div>
|
|
<div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="classmastodonpp_1_1CURLWrapper.html"> 56</a></span> <span class="keyword">class </span><a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a></div>
|
|
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> {</div>
|
|
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="keyword">public</span>:</div>
|
|
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">CURLWrapper</a>();</div>
|
|
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  </div>
|
|
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">CURLWrapper</a>(<span class="keyword">const</span> <a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &other) = <span class="keywordflow">default</span>;</div>
|
|
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  </div>
|
|
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">CURLWrapper</a>(<a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &&other) noexcept = <span class="keywordflow">default</span>;</div>
|
|
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  </div>
|
|
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="keyword">virtual</span> <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a350f7061c9cb54cb5992ae983db3fc19">~CURLWrapper</a>() noexcept;</div>
|
|
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  </div>
|
|
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a>& <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a9ab0da0f9186df2bdbf65189df57aeaf">operator=</a>(<span class="keyword">const</span> <a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &other) = <span class="keywordflow">default</span>;</div>
|
|
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  </div>
|
|
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a>& <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a9ab0da0f9186df2bdbf65189df57aeaf">operator=</a>(<a class="code" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &&other) noexcept = <span class="keywordflow">default</span>;</div>
|
|
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  </div>
|
|
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  [[nodiscard]]</div>
|
|
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <a class="code" href="structmastodonpp_1_1answer__type.html">answer_type</a> <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a6a0c0ff6e894e43cdb5df9dd8b55c785">make_request</a>(<span class="keyword">const</span> <a class="code" href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100">http_method</a> &method, <span class="keyword">const</span> string_view &uri);</div>
|
|
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  </div>
|
|
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span> <span class="keyword">private</span>:</div>
|
|
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  CURL *_connection;</div>
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordtype">char</span> _curl_buffer_error[CURL_ERROR_SIZE];</div>
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  <span class="keywordtype">string</span> _curl_buffer_headers;</div>
|
|
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="keywordtype">string</span> _curl_buffer_body;</div>
|
|
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  </div>
|
|
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  <span class="keyword">static</span> <span class="keywordtype">int</span> writer(<span class="keywordtype">char</span> *data, <span class="keywordtype">size_t</span> size, <span class="keywordtype">size_t</span> nmemb,</div>
|
|
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="keywordtype">string</span> *writerData);</div>
|
|
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  </div>
|
|
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="keywordtype">void</span> setup_curl();</div>
|
|
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span> };</div>
|
|
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  </div>
|
|
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span> } <span class="comment">// namespace mastodonpp</span></div>
|
|
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  </div>
|
|
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span> <span class="preprocessor">#endif // MASTODONPP_CURL_WRAPPER_HPP</span></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<div class="ttc" id="anamespacemastodonpp_html_a7d60fc71ad0fb1fbd467b37fe1f1f100"><div class="ttname"><a href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100">mastodonpp::http_method</a></div><div class="ttdeci">http_method</div><div class="ttdoc">The HTTP method.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.hpp:38</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a736572303fbec7a307514e611e6a468c"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">mastodonpp::CURLWrapper::CURLWrapper</a></div><div class="ttdeci">CURLWrapper()</div><div class="ttdoc">Initializes curl and sets up connection.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:31</div></div>
|
|
<div class="ttc" id="anamespacemastodonpp_html"><div class="ttname"><a href="namespacemastodonpp.html">mastodonpp</a></div><div class="ttdoc">C++ wrapper for the Mastodon API.</div><div class="ttdef"><b>Definition:</b> api.cpp:19</div></div>
|
|
<div class="ttc" id="astructmastodonpp_1_1answer__type_html"><div class="ttname"><a href="structmastodonpp_1_1answer__type.html">mastodonpp::answer_type</a></div><div class="ttdoc">Return type for Requests.</div><div class="ttdef"><b>Definition:</b> return_types.hpp:40</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a6a0c0ff6e894e43cdb5df9dd8b55c785"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a6a0c0ff6e894e43cdb5df9dd8b55c785">mastodonpp::CURLWrapper::make_request</a></div><div class="ttdeci">answer_type make_request(const http_method &method, const string_view &uri)</div><div class="ttdoc">Make a request.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:56</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html">mastodonpp::CURLWrapper</a></div><div class="ttdoc">Handles the details of network connections.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.hpp:56</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a350f7061c9cb54cb5992ae983db3fc19"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a350f7061c9cb54cb5992ae983db3fc19">mastodonpp::CURLWrapper::~CURLWrapper</a></div><div class="ttdeci">virtual ~CURLWrapper() noexcept</div><div class="ttdoc">Cleans up curl and connection.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:44</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a9ab0da0f9186df2bdbf65189df57aeaf"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a9ab0da0f9186df2bdbf65189df57aeaf">mastodonpp::CURLWrapper::operator=</a></div><div class="ttdeci">CURLWrapper & operator=(const CURLWrapper &other)=default</div><div class="ttdoc">Copy assignment operator.</div></div>
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.16
|
|
</small></address>
|
|
</body>
|
|
</html>
|