55 lines
6.0 KiB
HTML
55 lines
6.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.14"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>mastodon-cpp: example10_simplify.cpp</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">mastodon-cpp
|
|
 <span id="projectnumber">0.20.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.14 -->
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',false,false,'search.php','Search');
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">example10_simplify.cpp</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="fragment"><div class="line"><span class="comment">/* This file is part of mastodon-cpp.</span></div><div class="line"><span class="comment"> * Simplify the interface</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></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 <cstdint></span></div><div class="line"><span class="preprocessor">#ifdef MASTODON_CPP</span></div><div class="line"><span class="preprocessor"> #include "mastodon-cpp.hpp"</span></div><div class="line"><span class="preprocessor">#else</span></div><div class="line"><span class="preprocessor"> #include <mastodon-cpp/mastodon-cpp.hpp></span></div><div class="line"><span class="preprocessor">#endif</span></div><div class="line"></div><div class="line"><span class="keyword">using</span> <a name="_a0"></a><a class="code" href="classMastodon_1_1API.html">Mastodon::API</a>;</div><div class="line"></div><div class="line"><span class="keyword">class </span>EasyToot : <span class="keyword">public</span> <a class="code" href="classMastodon_1_1API.html">Mastodon::API</a></div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> <span class="keyword">explicit</span> EasyToot(<span class="keyword">const</span> std::string &instance, <span class="keyword">const</span> std::string &access_token)</div><div class="line"> : <a name="a1"></a><a class="code" href="classMastodon_1_1API.html#a627a687d2f211d714d2e1d2bd3faf7ff">API</a>(instance, access_token)</div><div class="line"> {}</div><div class="line"></div><div class="line"> std::uint16_t toot(<span class="keyword">const</span> std::string &text, <span class="keyword">const</span> std::string &cw = <span class="stringliteral">""</span>)</div><div class="line"> {</div><div class="line"> std::string answer;</div><div class="line"> API::parametermap parameters;</div><div class="line"> parameters.insert({ <span class="stringliteral">"status"</span>, { text } } );</div><div class="line"> <span class="keywordflow">if</span> (!cw.empty())</div><div class="line"> {</div><div class="line"> parameters.insert({ <span class="stringliteral">"spoiler_text"</span>, { cw } } );</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> <a name="a2"></a><a class="code" href="classMastodon_1_1API.html#aaf5ba9253c05c733bc6a7819fd7455cd">post</a>(API::v1::statuses, parameters, answer);</div><div class="line"> }</div><div class="line">};</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="keywordflow">if</span> (argc < 3)</div><div class="line"> {</div><div class="line"> std::cerr << <span class="stringliteral">"usage: "</span> << argv[0] << <span class="stringliteral">" <instance> <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"> std::uint16_t ret = 0;</div><div class="line"> EasyToot masto(argv[1], argv[2]);</div><div class="line"></div><div class="line"> ret = masto.toot(<span class="stringliteral">"Test"</span>);</div><div class="line"> <span class="keywordflow">if</span> (ret != 0)</div><div class="line"> {</div><div class="line"> std::cerr << <span class="stringliteral">"Error: "</span> << ret << <span class="charliteral">'\n'</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> ret;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.14
|
|
</small></address>
|
|
</body>
|
|
</html>
|