]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/membership.h
cmode_k Fix oversight in substr() conversion
[user/henk/code/inspircd.git] / include / membership.h
index e2c13c7e4ff4dfbb158ea6aa2b542d95c3913d54..11c142912ee60e6612980416c924bb514d08809c 100644 (file)
@@ -20,6 +20,8 @@
 
 #pragma once
 
+uint64_t ConvToUInt64(const std::string& in);
+
 /**
  * Represents a member of a channel.
  * A Membership object is created when a user joins a channel, and destroyed when a user leaves
  * All prefix modes a member has is tracked by this object. Moreover, Memberships are Extensibles
  * meaning modules can add arbitrary data to them using extensions (see m_delaymsg for an example).
  */
-class CoreExport Membership : public Extensible, public intrusive_list_node<Membership>
+class CoreExport Membership : public Extensible, public insp::intrusive_list_node<Membership>
 {
  public:
+       /** Type of the Membership id
+        */
+       typedef uint64_t Id;
+
        /** User on the channel
         */
        User* const user;
@@ -43,6 +49,20 @@ class CoreExport Membership : public Extensible, public intrusive_list_node<Memb
         */
        std::string modes;
 
+       /** Id of this Membership, set by the protocol module, other components should never read or
+        * write this field.
+        */
+       Id id;
+
+       /** Converts a string to a Membership::Id
+        * @param str The string to convert
+        * @return Raw value of type Membership::Id
+        */
+       static Id IdFromString(const std::string& str)
+       {
+               return ConvToUInt64(str);
+       }
+
        /** Constructor, sets the user and chan fields to the parameters, does NOT update any bookkeeping
         * information in the User or the Channel.
         * Call Channel::JoinUser() or ForceJoin() to make a user join a channel instead of constructing
@@ -99,7 +119,7 @@ class InviteBase
  protected:
        /** List of pending Invitations
         */
-       intrusive_list<Invitation, T> invites;
+       insp::intrusive_list<Invitation, T> invites;
 
  public:
        /** Remove and destruct all pending invitations this user or channel has.
@@ -114,7 +134,7 @@ class InviteBase
  * The Invitation class contains all data about a pending invitation.
  * Invitation objects are referenced from the user and the channel they belong to.
  */
-class CoreExport Invitation : public intrusive_list_node<Invitation, Channel>, public intrusive_list_node<Invitation, LocalUser>
+class CoreExport Invitation : public insp::intrusive_list_node<Invitation, Channel>, public insp::intrusive_list_node<Invitation, LocalUser>
 {
        /** Constructs an Invitation, only called by Create()
         * @param c Channel the user is invited to
@@ -162,12 +182,12 @@ class CoreExport Invitation : public intrusive_list_node<Invitation, Channel>, p
        static Invitation* Find(Channel* c, LocalUser* u, bool check_expired = true);
 };
 
-typedef intrusive_list<Invitation, LocalUser> InviteList;
+typedef insp::intrusive_list<Invitation, LocalUser> InviteList;
 
 template<typename T>
 inline void InviteBase<T>::ClearInvites()
 {
-       for (typename intrusive_list<Invitation, T>::iterator i = invites.begin(); i != invites.end(); )
+       for (typename insp::intrusive_list<Invitation, T>::iterator i = invites.begin(); i != invites.end(); )
        {
                Invitation* inv = *i;
                // Destructing the Invitation invalidates the iterator, so move it now