Skip to content

Commit

Permalink
refactor: remove noexcept
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Mar 8, 2024
1 parent 1ea6e9d commit 1d60496
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
18 changes: 9 additions & 9 deletions include/endstone/command/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace endstone {
class Command {
public:
explicit Command(std::string name, std::string description = "", std::vector<std::string> usages = {},
const std::vector<std::string> &aliases = {}) noexcept
const std::vector<std::string> &aliases = {})
{
setName(std::move(name));
setDescription(std::move(description));
Expand Down Expand Up @@ -68,7 +68,7 @@ class Command {
* @param name New command name
* @return returns true if the name is changed, false otherwise
*/
bool setName(std::string name) noexcept
bool setName(std::string name)
{
if (!isRegistered()) {
std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::tolower(c); });
Expand All @@ -95,7 +95,7 @@ class Command {
* @param description new command description
* @return this command object, for chaining
*/
Command &setDescription(std::string description) noexcept
Command &setDescription(std::string description)
{
if (!isRegistered()) {
description_ = std::move(description);
Expand All @@ -121,7 +121,7 @@ class Command {
* @return this command object, for chaining
*/
template <typename... Alias>
Command &setAliases(Alias... aliases) noexcept
Command &setAliases(Alias... aliases)
{
std::vector<std::string> all_aliases = {aliases...};
if (!isRegistered()) {
Expand Down Expand Up @@ -152,7 +152,7 @@ class Command {
* @return this command object, for chaining
*/
template <typename... Usage>
Command &setUsages(Usage... usages) noexcept
Command &setUsages(Usage... usages)
{
std::vector<std::string> all_usages = {usages...};
if (!isRegistered()) {
Expand All @@ -170,7 +170,7 @@ class Command {
* @param command_map the CommandMap to register to
* @return true if the registration was successful, false otherwise
*/
bool registerTo(CommandMap &command_map) noexcept
bool registerTo(CommandMap &command_map)
{
if (allowChangesFrom(command_map)) {
command_map_ = &command_map;
Expand All @@ -186,7 +186,7 @@ class Command {
* @param command_map the CommandMap to unregister from
* @return true if the unregistration was successful, false otherwise
*/
bool unregisterFrom(CommandMap &command_map) noexcept
bool unregisterFrom(CommandMap &command_map)
{
if (allowChangesFrom(command_map)) {
command_map_ = nullptr;
Expand All @@ -201,13 +201,13 @@ class Command {
*
* @return true if this command is currently registered false otherwise
*/
[[nodiscard]] bool isRegistered() const noexcept
[[nodiscard]] bool isRegistered() const
{
return command_map_ != nullptr;
}

private:
bool allowChangesFrom(CommandMap &command_map) noexcept
bool allowChangesFrom(CommandMap &command_map)
{
return (!isRegistered() || command_map_ == &command_map);
}
Expand Down
3 changes: 1 addition & 2 deletions include/endstone/command/command_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class CommandExecutor {
* @param args Passed command arguments
* @return true if the execution is successful, otherwise false
*/
virtual bool onCommand(const CommandSender &sender, const Command &command,
const std::vector<std::string> &args)
virtual bool onCommand(const CommandSender &sender, const Command &command, const std::vector<std::string> &args)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion include/endstone/detail/command/command_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class CommandAdapter : public ::Command {
};

bool customParseRule(CommandRegistry *, void *, const CommandRegistry::ParseToken &, const CommandOrigin &, int,
std::string &, std::vector<std::string> &);
std::string &, std::vector<std::string> &);

} // namespace endstone::detail
2 changes: 1 addition & 1 deletion include/endstone/detail/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EndstoneServer : public Server {
~EndstoneServer() override = default;

[[nodiscard]] Logger &getLogger() const override;
[[nodiscard]] EndstoneCommandMap &getCommandMap() const noexcept;
[[nodiscard]] EndstoneCommandMap &getCommandMap() const;
[[nodiscard]] MinecraftCommands &getMinecraftCommands();
[[nodiscard]] PluginManager &getPluginManager() const override;
[[nodiscard]] PluginCommand *getPluginCommand(std::string name) const override;
Expand Down
2 changes: 1 addition & 1 deletion src/endstone_core/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Logger &EndstoneServer::getLogger() const
return logger_;
}

EndstoneCommandMap &EndstoneServer::getCommandMap() const noexcept
EndstoneCommandMap &EndstoneServer::getCommandMap() const
{
return *command_map_;
}
Expand Down

0 comments on commit 1d60496

Please sign in to comment.