user.cpp 855 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "user.h"
  2. #include "chatroom.h"
  3. user::user()
  4. {
  5. initialize();
  6. }
  7. user::~user()
  8. {
  9. clear();
  10. }
  11. void user::clear()
  12. {
  13. userid = 0;
  14. idisposable::dereference((idisposable **)&username);
  15. idisposable::dereference((idisposable **)&password);
  16. chatrooms_allowed.clear(true);
  17. return;
  18. }
  19. void user::initialize()
  20. {
  21. username = nullptr;
  22. password = nullptr;
  23. userid = 0;
  24. return;
  25. }
  26. user *user::find(biglist<user *>*user_list,int64_t user_id)
  27. {
  28. biglist_iterator<user *> loop(user_list);
  29. while (!loop.eof()) {
  30. if (loop.item->userid == user_id) {
  31. return loop.item;
  32. }
  33. loop.movenext();
  34. }
  35. return nullptr;
  36. }
  37. user *user::find(biglist<user *>*user_list,datastring user_name)
  38. {
  39. biglist_iterator<user *> loop(user_list);
  40. while (!loop.eof()) {
  41. if (*(loop.item->username) == user_name) {
  42. return loop.item;
  43. }
  44. loop.movenext();
  45. }
  46. return nullptr;
  47. }