ircproxy The Ultimate Cyborg |
00001 // ircproxy -- An IRC bouncer. 00002 // 00003 //! @file UserMode.cc 00004 //! @brief This file contains the implementation of class UserMode. 00005 // 00006 // Copyright (C) 2006, 2007 by 00007 // 00008 // Carlo Wood, Run on IRC <carlo@alinoe.com> 00009 // RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt 00010 // Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61 00011 // 00012 // This file may be distributed under the terms of the Q Public License 00013 // version 1.0 as appearing in the file LICENSE.QPL included in the 00014 // packaging of this file. 00015 00016 #ifndef USE_PCH 00017 #include "sys.h" 00018 #include "debug.h" 00019 #endif 00020 00021 #include "UserMode.h" 00022 #include "MessageIn.h" 00023 00024 //! Decode the MODE message \a msg and store the user mode. 00025 void UserMode::new_server_message_received(ServerMessageIn const& msg) 00026 { 00027 DoutEntering(dc::notice, "UserMode::new_server_message_received(" << msg << ")"); 00028 std::string mode_string = msg.param(1); 00029 bool add = true; 00030 for (std::string::iterator iter = mode_string.begin(); iter != mode_string.end(); ++iter) 00031 { 00032 if (*iter == '+') 00033 add = true; 00034 else if (*iter == '-') 00035 add = false; 00036 else if (add) 00037 M_mask |= *iter; 00038 else 00039 M_mask &= ~*iter; 00040 } 00041 Dout(dc::notice, "M_mask is now " << M_mask); 00042 } 00043 00044 UserModeMask& UserModeMask::operator=(char c) 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 } 00068 00069 UserModeMask& UserModeMask::operator|=(char c) 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 } 00081 00082 UserModeMask& UserModeMask::operator|=(UserModeMask const& um) 00083 { 00084 uppercase_modes |= um.uppercase_modes; 00085 lowercase_modes |= um.lowercase_modes; 00086 return *this; 00087 } 00088 00089 UserModeMask& UserModeMask::operator&=(char c) 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 } 00101 00102 UserModeMask& UserModeMask::operator&=(UserModeMask const& um) 00103 { 00104 uppercase_modes &= um.uppercase_modes; 00105 lowercase_modes &= um.lowercase_modes; 00106 return *this; 00107 } 00108 00109 UserModeMask& UserModeMask::operator^=(char c) 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 } 00121 00122 UserModeMask& UserModeMask::operator^=(UserModeMask const& um) 00123 { 00124 uppercase_modes ^= um.uppercase_modes; 00125 lowercase_modes ^= um.lowercase_modes; 00126 return *this; 00127 } 00128
Copyright © 2005-2007 Carlo Wood. All rights reserved. |
---|