diff options
author | Adam <Adam@anope.org> | 2011-01-08 00:25:11 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-01-08 00:25:11 -0500 |
commit | 512d23d60f25203ab88605ba131a0704cadd2263 (patch) | |
tree | f7bf42a648677f02f170db1e6692fafad10d81c6 /include | |
parent | 44038491264a350a8849e1d7e8547bbdec134d74 (diff) |
Made the Flag class able to convert flags to strings and back
Diffstat (limited to 'include')
-rw-r--r-- | include/account.h | 10 | ||||
-rw-r--r-- | include/channels.h | 4 | ||||
-rw-r--r-- | include/commands.h | 10 | ||||
-rw-r--r-- | include/modes.h | 35 | ||||
-rw-r--r-- | include/regchannel.h | 6 | ||||
-rw-r--r-- | include/servers.h | 2 | ||||
-rw-r--r-- | include/services.h | 36 | ||||
-rw-r--r-- | include/sockets.h | 2 | ||||
-rw-r--r-- | include/users.h | 1 |
9 files changed, 103 insertions, 3 deletions
diff --git a/include/account.h b/include/account.h index 08652f13c..afef1236d 100644 --- a/include/account.h +++ b/include/account.h @@ -41,6 +41,10 @@ enum NickNameFlag NS_END }; +const Anope::string NickNameFlagStrings[] = { + "NS_BEGIN", "NS_FORBIDDEN", "NS_NO_EXPIRE", "NS_HELD", "NS_COLLIDED", "NS_END", "" +}; + /** Flags set on NickCores */ enum NickCoreFlag @@ -85,6 +89,12 @@ enum NickCoreFlag NI_END }; +const Anope::string NickCoreFlagStrings[] = { + "NI_BEGIN", "NI_KILLPROTECT", "NI_SECURE", "NI_MSG", "NI_MEMO_HARDMAX", "NI_MEMO_SIGNON", "NI_MEMO_RECEIVE", + "NI_PRIVATE", "NI_HIDE_EMAIL", "NI_HIDE_MASK", "NI_HIDE_QUIT", "NI_KILL_QUICK", "NI_KILL_IMMED", + "NI_MEMO_MAIL", "NI_HIDE_STATUS", "NI_SUSPENDED", "NI_AUTOOP", "NI_FORBIDDEN", "" +}; + class CoreExport NickRequest : public Extensible { public: diff --git a/include/channels.h b/include/channels.h index 6991e1a20..8d6cbde5e 100644 --- a/include/channels.h +++ b/include/channels.h @@ -52,7 +52,7 @@ struct UserContainer typedef std::list<UserContainer *> CUserList; -enum ChannelFlags +enum ChannelFlag { /* Channel still exists when emptied */ CH_PERSIST, @@ -62,7 +62,7 @@ enum ChannelFlags CH_LOGCHAN }; -class CoreExport Channel : public Extensible, public Flags<ChannelFlags> +class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3> { public: typedef std::multimap<ChannelModeName, Anope::string> ModeList; diff --git a/include/commands.h b/include/commands.h index 4abaa43b8..afb7ab51f 100644 --- a/include/commands.h +++ b/include/commands.h @@ -43,6 +43,16 @@ enum CommandFlag CFLAG_DISABLE_FANTASY }; +const Anope::string CommandFlagStrings[] = { + "CFLAG_ALLOW_UNREGISTERED", + "CFLAG_ALLOW_FORBIDDEN", + "CFLAG_ALLOW_SUSPENDED", + "CFLAG_ALLOW_UNREGISTEREDCHANNEL", + "CFLAG_STRIP_CHANNEL", + "CFLAG_DISABLE_FANTASY", + "" +}; + /* The source for a command */ struct CoreExport CommandSource { diff --git a/include/modes.h b/include/modes.h index c6534f353..9cf780b31 100644 --- a/include/modes.h +++ b/include/modes.h @@ -24,6 +24,18 @@ enum UserModeName UMODE_END }; +const Anope::string UserModeNameStrings[] = { + "UMODE_BEGIN", + + "UMODE_SERV_ADMIN", "UMODE_BOT", "UMODE_CO_ADMIN", "UMODE_FILTER", "UMODE_HIDEOPER", "UMODE_NETADMIN", + "UMODE_REGPRIV", "UMODE_PROTECTED", "UMODE_NO_CTCP", "UMODE_WEBTV", "UMODE_WEBIRC", "UMODE_WHOIS", "UMODE_ADMIN", "UMODE_DEAF", + "UMODE_GLOBOPS", "UMODE_HELPOP", "UMODE_INVIS", "UMODE_OPER", "UMODE_PRIV", "UMODE_GOD", "UMODE_REGISTERED", + "UMODE_SNOMASK", "UMODE_VHOST", "UMODE_WALLOPS", "UMODE_CLOAK", "UMODE_SSL", "UMODE_SOFTCALLERID", "UMODE_CALLERID", + "UMODE_COMMONCHANS", "UMODE_HIDDEN", "UMODE_STRIPCOLOR", "UMODE_INVISIBLE_OPER", + + "" +}; + /** All of the valid channel mode names */ enum ChannelModeName @@ -49,6 +61,29 @@ enum ChannelModeName CMODE_END }; +const Anope::string ChannelModeNameStrings[] = { + "CMODE_BEGIN", + + /* Channel modes */ + "CMODE_BLOCKCOLOR", " CMODE_FLOOD", " CMODE_INVITE", " CMODE_KEY", " CMODE_LIMIT", " CMODE_MODERATED", " CMODE_NOEXTERNAL", + "CMODE_PRIVATE", " CMODE_REGISTERED", " CMODE_SECRET", " CMODE_TOPIC", " CMODE_AUDITORIUM", " CMODE_SSL", " CMODE_ADMINONLY", + "CMODE_NOCTCP", " CMODE_FILTER", " CMODE_NOKNOCK", " CMODE_REDIRECT", " CMODE_REGMODERATED", " CMODE_NONICK", " CMODE_OPERONLY", + "CMODE_NOKICK", " CMODE_REGISTEREDONLY", " CMODE_STRIPCOLOR", " CMODE_NONOTICE", " CMODE_NOINVITE", " CMODE_ALLINVITE", + "CMODE_BLOCKCAPS", " CMODE_PERM", " CMODE_NICKFLOOD", " CMODE_JOINFLOOD", " CMODE_DELAYEDJOIN", " CMODE_NOREJOIN", + "CMODE_BANDWIDTH", + + /* b/e/I */ + "CMODE_BAN", " CMODE_EXCEPT", + "CMODE_INVITEOVERRIDE", + + /* v/h/o/a/q */ + "CMODE_VOICE", " CMODE_HALFOP", " CMODE_OP", + "CMODE_PROTECT", " CMODE_OWNER", + + "" +}; + + /** The different types of modes */ enum ModeType diff --git a/include/regchannel.h b/include/regchannel.h index 4be8a50aa..298e35798 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -62,6 +62,12 @@ enum ChannelInfoFlag CI_END }; +const Anope::string ChannelInfoFlagStrings[] = { + "CI_BEGIN", "CI_INHABIT", "CI_KEEPTOPIC", "CI_SECUREOPS", "CI_PRIVATE", "CI_TOPICLOCK", "CI_RESTRICTED", + "CI_PEACE", "CI_SECURE", "CI_FORBIDDEN", "CI_NO_EXPIRE", "CI_MEMO_HARDMAX", "CI_OPNOTICE", "CI_SECUREFOUNDER", + "CI_SIGNKICK", "CI_SIGNKICK_LEVEL", "CI_XOP", "CI_SUSPENDED", "CI_PERSIST", "" +}; + struct ModeLock { bool set; diff --git a/include/servers.h b/include/servers.h index d22ab05ac..c9d85804b 100644 --- a/include/servers.h +++ b/include/servers.h @@ -70,6 +70,8 @@ enum ServerFlag SERVER_JUPED }; +const Anope::string ServerFlagStrings[] = { "SERVER_NONE", "SERVER_SYNCING", "SERVER_JUPED", "" }; + /** Class representing a server */ class CoreExport Server : public Flags<ServerFlag> diff --git a/include/services.h b/include/services.h index 881bbbb76..69ed1a944 100644 --- a/include/services.h +++ b/include/services.h @@ -306,8 +306,11 @@ template<typename T, size_t Size = 32> class Flags { protected: std::bitset<Size> Flag_Values; + const Anope::string *Flag_Strings; public: + Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { } + /** Add a flag to this item * @param Value The flag */ @@ -347,6 +350,23 @@ template<typename T, size_t Size = 32> class Flags { Flag_Values.reset(); } + + std::vector<Anope::string> ToString() + { + std::vector<Anope::string> ret; + for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i) + if (this->HasFlag(static_cast<T>(i))) + ret.push_back(this->Flag_Strings[i]); + return ret; + } + + void FromString(const std::vector<Anope::string> &strings) + { + for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i) + for (unsigned j = 0; j < strings.size(); ++j) + if (this->Flag_Strings[i] == strings[j]) + this->SetFlag(static_cast<T>(i)); + } }; #include "sockets.h" @@ -470,17 +490,22 @@ enum MemoFlag { /* Memo is unread */ MF_UNREAD, - /* SEnder requests a receipt */ + /* Sender requests a receipt */ MF_RECEIPT, /* Memo is a notification of receipt */ MF_NOTIFYS }; +const Anope::string MemoFlagStrings[] = { + "MF_UNREAD", "MF_RECEIPT", "MF_NOTIFYS", "" +}; + /* Memo info structures. Since both nicknames and channels can have memos, * we encapsulate memo data in a MemoList to make it easier to handle. */ class Memo : public Flags<MemoFlag> { public: + Memo(); time_t time; /* When it was sent */ Anope::string sender; Anope::string text; @@ -592,10 +617,13 @@ enum AutoKickFlag AK_ISNICK }; +const Anope::string AutoKickFlagString[] = { "AK_ISNICK", "" }; + /* AutoKick data. */ class AutoKick : public Flags<AutoKickFlag> { public: + AutoKick() : Flags<AutoKickFlag>(AutoKickFlagString) { } /* Only one of these can be in use */ Anope::string mask; NickCore *nc; @@ -715,6 +743,12 @@ enum BotServFlag BS_END }; +const Anope::string BotServFlagStrings[] = { + "BS_BEGIN", "BS_DONTKICKOPS", "BS_DONTKICKVOICES", "BS_FANTASY", "BS_SYMBIOSIS", "BS_GREET", "BS_NOBOT", + "BS_KICK_BOLDs", "BS_KICK_COLORS", "BS_KICK_REVERSES", "BS_KICK_UNDERLINES", "BS_KICK_BADWORDS", "BS_KICK_CAPS", + "BS_KICK_FLOOD", "BS_KICK_REPEAT", "BS_KICK_ITALICS", "BS_MSG_PRIVMSG", "BS_MSG_NOTICE", "BS_MSG_NOTICEOPS", "" +}; + /* Indices for TTB (Times To Ban) */ enum { diff --git a/include/sockets.h b/include/sockets.h index 4d6938e09..6d48d1481 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -121,6 +121,8 @@ enum SocketFlag SF_WRITABLE }; +static const Anope::string SocketFlagStrings[] = { "SF_DEAD", "SF_WRITABLE", "" }; + class Socket; class ClientSocket; class ListenSocket; diff --git a/include/users.h b/include/users.h index 8eba0e476..d54fd13be 100644 --- a/include/users.h +++ b/include/users.h @@ -14,6 +14,7 @@ extern CoreExport patricia_tree<User *> UserListByUID; class CoreExport ChannelStatus : public Flags<ChannelModeName, CMODE_END * 2> { public: + ChannelStatus(); Anope::string BuildCharPrefixList() const; Anope::string BuildModePrefixList() const; }; |