mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-13 15:33:59 +00:00
feat(Core/DBLayer): replace char const* to std::string_view (#10211)
* feat(Core/DBLayer): replace `char const*` to `std::string_view` * CString * 1 * chore(Core/Misc): code cleanup * cl * db fix * fmt style sql * to fmt * py * del old * 1 * 2 * 3 * 1 * 1
This commit is contained in:
@@ -52,7 +52,7 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
|
||||
|
||||
// Resize index table
|
||||
// database query *MUST* contain ORDER BY `index_field` DESC clause
|
||||
uint32 indexTableSize = std::max(records, (*result)[_sqlIndexPos].GetUInt32() + 1);
|
||||
uint32 indexTableSize = std::max(records, (*result)[_sqlIndexPos].Get<uint32>() + 1);
|
||||
if (indexTableSize > records)
|
||||
{
|
||||
char** tmpIdxTable = new char* [indexTableSize];
|
||||
@@ -70,7 +70,7 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 indexValue = fields[_sqlIndexPos].GetUInt32();
|
||||
uint32 indexValue = fields[_sqlIndexPos].Get<uint32>();
|
||||
char* dataValue = indexTable[indexValue];
|
||||
|
||||
// If exist in DBC file override from DB
|
||||
@@ -86,20 +86,20 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
|
||||
switch (*dbcFormat)
|
||||
{
|
||||
case FT_FLOAT:
|
||||
*reinterpret_cast<float*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetFloat();
|
||||
*reinterpret_cast<float*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].Get<float>();
|
||||
dataOffset += sizeof(float);
|
||||
break;
|
||||
case FT_IND:
|
||||
case FT_INT:
|
||||
*reinterpret_cast<uint32*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt32();
|
||||
*reinterpret_cast<uint32*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].Get<uint32>();
|
||||
dataOffset += sizeof(uint32);
|
||||
break;
|
||||
case FT_BYTE:
|
||||
*reinterpret_cast<uint8*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].GetUInt8();
|
||||
*reinterpret_cast<uint8*>(&dataValue[dataOffset]) = fields[sqlColumnNumber].Get<uint8>();
|
||||
dataOffset += sizeof(uint8);
|
||||
break;
|
||||
case FT_STRING:
|
||||
*reinterpret_cast<char**>(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].GetString());
|
||||
*reinterpret_cast<char**>(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].Get<std::string>());
|
||||
dataOffset += sizeof(char*);
|
||||
break;
|
||||
case FT_SORT:
|
||||
|
||||
@@ -59,10 +59,10 @@ void RealmList::LoadBuildInfo()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
RealmBuildInfo& build = _builds.emplace_back();
|
||||
build.MajorVersion = fields[0].GetUInt32();
|
||||
build.MinorVersion = fields[1].GetUInt32();
|
||||
build.BugfixVersion = fields[2].GetUInt32();
|
||||
std::string hotfixVersion = fields[3].GetString();
|
||||
build.MajorVersion = fields[0].Get<uint32>();
|
||||
build.MinorVersion = fields[1].Get<uint32>();
|
||||
build.BugfixVersion = fields[2].Get<uint32>();
|
||||
std::string hotfixVersion = fields[3].Get<std::string>();
|
||||
|
||||
if (hotfixVersion.length() < build.HotfixVersion.size())
|
||||
{
|
||||
@@ -73,15 +73,15 @@ void RealmList::LoadBuildInfo()
|
||||
std::fill(hotfixVersion.begin(), hotfixVersion.end(), '\0');
|
||||
}
|
||||
|
||||
build.Build = fields[4].GetUInt32();
|
||||
std::string windowsHash = fields[5].GetString();
|
||||
build.Build = fields[4].Get<uint32>();
|
||||
std::string windowsHash = fields[5].Get<std::string>();
|
||||
|
||||
if (windowsHash.length() == build.WindowsHash.size() * 2)
|
||||
{
|
||||
HexStrToByteArray(windowsHash, build.WindowsHash);
|
||||
}
|
||||
|
||||
std::string macHash = fields[6].GetString();
|
||||
std::string macHash = fields[6].Get<std::string>();
|
||||
|
||||
if (macHash.length() == build.MacHash.size() * 2)
|
||||
{
|
||||
@@ -154,12 +154,12 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
|
||||
try
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 realmId = fields[0].GetUInt32();
|
||||
std::string name = fields[1].GetString();
|
||||
std::string externalAddressString = fields[2].GetString();
|
||||
std::string localAddressString = fields[3].GetString();
|
||||
std::string localSubmaskString = fields[4].GetString();
|
||||
uint16 port = fields[5].GetUInt16();
|
||||
uint32 realmId = fields[0].Get<uint32>();
|
||||
std::string name = fields[1].Get<std::string>();
|
||||
std::string externalAddressString = fields[2].Get<std::string>();
|
||||
std::string localAddressString = fields[3].Get<std::string>();
|
||||
std::string localSubmaskString = fields[4].Get<std::string>();
|
||||
uint16 port = fields[5].Get<uint16>();
|
||||
|
||||
Optional<boost::asio::ip::tcp::endpoint> externalAddress = _resolver->Resolve(boost::asio::ip::tcp::v4(), externalAddressString, "");
|
||||
if (!externalAddress)
|
||||
@@ -182,7 +182,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8 icon = fields[6].GetUInt8();
|
||||
uint8 icon = fields[6].Get<uint8>();
|
||||
|
||||
if (icon == REALM_TYPE_FFA_PVP)
|
||||
{
|
||||
@@ -194,11 +194,11 @@ void RealmList::UpdateRealms(boost::system::error_code const& error)
|
||||
icon = REALM_TYPE_NORMAL;
|
||||
}
|
||||
|
||||
RealmFlags flag = RealmFlags(fields[7].GetUInt8());
|
||||
uint8 timezone = fields[8].GetUInt8();
|
||||
uint8 allowedSecurityLevel = fields[9].GetUInt8();
|
||||
float pop = fields[10].GetFloat();
|
||||
uint32 build = fields[11].GetUInt32();
|
||||
RealmFlags flag = RealmFlags(fields[7].Get<uint8>());
|
||||
uint8 timezone = fields[8].Get<uint8>();
|
||||
uint8 allowedSecurityLevel = fields[9].Get<uint8>();
|
||||
float pop = fields[10].Get<float>();
|
||||
uint32 build = fields[11].Get<uint32>();
|
||||
|
||||
RealmHandle id{ realmId };
|
||||
|
||||
|
||||
@@ -110,10 +110,10 @@ void SecretMgr::AttemptLoad(Secrets i, LogLevel errorLevel, std::unique_lock<std
|
||||
Optional<std::string> oldDigest;
|
||||
{
|
||||
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_SECRET_DIGEST);
|
||||
stmt->setUInt32(0, i);
|
||||
stmt->SetData(0, i);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
if (result)
|
||||
oldDigest = result->Fetch()->GetString();
|
||||
oldDigest = result->Fetch()->Get<std::string>();
|
||||
}
|
||||
|
||||
Optional<BigNumber> currentValue = GetHexFromConfig(info.configKey, info.bits);
|
||||
@@ -182,8 +182,8 @@ Optional<std::string> SecretMgr::AttemptTransition(Secrets i, Optional<BigNumber
|
||||
if (fields[1].IsNull())
|
||||
continue;
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::vector<uint8> totpSecret = fields[1].GetBinary();
|
||||
uint32 id = fields[0].Get<uint32>();
|
||||
std::vector<uint8> totpSecret = fields[1].Get<Binary>();
|
||||
|
||||
if (hadOldSecret)
|
||||
{
|
||||
@@ -199,8 +199,8 @@ Optional<std::string> SecretMgr::AttemptTransition(Secrets i, Optional<BigNumber
|
||||
Acore::Crypto::AEEncryptWithRandomIV<Acore::Crypto::AES>(totpSecret, newSecret->ToByteArray<Acore::Crypto::AES::KEY_SIZE_BYTES>());
|
||||
|
||||
auto* updateStmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET);
|
||||
updateStmt->setBinary(0, totpSecret);
|
||||
updateStmt->setUInt32(1, id);
|
||||
updateStmt->SetData(0, totpSecret);
|
||||
updateStmt->SetData(1, id);
|
||||
trans->Append(updateStmt);
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -213,7 +213,7 @@ Optional<std::string> SecretMgr::AttemptTransition(Secrets i, Optional<BigNumber
|
||||
if (hadOldSecret)
|
||||
{
|
||||
auto* deleteStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_SECRET_DIGEST);
|
||||
deleteStmt->setUInt32(0, i);
|
||||
deleteStmt->SetData(0, i);
|
||||
trans->Append(deleteStmt);
|
||||
}
|
||||
|
||||
@@ -226,8 +226,8 @@ Optional<std::string> SecretMgr::AttemptTransition(Secrets i, Optional<BigNumber
|
||||
return std::string("Failed to hash new secret");
|
||||
|
||||
auto* insertStmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_SECRET_DIGEST);
|
||||
insertStmt->setUInt32(0, i);
|
||||
insertStmt->setString(1, *hash);
|
||||
insertStmt->SetData(0, i);
|
||||
insertStmt->SetData(1, *hash);
|
||||
trans->Append(insertStmt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user