[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,15 +19,15 @@
class BaseRaidMembersRepository {
public:
struct RaidMembers {
int raidid;
int charid;
int groupid;
int _class;
int level;
int32_t raidid;
int32_t charid;
uint32_t groupid;
int8_t _class;
int8_t level;
std::string name;
int isgroupleader;
int israidleader;
int islooter;
int8_t isgroupleader;
int8_t israidleader;
int8_t islooter;
};
static std::string PrimaryKey()
@@ -146,15 +146,15 @@ public:
if (results.RowCount() == 1) {
RaidMembers e{};
e.raidid = atoi(row[0]);
e.charid = atoi(row[1]);
e.groupid = atoi(row[2]);
e._class = atoi(row[3]);
e.level = atoi(row[4]);
e.raidid = static_cast<int32_t>(atoi(row[0]));
e.charid = static_cast<int32_t>(atoi(row[1]));
e.groupid = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e._class = static_cast<int8_t>(atoi(row[3]));
e.level = static_cast<int8_t>(atoi(row[4]));
e.name = row[5] ? row[5] : "";
e.isgroupleader = atoi(row[6]);
e.israidleader = atoi(row[7]);
e.islooter = atoi(row[8]);
e.isgroupleader = static_cast<int8_t>(atoi(row[6]));
e.israidleader = static_cast<int8_t>(atoi(row[7]));
e.islooter = static_cast<int8_t>(atoi(row[8]));
return e;
}
@@ -298,15 +298,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
RaidMembers e{};
e.raidid = atoi(row[0]);
e.charid = atoi(row[1]);
e.groupid = atoi(row[2]);
e._class = atoi(row[3]);
e.level = atoi(row[4]);
e.raidid = static_cast<int32_t>(atoi(row[0]));
e.charid = static_cast<int32_t>(atoi(row[1]));
e.groupid = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e._class = static_cast<int8_t>(atoi(row[3]));
e.level = static_cast<int8_t>(atoi(row[4]));
e.name = row[5] ? row[5] : "";
e.isgroupleader = atoi(row[6]);
e.israidleader = atoi(row[7]);
e.islooter = atoi(row[8]);
e.isgroupleader = static_cast<int8_t>(atoi(row[6]));
e.israidleader = static_cast<int8_t>(atoi(row[7]));
e.islooter = static_cast<int8_t>(atoi(row[8]));
all_entries.push_back(e);
}
@@ -331,15 +331,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) {
RaidMembers e{};
e.raidid = atoi(row[0]);
e.charid = atoi(row[1]);
e.groupid = atoi(row[2]);
e._class = atoi(row[3]);
e.level = atoi(row[4]);
e.raidid = static_cast<int32_t>(atoi(row[0]));
e.charid = static_cast<int32_t>(atoi(row[1]));
e.groupid = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e._class = static_cast<int8_t>(atoi(row[3]));
e.level = static_cast<int8_t>(atoi(row[4]));
e.name = row[5] ? row[5] : "";
e.isgroupleader = atoi(row[6]);
e.israidleader = atoi(row[7]);
e.islooter = atoi(row[8]);
e.isgroupleader = static_cast<int8_t>(atoi(row[6]));
e.israidleader = static_cast<int8_t>(atoi(row[7]));
e.islooter = static_cast<int8_t>(atoi(row[8]));
all_entries.push_back(e);
}