Whyblocked reminds you why you blocked someone.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4KB

  1. /* This file is part of whyblocked.
  2. * Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, version 3.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef WHYBLOCKED_HPP
  17. #define WHYBLOCKED_HPP
  18. #include <vector>
  19. #include <string>
  20. using std::string;
  21. using std::vector;
  22. class Database
  23. {
  24. public:
  25. struct data
  26. {
  27. string user;
  28. bool blocked;
  29. string reason;
  30. vector<string> receipts;
  31. explicit operator bool() const;
  32. };
  33. bool add_user(const data &userdata);
  34. bool remove(const string &user);
  35. const vector<data> query(const string &sql_query =
  36. "SELECT * FROM blocks;") const;
  37. bool reload();
  38. std::vector<data> &get_data();
  39. const data get_user(const string &user) const;
  40. private:
  41. std::vector<data> _data;
  42. private:
  43. const string get_filepath() const;
  44. };
  45. #endif // WHYBLOCKED_HPP