DragonNest/Server/ServerCommon/DNConfig_Work.h
2024-12-20 16:56:44 +08:00

52 lines
No EOL
2.1 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
class ConfigWork
{
public:
void AddCommand(std::wstring& command)
{
std::transform(command.begin(), command.end(), command.begin(), tolower);
m_Commands.insert(command);
}
void AddCommand(wchar_t* command)
{
AddCommand(std::wstring(command));
}
void RemoveCommand(std::wstring& command)
{
std::transform(command.begin(), command.end(), command.begin(), tolower);
std::set<std::wstring>::iterator it = m_Commands.find(command);
if (it == m_Commands.end())
return;
m_Commands.erase(it);
}
void RemoveCommand(wchar_t* command)
{
RemoveCommand(std::wstring(command));
}
void ClearCommand()
{
m_Commands.clear();
}
bool HasCommand(std::wstring& command) const
{
std::transform(command.begin(), command.end(), command.begin(), tolower);
return (m_Commands.find(command) != m_Commands.end()) ? true : false;
}
bool HasCommand(wchar_t* command) const
{
return HasCommand(std::wstring(command));
}
private:
std::set<std::wstring> m_Commands;
};
extern ConfigWork g_ConfigWork;