2020-02-24 20:13:53 +01:00
|
|
|
/* This file is part of FediPotato.
|
|
|
|
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FEDIPOTATO_HPP
|
|
|
|
#define FEDIPOTATO_HPP
|
|
|
|
|
2020-02-29 06:30:19 +01:00
|
|
|
#include "config.hpp"
|
|
|
|
#include "version.hpp"
|
|
|
|
|
|
|
|
#include <string>
|
2020-02-25 03:22:13 +01:00
|
|
|
#include <string_view>
|
|
|
|
|
2020-02-24 20:13:53 +01:00
|
|
|
namespace FediPotato
|
|
|
|
{
|
|
|
|
|
2020-02-29 06:30:19 +01:00
|
|
|
using std::string;
|
2020-02-25 03:22:13 +01:00
|
|
|
using std::string_view;
|
|
|
|
|
2020-02-25 18:12:41 +01:00
|
|
|
/*!
|
|
|
|
* @brief High-level interface to fediverse accounts and their data.
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*
|
|
|
|
* @headerfile fedipotato.hpp FediPotato/fedipotato.hpp
|
|
|
|
*/
|
2020-02-25 03:22:13 +01:00
|
|
|
class FediPotato
|
|
|
|
{
|
|
|
|
public:
|
2020-02-29 06:30:19 +01:00
|
|
|
/*!
|
|
|
|
* @brief Construct a FediPotato object.
|
|
|
|
*
|
|
|
|
* These exception could occur:
|
|
|
|
* * `std::runtime_error` (Directory not found)
|
|
|
|
* * `std::filesystem::filesystem_error` (Could not create directory)
|
|
|
|
* * `std::ifstream::failure` (Could not read from file)
|
2020-02-29 21:55:45 +01:00
|
|
|
* * `std::ofstream::failure` (Could not write to file)
|
2020-02-29 06:30:19 +01:00
|
|
|
* * `nlohmann::detail::parse_error` (Could not parse file)
|
|
|
|
*
|
|
|
|
* @param application_name The name of your application. Influences the
|
|
|
|
* file paths for all the data that is stored.
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
|
|
|
explicit FediPotato(const string_view application_name)
|
|
|
|
: _application_name{application_name}
|
|
|
|
, _config{application_name, "general.json"}
|
|
|
|
{
|
|
|
|
}
|
2020-02-25 03:22:13 +01:00
|
|
|
|
|
|
|
//! Copy constructor
|
|
|
|
FediPotato(const FediPotato &other) = default;
|
|
|
|
|
|
|
|
//! Move constructor
|
|
|
|
FediPotato(FediPotato &&other) noexcept = default;
|
|
|
|
|
|
|
|
//! Destructor
|
|
|
|
virtual ~FediPotato() noexcept = default;
|
|
|
|
|
|
|
|
//! Copy assignment operator
|
2020-02-29 06:30:19 +01:00
|
|
|
FediPotato& operator=(const FediPotato &other) = delete;
|
2020-02-25 03:22:13 +01:00
|
|
|
|
|
|
|
//! Move assignment operator
|
2020-02-29 06:30:19 +01:00
|
|
|
FediPotato& operator=(FediPotato &&other) noexcept = delete;
|
2020-02-25 03:22:13 +01:00
|
|
|
|
2020-02-25 23:17:08 +01:00
|
|
|
public:
|
2020-02-25 03:22:13 +01:00
|
|
|
/*!
|
2020-02-29 06:30:19 +01:00
|
|
|
* @brief Return the version of the library.
|
2020-02-25 03:22:13 +01:00
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-02-29 02:16:18 +01:00
|
|
|
inline static constexpr string_view get_version()
|
|
|
|
{
|
|
|
|
return version;
|
|
|
|
}
|
2020-02-29 06:30:19 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Set the proxy server.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* @code
|
|
|
|
* FediPotato account("example");
|
|
|
|
* account.set_proxy("socks4a://user:password@localhost:9050");
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* @param proxy curl-compatible proxy string. See [CURLOPT_PROXY(3)]
|
|
|
|
* (https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html).
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
|
|
|
void set_proxy(const string_view proxy)
|
|
|
|
{
|
|
|
|
_config.set("proxy", proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const string _application_name;
|
|
|
|
Config _config;
|
2020-02-25 03:22:13 +01:00
|
|
|
};
|
|
|
|
|
2020-02-24 20:13:53 +01:00
|
|
|
} // namespace FediPotato
|
|
|
|
|
|
|
|
#endif // FEDIPOTATO_HPP
|