[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
+15 -15
View File
@@ -1047,7 +1047,7 @@ int ZoneDatabase::GetHighestGrid(uint32 zoneid) {
return 0;
auto row = results.begin();
return atoi(row[0]);
return Strings::ToInt(row[0]);
}
uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
@@ -1064,7 +1064,7 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) {
auto row = results.begin();
return atoi(row[0]);
return Strings::ToInt(row[0]);
}
bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) {
@@ -1084,11 +1084,11 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist*
auto row = results.begin();
wp->x = atof(row[0]);
wp->y = atof(row[1]);
wp->z = atof(row[2]);
wp->pause = atoi(row[3]);
wp->heading = atof(row[4]);
wp->x = Strings::ToFloat(row[0]);
wp->y = Strings::ToFloat(row[1]);
wp->z = Strings::ToFloat(row[2]);
wp->pause = Strings::ToInt(row[3]);
wp->heading = Strings::ToFloat(row[4]);
return true;
}
@@ -1229,7 +1229,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v
return 0;
auto row = results.begin();
grid_num = atoi(row[0]);
grid_num = Strings::ToInt(row[0]);
if (grid_num == 0)
{ // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn
@@ -1259,7 +1259,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v
row = results.begin();
if (row[0] != 0)
next_wp_num = atoi(row[0]) + 1;
next_wp_num = Strings::ToInt(row[0]) + 1;
else // No waypoints in this grid yet
next_wp_num = 1;
@@ -1283,7 +1283,7 @@ uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) {
return 0;
auto row = results.begin();
uint32 freeGridID = row[0] ? atoi(row[0]) + 1 : 1;
uint32 freeGridID = row[0] ? Strings::ToInt(row[0]) + 1 : 1;
return freeGridID;
}
@@ -1301,7 +1301,7 @@ int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) {
return 0;
auto row = results.begin();
return atoi(row[0]);
return Strings::ToInt(row[0]);
}
int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, int grid)
@@ -1326,10 +1326,10 @@ int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, in
row++;
i++;
}
loc.x = atof(row[0]);
loc.y = atof(row[1]);
loc.z = atof(row[2]);
loc.w = atof(row[3]);
loc.x = Strings::ToFloat(row[0]);
loc.y = Strings::ToFloat(row[1]);
loc.z = Strings::ToFloat(row[2]);
loc.w = Strings::ToFloat(row[3]);
return i;
}
return 0;