File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -751,3 +751,33 @@ int mysql_adaptor_mbop_userlist(std::vector<sql_user> &out) try
751751} catch (const std::bad_alloc &) {
752752 return ENOMEM;
753753}
754+
755+ /* *
756+ * @brief Compare domains based on (case-insensitive) domain name
757+ *
758+ * @param o Other domain
759+ *
760+ * @return Result of lexicographic comparison
761+ */
762+ std::weak_ordering sql_domain::operator <=>(const sql_domain& o) const {
763+ auto r = strcasecmp (name.c_str (), o.name .c_str ());
764+ return r < 0 ? std::weak_ordering::less : r == 0 ? std::weak_ordering::equivalent : std::weak_ordering::greater;
765+ }
766+
767+ /* *
768+ * @brief Compare users based on (case-insensitive) display name
769+ *
770+ * Missing display names are substituted with the username.
771+ *
772+ * @param Other user
773+ *
774+ * @return Result of lexicographic comparison
775+ */
776+ std::weak_ordering sql_user::operator <=>(const sql_user &o) const {
777+ auto i = propvals.find (PR_DISPLAY_NAME);
778+ auto name_this = i != propvals.end () ? i->second .c_str () : username.c_str ();
779+ i = o.propvals .find (PR_DISPLAY_NAME);
780+ auto name_other = i != o.propvals .end () ? i->second .c_str () : o.username .c_str ();
781+ auto r = strcasecmp (name_this, name_other);
782+ return r == 0 ? std::weak_ordering::equivalent : r < 0 ? std::weak_ordering::less : std::weak_ordering::greater;
783+ }
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ struct mysql_adaptor_init_param {
5050
5151struct sql_domain {
5252 std::string name, title, address;
53+
54+ std::weak_ordering operator <=>(const sql_domain&) const ;
5355};
5456
5557/* *
@@ -90,6 +92,8 @@ struct sql_user {
9092 std::string username, homeserver, maildir;
9193 std::vector<std::string> aliases; /* email addresses */
9294 std::map<unsigned int , std::string> propvals;
95+
96+ std::weak_ordering operator <=>(const sql_user &o) const ;
9397};
9498
9599struct sql_group {
You can’t perform that action at this time.
0 commit comments