From 80df5cafffe256861adb829f881206044d5fe9ad Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 15 Jan 2018 15:34:18 +0100 Subject: [PATCH] updated documentation --- Doxyfile | 4 ++-- README.md | 2 +- src/examples/example3_mastocron.cpp | 13 +++++++++++++ src/mastodon-cpp.hpp | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Doxyfile b/Doxyfile index e7e6adf..3c18141 100644 --- a/Doxyfile +++ b/Doxyfile @@ -77,8 +77,8 @@ WARN_FORMAT = "$file:$line: $text" INPUT_ENCODING = UTF-8 RECURSIVE = NO EXCLUDE_SYMLINKS = NO -EXAMPLE_PATH = examples -EXAMPLE_RECURSIVE = NO +EXAMPLE_PATH = src/examples +EXAMPLE_RECURSIVE = YES FILTER_SOURCE_FILES = NO SOURCE_BROWSER = NO INLINE_SOURCES = YES diff --git a/README.md b/README.md index 6633fe6..0a4f487 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Install with `make install`. # Usage -The HTML reference can be generated with `build_doc.sh`, if doxygen is installed. Or just look in `src/mastodon-cpp.hpp`. There is an example in `src/examples/`. +The HTML reference can be generated with `build_doc.sh`, if doxygen is installed. Or just look in `src/mastodon-cpp.hpp`. There are examples in `src/examples/`. ## Compiling your project diff --git a/src/examples/example3_mastocron.cpp b/src/examples/example3_mastocron.cpp index 12bfd8a..882ed6c 100644 --- a/src/examples/example3_mastocron.cpp +++ b/src/examples/example3_mastocron.cpp @@ -60,6 +60,15 @@ int main(int argc, char *argv[]) // if answer is "[]" there are none at all if (answer != "" && answer != "[]") { + string ornament = " +++++"; + for (std::uint8_t i = hashtag.size(); i > 0; --i) + { + ornament += "+"; + } + cout << ornament << '\n'; + cout << " + " << hashtag << ": +\n"; + cout << ornament << '\n'; + std::istringstream iss(answer); pt::ptree tree; @@ -78,6 +87,10 @@ int main(int argc, char *argv[]) << " (" << toot.second.get("account.acct") << ") at " << toot.second.get("created_at") << "\n"; cout << " " << toot.second.get("url") << '\n'; + for (const pt::ptree::value_type &media : toot.second.get_child("media_attachments")) + { + cout << "Attachment: <" << media.second.get("url") << ">\n"; + } cout << "++++++++\n"; } diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index 0b74c23..0e5feb7 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -23,8 +23,27 @@ #include #include +/*! + * @example example1_dump_json.cpp + * @example example2_parse_account.cpp + * @example example3_mastocron.cpp + */ namespace Mastodon { +/*! + * @brief Class for the Mastodon API. + * @section error Error codes + * | Code | Explanation | + * | --------: |:------------------------------| + * | 0 | No error | + * | 1 | Invalid call | + * | 2 | Not implemented | + * | 16 | Connection failed | + * | 17 | TLS error | + * | 18 | Invalid response from server | + * | 100 - 999 | HTTP status codes | + * | 65535 | Unknown exception | + */ class API { public: