[Strings] Add more number formatters (#2873)

* [Strings] Add more number formatters

# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* [Strings] Add more number formatters

- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* Rebase cleanup

* Changes/benchmarks/tests

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Alex King
2023-03-04 18:01:19 -05:00
committed by GitHub
parent be567af70d
commit 2a6cf8c8e7
261 changed files with 3178 additions and 3012 deletions
+10 -9
View File
@@ -1,6 +1,7 @@
#include "door_manipulation.h"
#include "../doors.h"
#include "../../common/misc_functions.h"
#include "../../common/strings.h"
#define MAX_CLIENT_MESSAGE_LENGTH 2000
@@ -54,23 +55,23 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
float set_size = 0.0f;
if (arg2 == move_x_action) {
x_move = std::atof(arg3.c_str());
x_move = Strings::ToFloat(arg3.c_str());
}
if (arg2 == move_y_action) {
y_move = std::atof(arg3.c_str());
y_move = Strings::ToFloat(arg3.c_str());
}
if (arg2 == move_z_action) {
z_move = std::atof(arg3.c_str());
z_move = Strings::ToFloat(arg3.c_str());
}
if (arg2 == move_h_action) {
h_move = std::atof(arg3.c_str());
h_move = Strings::ToFloat(arg3.c_str());
}
if (arg2 == set_size_action) {
set_size = std::atof(arg3.c_str());
set_size = Strings::ToFloat(arg3.c_str());
}
door->SetLocation(
@@ -369,7 +370,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
if (arg1 == "opentype" && !arg2.empty() && Strings::IsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetOpenType(std::atoi(arg2.c_str()));
door->SetOpenType(Strings::ToInt(arg2.c_str()));
}
}
@@ -377,7 +378,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
if (arg1 == "setincline" && !arg2.empty() && Strings::IsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetIncline(std::atoi(arg2.c_str()));
door->SetIncline(Strings::ToInt(arg2.c_str()));
}
}
@@ -385,7 +386,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
if (arg1 == "setinvertstate" && !arg2.empty() && Strings::IsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetInvertState(std::atoi(arg2.c_str()));
door->SetInvertState(Strings::ToInt(arg2.c_str()));
}
}
@@ -402,7 +403,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
if (arg1 == "setinclineinc" && !arg2.empty() && Strings::IsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetIncline(door->GetIncline() + std::atoi(arg2.c_str()));
door->SetIncline(door->GetIncline() + Strings::ToInt(arg2.c_str()));
}
}