[Repositories] Add more precise types to repository generator (#2391)

* Make utils/scripts/generators/repository-generator.pl aware of more
datatypes

This adds support for unsigned and more integer types. It also avoids
using parsing functions that require casting (still needed in some
cases)

Having the data types in the Repository structs better map to the types
in the database will allow us to avoid casting when we pull data out of
them. And as a benefit, assume something is wrong if we do :)

Hopefully clean up some warnings due to casting too.

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Michael Cook (mackal)
2022-08-31 01:04:27 -04:00
committed by GitHub
parent fcf01f6d87
commit 6f7fa98996
183 changed files with 7849 additions and 7818 deletions
@@ -19,22 +19,22 @@
class BasePetitionsRepository {
public:
struct Petitions {
int dib;
int petid;
uint32_t dib;
uint32_t petid;
std::string charname;
std::string accountname;
std::string lastgm;
std::string petitiontext;
std::string gmtext;
std::string zone;
int urgency;
int charclass;
int charrace;
int charlevel;
int checkouts;
int unavailables;
int ischeckedout;
int64 senttime;
int32_t urgency;
int32_t charclass;
int32_t charrace;
int32_t charlevel;
int32_t checkouts;
int32_t unavailables;
int8_t ischeckedout;
int64_t senttime;
};
static std::string PrimaryKey()
@@ -174,21 +174,21 @@ public:
if (results.RowCount() == 1) {
Petitions e{};
e.dib = atoi(row[0]);
e.petid = atoi(row[1]);
e.dib = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.petid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.charname = row[2] ? row[2] : "";
e.accountname = row[3] ? row[3] : "";
e.lastgm = row[4] ? row[4] : "";
e.petitiontext = row[5] ? row[5] : "";
e.gmtext = row[6] ? row[6] : "";
e.zone = row[7] ? row[7] : "";
e.urgency = atoi(row[8]);
e.charclass = atoi(row[9]);
e.charrace = atoi(row[10]);
e.charlevel = atoi(row[11]);
e.checkouts = atoi(row[12]);
e.unavailables = atoi(row[13]);
e.ischeckedout = atoi(row[14]);
e.urgency = static_cast<int32_t>(atoi(row[8]));
e.charclass = static_cast<int32_t>(atoi(row[9]));
e.charrace = static_cast<int32_t>(atoi(row[10]));
e.charlevel = static_cast<int32_t>(atoi(row[11]));
e.checkouts = static_cast<int32_t>(atoi(row[12]));
e.unavailables = static_cast<int32_t>(atoi(row[13]));
e.ischeckedout = static_cast<int8_t>(atoi(row[14]));
e.senttime = strtoll(row[15], nullptr, 10);
return e;
@@ -353,21 +353,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Petitions e{};
e.dib = atoi(row[0]);
e.petid = atoi(row[1]);
e.dib = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.petid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.charname = row[2] ? row[2] : "";
e.accountname = row[3] ? row[3] : "";
e.lastgm = row[4] ? row[4] : "";
e.petitiontext = row[5] ? row[5] : "";
e.gmtext = row[6] ? row[6] : "";
e.zone = row[7] ? row[7] : "";
e.urgency = atoi(row[8]);
e.charclass = atoi(row[9]);
e.charrace = atoi(row[10]);
e.charlevel = atoi(row[11]);
e.checkouts = atoi(row[12]);
e.unavailables = atoi(row[13]);
e.ischeckedout = atoi(row[14]);
e.urgency = static_cast<int32_t>(atoi(row[8]));
e.charclass = static_cast<int32_t>(atoi(row[9]));
e.charrace = static_cast<int32_t>(atoi(row[10]));
e.charlevel = static_cast<int32_t>(atoi(row[11]));
e.checkouts = static_cast<int32_t>(atoi(row[12]));
e.unavailables = static_cast<int32_t>(atoi(row[13]));
e.ischeckedout = static_cast<int8_t>(atoi(row[14]));
e.senttime = strtoll(row[15], nullptr, 10);
all_entries.push_back(e);
@@ -393,21 +393,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
Petitions e{};
e.dib = atoi(row[0]);
e.petid = atoi(row[1]);
e.dib = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.petid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.charname = row[2] ? row[2] : "";
e.accountname = row[3] ? row[3] : "";
e.lastgm = row[4] ? row[4] : "";
e.petitiontext = row[5] ? row[5] : "";
e.gmtext = row[6] ? row[6] : "";
e.zone = row[7] ? row[7] : "";
e.urgency = atoi(row[8]);
e.charclass = atoi(row[9]);
e.charrace = atoi(row[10]);
e.charlevel = atoi(row[11]);
e.checkouts = atoi(row[12]);
e.unavailables = atoi(row[13]);
e.ischeckedout = atoi(row[14]);
e.urgency = static_cast<int32_t>(atoi(row[8]));
e.charclass = static_cast<int32_t>(atoi(row[9]));
e.charrace = static_cast<int32_t>(atoi(row[10]));
e.charlevel = static_cast<int32_t>(atoi(row[11]));
e.checkouts = static_cast<int32_t>(atoi(row[12]));
e.unavailables = static_cast<int32_t>(atoi(row[13]));
e.ischeckedout = static_cast<int8_t>(atoi(row[14]));
e.senttime = strtoll(row[15], nullptr, 10);
all_entries.push_back(e);