2020-11-27
# # Previous commits: #d452daa
2020-11-13 # # Previous commits: #73648eb
2020-11-13 #a028edd
2020-03-21 #0cbf498
2020-03-21 #e6478b1
2020-03-12 #73648eb
2020-11-13 #a028edd
2020-03-21 #0cbf498
2020-03-21
This commit is contained in:
parent
d452daac6e
commit
1a6dd5fae7
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,95 +67,7 @@ $(function() {
|
|||
<div class="title">example01_instance_info.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Print information about an instance (/api/v1/instance).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 1)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], {}};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Get maximum allowed characters per post.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> max_chars{instance.get_max_chars()};</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Maximum characters per post: "</span> << max_chars << <span class="stringliteral">"\n\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Initialize a Connection.</span></div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Get information about the instance.</span></div>
|
||||
<div class="line"> masto::answer_type answer{connection.get(masto::API::v1::instance)};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << answer << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,119 +67,7 @@ $(function() {
|
|||
<div class="title">example02_streaming.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Print new public events (/api/v1/streaming/public).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <chrono></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <thread></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using namespace </span>std::chrono_literals;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::thread;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::this_thread::sleep_for;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 1)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], {}};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Initialize a Connection.</span></div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Find out if the streaming service is fine.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{connection.get(masto::API::v1::streaming_health)};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer && answer.body == <span class="stringliteral">"OK"</span>)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Make a thread, get all public events.</span></div>
|
||||
<div class="line"> <span class="comment">// clang-format off</span></div>
|
||||
<div class="line"> thread stream_thread{[&]</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// clang-format on</span></div>
|
||||
<div class="line"> answer = connection.get(masto::API::v1::streaming_public);</div>
|
||||
<div class="line"> }};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Print new events every 2 seconds, for 10 seconds.</span></div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">auto</span> counter{0}; counter < 5; ++counter)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> sleep_for(2s);</div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> &event : connection.get_new_events())</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Print type of event and the beginning of the data.</span></div>
|
||||
<div class="line"> cout << <span class="keyword">event</span>.type << <span class="stringliteral">": "</span> << <span class="keyword">event</span>.data.substr(0, 70)</div>
|
||||
<div class="line"> << <span class="stringliteral">" …"</span> << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Cancel the stream, …</span></div>
|
||||
<div class="line"> connection.cancel_stream();</div>
|
||||
<div class="line"> <span class="comment">// … and wait for the thread.</span></div>
|
||||
<div class="line"> stream_thread.join();</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,98 +67,7 @@ $(function() {
|
|||
<div class="title">example03_post_status.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Post a status (/api/v1/status).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 2)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname> <access token>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance and a Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], args[2]};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Set up the parameters.</span></div>
|
||||
<div class="line"> constexpr <span class="keyword">auto</span> poll_seconds{60 * 60 * 24 * 2}; <span class="comment">// 2 days.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> masto::parametermap parameters{{<span class="stringliteral">"status"</span>, <span class="stringliteral">"How is the weather?"</span>},</div>
|
||||
<div class="line"> {<span class="stringliteral">"poll[options]"</span>,</div>
|
||||
<div class="line"> vector<string_view>{<span class="stringliteral">"Nice"</span>,</div>
|
||||
<div class="line"> <span class="stringliteral">"not nice"</span>}},</div>
|
||||
<div class="line"> {<span class="stringliteral">"poll[expires_in]"</span>,</div>
|
||||
<div class="line"> to_string(poll_seconds)}};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Post the status.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{connection.post(masto::API::v1::statuses, parameters)};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Successfully posted a status.\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,108 +67,7 @@ $(function() {
|
|||
<div class="title">example04_post_with_attachment.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Post a status (/api/v1/status) with an attachment (/api/v1/media).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 3)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0]</div>
|
||||
<div class="line"> << <span class="stringliteral">" <instance hostname> <access token> <file>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance and a Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], args[2]};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> <span class="keyword">const</span> string_view filename{args[3]};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Create attachment.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{connection.post(masto::API::v1::media,</div>
|
||||
<div class="line"> {{<span class="stringliteral">"file"</span>, string(<span class="stringliteral">"@file:"</span>) += filename},</div>
|
||||
<div class="line"> {<span class="stringliteral">"description"</span>, <span class="stringliteral">"Test."</span>}})};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Get the ID of the attachment.</span></div>
|
||||
<div class="line"> <span class="comment">// You normally would use a JSON parser, of course. I don't use one</span></div>
|
||||
<div class="line"> <span class="comment">// because I don't want to add a dependency just for an example.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> pos{answer.body.find(R<span class="stringliteral">"("id":")") + 6};</span></div>
|
||||
<div class="line"><span class="stringliteral"> </span><span class="keyword">const</span> <span class="keyword">auto</span> endpos{answer.body.find(R<span class="stringliteral">"(",)", pos)};</span></div>
|
||||
<div class="line"><span class="stringliteral"> </span><span class="keyword">const</span> <span class="keyword">auto</span> media_id{answer.body.substr(pos, endpos - pos)};</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Attachment has ID: "</span> << media_id << endl;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Post the status. Note that “media_ids” always has to be a vector.</span></div>
|
||||
<div class="line"> answer = connection.post(masto::API::v1::statuses,</div>
|
||||
<div class="line"> {{<span class="stringliteral">"status"</span>, <span class="stringliteral">"Attachment test."</span>},</div>
|
||||
<div class="line"> {<span class="stringliteral">"media_ids"</span>,</div>
|
||||
<div class="line"> vector<string_view>{media_id}}});</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Successfully posted "</span> << filename << <span class="stringliteral">".\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,96 +67,7 @@ $(function() {
|
|||
<div class="title">example05_update_notification_settings.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Update notification settings (/api/pleroma/notification_settings).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 2)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname> <access token>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance and a Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], args[2]};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update the settings.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> answer{</div>
|
||||
<div class="line"> connection.put(masto::API::pleroma::notification_settings,</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> {<span class="stringliteral">"followers"</span>, <span class="stringliteral">"true"</span>},</div>
|
||||
<div class="line"> {<span class="stringliteral">"follows"</span>, <span class="stringliteral">"true"</span>},</div>
|
||||
<div class="line"> {<span class="stringliteral">"remote"</span>, <span class="stringliteral">"true"</span>},</div>
|
||||
<div class="line"> {<span class="stringliteral">"local"</span>, <span class="stringliteral">"true"</span>},</div>
|
||||
<div class="line"> })};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << answer << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,93 +67,7 @@ $(function() {
|
|||
<div class="title">example06_update_name.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Update account display name settings (/api/v1/accounts/update_credentials).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 3)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0]</div>
|
||||
<div class="line"> << <span class="stringliteral">" <instance hostname> <access token> <name>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> name{args[3]};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance and a Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], args[2]};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Update the settings.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> answer{</div>
|
||||
<div class="line"> connection.patch(masto::API::v1::accounts_update_credentials,</div>
|
||||
<div class="line"> {{<span class="stringliteral">"display_name"</span>, name}})};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Successfully changed display name.\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,110 +67,7 @@ $(function() {
|
|||
<div class="title">example07_delete_status.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Post a status (/api/v1/status), then delete it (/api/v1/statuses/:id).</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <chrono></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <thread></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using namespace </span>std::chrono_literals;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::this_thread::sleep_for;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 2)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname> <access token>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize an Instance and a Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], args[2]};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Post a status.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{connection.post(masto::API::v1::statuses,</div>
|
||||
<div class="line"> {{<span class="stringliteral">"status"</span>, <span class="stringliteral">"Delete me."</span>}})};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Successfully posted a status.\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Get the ID of the post.</span></div>
|
||||
<div class="line"> <span class="comment">// You normally would use a JSON parser, of course. I don't use one</span></div>
|
||||
<div class="line"> <span class="comment">// because I don't want to add a dependency just for an example.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> pos{answer.body.rfind(R<span class="stringliteral">"("id":")") + 6};</span></div>
|
||||
<div class="line"><span class="stringliteral"> </span><span class="keyword">const</span> <span class="keyword">auto</span> endpos{answer.body.find(R<span class="stringliteral">"(",)", pos)};</span></div>
|
||||
<div class="line"><span class="stringliteral"> </span><span class="keyword">const</span> <span class="keyword">auto</span> <span class="keywordtype">id</span>{answer.body.substr(pos, endpos - pos)};</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Post has ID: "</span> << <span class="keywordtype">id</span> << endl;</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Waiting 10 seconds…\n"</span>;</div>
|
||||
<div class="line"> sleep_for(10s);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> answer = connection.del(masto::API::v1::statuses_id, {{<span class="stringliteral">"id"</span>, <span class="keywordtype">id</span>}});</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Successfully deleted the status.\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code)</div>
|
||||
<div class="line"> << <span class="stringliteral">": "</span> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,125 +67,7 @@ $(function() {
|
|||
<div class="title">example08_obtain_token.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Obtain an access token and verify that it works.</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#include <cstdlib></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor">#include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cin;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::endl;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::exit;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">void</span> handle_error(<span class="keyword">const</span> masto::answer_type &answer);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 1)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize Instance and Instance::ObtainToken.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], {}};</div>
|
||||
<div class="line"> masto::Instance::ObtainToken token{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Create an “Application” (/api/v1/apps),</span></div>
|
||||
<div class="line"> <span class="comment">// and get URI for the authorization code (/oauth/authorize).</span></div>
|
||||
<div class="line"> <span class="comment">// NOTE: Mastodon only needs read:accounts for verify_credentials but</span></div>
|
||||
<div class="line"> <span class="comment">// Pleroma needs the full read scope.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{token.step_1(<span class="stringliteral">"Testclient"</span>, <span class="stringliteral">"read write:favourites"</span>,</div>
|
||||
<div class="line"> <span class="stringliteral">"https://example.com/"</span>)};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (!answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> handle_error(answer);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Please visit "</span> << answer << <span class="stringliteral">"\nand paste the code here: "</span>;</div>
|
||||
<div class="line"> <span class="keywordtype">string</span> code;</div>
|
||||
<div class="line"> cin >> code;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Obtain the token (/oauth/token).</span></div>
|
||||
<div class="line"> answer = token.step_2(code);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (!answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> handle_error(answer);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> cout << <span class="stringliteral">"Your access token is: "</span> << answer << endl;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Test if the token works.</span></div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> answer = connection.get(masto::API::v1::apps_verify_credentials);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (!answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> handle_error(answer);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> cout << answer << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">void</span> handle_error(<span class="keyword">const</span> masto::answer_type &answer)</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code) << <span class="stringliteral">": "</span></div>
|
||||
<div class="line"> << answer.error_message << endl;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> exit(1);</div>
|
||||
<div class="line">}</div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
@ -67,153 +67,7 @@ $(function() {
|
|||
<div class="title">example09_nlohmann_json.cpp</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodonpp.</span></div>
|
||||
<div class="line"><span class="comment"> * Copyright © 2020 tastytea <tastytea@tastytea.de></span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><span class="comment"> * purpose with or without fee is hereby granted.</span></div>
|
||||
<div class="line"><span class="comment"> *</span></div>
|
||||
<div class="line"><span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><span class="comment"> * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><span class="comment"> * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span></div>
|
||||
<div class="line"><span class="comment"> * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><span class="comment"> * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION</span></div>
|
||||
<div class="line"><span class="comment"> * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN</span></div>
|
||||
<div class="line"><span class="comment"> * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><span class="comment"> */</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Get the last 4 public statuses of an instance and process them with</span></div>
|
||||
<div class="line"><span class="comment">// nlohmann-json. <https://github.com/nlohmann/json></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include("mastodonpp.hpp")</span></div>
|
||||
<div class="line"><span class="preprocessor"># include "mastodonpp.hpp"</span> <span class="comment">// We're building mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <mastodonpp/mastodonpp.hpp></span> <span class="comment">// We're building outside mastodonpp.</span></div>
|
||||
<div class="line"><span class="preprocessor">#endif</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="comment">// Don't compile if nlohmann-json can't be found.</span></div>
|
||||
<div class="line"><span class="preprocessor">#if __has_include(<nlohmann/json.hpp>)</span></div>
|
||||
<div class="line"><span class="preprocessor"># include <nlohmann/json.hpp></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor"># include <cstdlib></span></div>
|
||||
<div class="line"><span class="preprocessor"># include <iostream></span></div>
|
||||
<div class="line"><span class="preprocessor"># include <string></span></div>
|
||||
<div class="line"><span class="preprocessor"># include <string_view></span></div>
|
||||
<div class="line"><span class="preprocessor"># include <vector></span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keyword">namespace </span>masto = <a class="code" href="namespacemastodonpp.html">mastodonpp</a>;</div>
|
||||
<div class="line"><span class="keyword">using</span> json = nlohmann::json;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cerr;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::cout;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::exit;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::string_view;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::to_string;</div>
|
||||
<div class="line"><span class="keyword">using</span> std::vector;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">void</span> handle_error(<span class="keyword">const</span> masto::answer_type &answer);</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keyword">const</span> vector<string_view> args(argv, argv + argc);</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (args.size() <= 1)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"Usage: "</span> << args[0] << <span class="stringliteral">" <instance hostname>\n"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">return</span> 1;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="keywordflow">try</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Initialize Instance and Connection.</span></div>
|
||||
<div class="line"> masto::Instance instance{args[1], {}};</div>
|
||||
<div class="line"> masto::Connection connection{instance};</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Get the last 4 public statuses of the instance.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> answer{connection.get(masto::API::v1::timelines_public,</div>
|
||||
<div class="line"> {{<span class="stringliteral">"limit"</span>, <span class="stringliteral">"4"</span>}, {<span class="stringliteral">"local"</span>, <span class="stringliteral">"true"</span>}})};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Parse JSON string.</span></div>
|
||||
<div class="line"> <span class="keyword">auto</span> statuses{json::parse(answer.body)};</div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> &status : statuses)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Extract the info we want and print it.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> acct{status[<span class="stringliteral">"account"</span>][<span class="stringliteral">"acct"</span>].get<string_view>()};</div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> content{status[<span class="stringliteral">"content"</span>].get<string_view>()};</div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> <span class="keywordtype">id</span>{status[<span class="stringliteral">"id"</span>].get<string_view>()};</div>
|
||||
<div class="line"> cout << acct << <span class="stringliteral">" wrote status "</span> << <span class="keywordtype">id</span> << <span class="stringliteral">": \n"</span>;</div>
|
||||
<div class="line"> cout << <span class="stringliteral">" "</span> << content.substr(0, 76) << <span class="stringliteral">" …\n"</span>;</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Print tags if there are any.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> tags{status[<span class="stringliteral">"tags"</span>]};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (!tags.empty())</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">" Tags: "</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> &tag : tags)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="charliteral">'#'</span> << tag[<span class="stringliteral">"name"</span>].get<string_view>() << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> cout << <span class="charliteral">'\n'</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> <span class="comment">// Print the number of attachments.</span></div>
|
||||
<div class="line"> <span class="keyword">const</span> <span class="keyword">auto</span> n_attachments{status[<span class="stringliteral">"media_attachments"</span>].size()};</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (n_attachments > 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">" "</span> << n_attachments << <span class="stringliteral">" attachment"</span>;</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (n_attachments > 1)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cout << <span class="stringliteral">"s"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> cout << <span class="stringliteral">".\n"</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> handle_error(answer);</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> masto::CURLException &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Only libcurl errors that are not network errors will be thrown.</span></div>
|
||||
<div class="line"> <span class="comment">// There went probably something wrong with the initialization.</span></div>
|
||||
<div class="line"> cerr << e.what() << <span class="charliteral">'\n'</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">catch</span> (<span class="keyword">const</span> nlohmann::detail::exception &e)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"JSON exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="keywordtype">void</span> handle_error(<span class="keyword">const</span> masto::answer_type &answer)</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> <span class="keywordflow">if</span> (answer.curl_error_code == 0)</div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// If it is no libcurl error, it must be an HTTP error.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"HTTP status: "</span> << answer.http_status << <span class="charliteral">'\n'</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> <span class="keywordflow">else</span></div>
|
||||
<div class="line"> {</div>
|
||||
<div class="line"> <span class="comment">// Network errors like “Couldn't resolve host.”.</span></div>
|
||||
<div class="line"> cerr << <span class="stringliteral">"libcurl error "</span> << to_string(answer.curl_error_code) << <span class="stringliteral">": "</span></div>
|
||||
<div class="line"> << answer.error_message << <span class="charliteral">'\n'</span>;</div>
|
||||
<div class="line"> }</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"> exit(1);</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#else</span></div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor"># include <iostream></span></div>
|
||||
<div class="line"><span class="keywordtype">int</span> main()</div>
|
||||
<div class="line">{</div>
|
||||
<div class="line"> std::cout << <span class="stringliteral">"Example could not be compiled "</span></div>
|
||||
<div class="line"> <span class="stringliteral">"because nlohmann-json was not found.\n"</span>;</div>
|
||||
<div class="line">}</div>
|
||||
<div class="line"> </div>
|
||||
<div class="line"><span class="preprocessor">#endif // __has_include(<nlohmann/json.hpp>)</span></div>
|
||||
</div><!-- fragment --> </div><!-- contents -->
|
||||
<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.hpp:24</div></div>
|
||||
<div class="fragment"></div><!-- fragment --> </div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">mastodonpp
|
||||
 <span id="projectnumber">0.5.5</span>
|
||||
 <span id="projectnumber">0.5.7</span>
|
||||
</div>
|
||||
<div id="projectbrief">C++ wrapper for the Mastodon and Pleroma APIs.</div>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue