ircproxy  The Ultimate Cyborg

UserModeMask Struct Reference

#include <UserMode.h>

List of all members.


Detailed Description

For internal use only.

Definition at line 44 of file UserMode.h.


Public Member Functions

 UserModeMask ()
 Default constructor. Constructs a UserModeMask with no usermodes sets.
 UserModeMask (char c)
 Construct a UserModeMask with only mode c set.
UserModeMaskoperator= (char c)
 Reset the mask to just mode c.
UserModeMaskoperator|= (char c)
 Set mode c.
UserModeMaskoperator|= (UserModeMask const &um)
 Bitwise OR this mask with um.
UserModeMaskoperator &= (char c)
 Reset all modes except usermode c.
UserModeMaskoperator &= (UserModeMask const &um)
 Bitwise AND this mask with um.
UserModeMaskoperator^= (char c)
 Toggle usermode c.
UserModeMaskoperator^= (UserModeMask const &um)
 Bitwise XOR this mask with um.

Public Attributes

uint32_t uppercase_modes
 A mask for uppercase usermodes. Bit 0 represents 'A' and so on.
uint32_t lowercase_modes
 A mask for lowercase usermodes. Bit 0 represents 'a' and so on.

Friends

bool operator== (UserModeMask const &um1, UserModeMask const &um2)
 Compare two UserModeMask instances.
bool operator!= (UserModeMask const &um1, UserModeMask const &um2)
 Compare two UserModeMask instances.
std::ostream & operator<< (std::ostream &os, UserModeMask const &um)
 For debugging purpose; write UserModeMask m to os.

Constructor & Destructor Documentation

UserModeMask::UserModeMask (  )  [inline]

Default constructor. Constructs a UserModeMask with no usermodes sets.

Definition at line 49 of file UserMode.h.

00049 : uppercase_modes(0), lowercase_modes(0) { }

UserModeMask::UserModeMask ( char  c  )  [inline]

Construct a UserModeMask with only mode c set.

Definition at line 51 of file UserMode.h.

00051 : uppercase_modes(0), lowercase_modes(0) { *this = c; }


Member Function Documentation

UserModeMask & UserModeMask::operator= ( char  c  ) 

Reset the mask to just mode c.

Definition at line 44 of file UserMode.cc.

References lowercase_modes, make_lowercase_usermode_mask(), make_uppercase_usermode_mask(), and uppercase_modes.

00045 {
00046   if (std::isupper(c))
00047   {
00048     uppercase_modes = make_uppercase_usermode_mask(c);
00049     lowercase_modes = 0;
00050   }
00051   else if (std::islower(c))
00052   {
00053     uppercase_modes = 0;
00054     lowercase_modes = make_lowercase_usermode_mask(c);
00055   }
00056   else if (std::isupper(~c))
00057   {
00058     uppercase_modes = ~make_uppercase_usermode_mask(~c);
00059     lowercase_modes = 0;
00060   }
00061   else if (std::islower(~c))
00062   {
00063     uppercase_modes = 0;
00064     lowercase_modes = ~make_lowercase_usermode_mask(~c);
00065   }
00066   return *this;
00067 }

UserModeMask & UserModeMask::operator|= ( char  c  ) 

Set mode c.

Definition at line 69 of file UserMode.cc.

References lowercase_modes, make_lowercase_usermode_mask(), make_uppercase_usermode_mask(), and uppercase_modes.

00070 {
00071   if (std::isupper(c))
00072     uppercase_modes |= make_uppercase_usermode_mask(c);
00073   else if (std::islower(c))
00074     lowercase_modes |= make_lowercase_usermode_mask(c);
00075   else if (std::isupper(~c))
00076     uppercase_modes |= ~make_uppercase_usermode_mask(~c);
00077   else if (std::islower(~c))
00078     lowercase_modes |= ~make_lowercase_usermode_mask(~c);
00079   return *this;
00080 }

UserModeMask & UserModeMask::operator|= ( UserModeMask const &  um  ) 

Bitwise OR this mask with um.

Definition at line 82 of file UserMode.cc.

References lowercase_modes, and uppercase_modes.

00083 {
00084   uppercase_modes |= um.uppercase_modes;
00085   lowercase_modes |= um.lowercase_modes;
00086   return *this;
00087 }

UserModeMask & UserModeMask::operator &= ( char  c  ) 

Reset all modes except usermode c.

Definition at line 89 of file UserMode.cc.

References lowercase_modes, make_lowercase_usermode_mask(), make_uppercase_usermode_mask(), and uppercase_modes.

00090 {
00091   if (std::isupper(c))
00092     uppercase_modes &= make_uppercase_usermode_mask(c);
00093   else if (std::islower(c))
00094     lowercase_modes &= make_lowercase_usermode_mask(c);
00095   else if (std::isupper(~c))
00096     uppercase_modes &= ~make_uppercase_usermode_mask(~c);
00097   else if (std::islower(~c))
00098     lowercase_modes &= ~make_lowercase_usermode_mask(~c);
00099   return *this;
00100 }

UserModeMask & UserModeMask::operator &= ( UserModeMask const &  um  ) 

Bitwise AND this mask with um.

Definition at line 102 of file UserMode.cc.

References lowercase_modes, and uppercase_modes.

00103 {
00104   uppercase_modes &= um.uppercase_modes;
00105   lowercase_modes &= um.lowercase_modes;
00106   return *this;
00107 }

UserModeMask & UserModeMask::operator^= ( char  c  ) 

Toggle usermode c.

Definition at line 109 of file UserMode.cc.

References lowercase_modes, make_lowercase_usermode_mask(), make_uppercase_usermode_mask(), and uppercase_modes.

00110 {
00111   if (std::isupper(c))
00112     uppercase_modes ^= make_uppercase_usermode_mask(c);
00113   else if (std::islower(c))
00114     lowercase_modes ^= make_lowercase_usermode_mask(c);
00115   else if (std::isupper(~c))
00116     uppercase_modes ^= ~make_uppercase_usermode_mask(~c);
00117   else if (std::islower(~c))
00118     lowercase_modes ^= ~make_lowercase_usermode_mask(~c);
00119   return *this;
00120 }

UserModeMask & UserModeMask::operator^= ( UserModeMask const &  um  ) 

Bitwise XOR this mask with um.

Definition at line 122 of file UserMode.cc.

References lowercase_modes, and uppercase_modes.

00123 {
00124   uppercase_modes ^= um.uppercase_modes;
00125   lowercase_modes ^= um.lowercase_modes;
00126   return *this;
00127 }


Friends And Related Function Documentation

bool operator== ( UserModeMask const &  um1,
UserModeMask const &  um2 
) [friend]

Compare two UserModeMask instances.

Definition at line 69 of file UserMode.h.

00070   {
00071     return um1.lowercase_modes == um2.lowercase_modes &&
00072            um2.uppercase_modes == um2.uppercase_modes;
00073   }

bool operator!= ( UserModeMask const &  um1,
UserModeMask const &  um2 
) [friend]

Compare two UserModeMask instances.

Definition at line 76 of file UserMode.h.

00077   {
00078     return um1.lowercase_modes != um2.lowercase_modes ||
00079            um2.uppercase_modes != um2.uppercase_modes;
00080   }

std::ostream& operator<< ( std::ostream &  os,
UserModeMask const &  um 
) [friend]

For debugging purpose; write UserModeMask m to os.

Definition at line 84 of file UserMode.h.

00085   {
00086     os << "\"+";
00087     char c = 'a';
00088     for (uint32_t m = 1; c <= 'z'; ++c, m <<= 1)
00089       if ((um.lowercase_modes & m))
00090         os << c;
00091     c = 'A';
00092     for (uint32_t m = 1; c <= 'z'; ++c, m <<= 1)
00093       if ((um.uppercase_modes & m))
00094         os << c;
00095     return os << '"';
00096   }


Member Data Documentation

A mask for uppercase usermodes. Bit 0 represents 'A' and so on.

Definition at line 45 of file UserMode.h.

Referenced by operator &=(), operator=(), operator^=(), and operator|=().

A mask for lowercase usermodes. Bit 0 represents 'a' and so on.

Definition at line 46 of file UserMode.h.

Referenced by operator &=(), operator=(), operator^=(), and operator|=().


The documentation for this struct was generated from the following files:

Copyright © 2005-2007 Carlo Wood.  All rights reserved.