本文整理汇总了C++中QueryResult::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::c_str方法的具体用法?C++ QueryResult::c_str怎么用?C++ QueryResult::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::c_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadWardenDataResult
void CWardenDataStorage::LoadWardenDataResult()
{
// Check if Warden is enabled by config before loading anything
if (!sWorld.getConfig(CONFIG_BOOL_ANTICHEAT_WARDEN))
{
sLog.outString(">> Warden disabled, loading checks skipped.");
sLog.outString();
return;
}
QueryResult *result = LoginDatabase.Query("SELECT `check`, `data`, `result`, `address`, `length`, `str` FROM warden_data_result");
uint32 count = 0;
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
return;
}
BarGoLink bar((int)result->GetRowCount());
do
{
++count;
bar.step();
Field *fields = result->Fetch();
uint8 type = fields[0].GetUInt8();
uint32 id = GenerateInternalDataID();
WardenData *wd = new WardenData();
wd->Type = type;
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == DRIVER_CHECK)
{
std::string data = fields[1].GetCppString();
wd->i.SetHexStr(data.c_str());
int len = data.size() / 2;
if (wd->i.GetNumBytes() < len)
{
uint8 temp[24];
memset(temp, 0, len);
memcpy(temp, wd->i.AsByteArray(), wd->i.GetNumBytes());
std::reverse(temp, temp + len);
wd->i.SetBinary((uint8*)temp, len);
}
}
if (type == MEM_CHECK || type == MODULE_CHECK)
MemCheckIds.push_back(id);
if (type == MEM_CHECK || type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == PROC_CHECK)
{
wd->Address = fields[3].GetUInt32();
wd->Length = fields[4].GetUInt8();
}
// PROC_CHECK support missing
if (type == MEM_CHECK || type == MPQ_CHECK || type == LUA_STR_CHECK || type == DRIVER_CHECK || type == MODULE_CHECK)
wd->str = fields[5].GetCppString();
_data_map[id] = wd;
if (type == MPQ_CHECK || type == MEM_CHECK)
{
std::string result = fields[2].GetCppString();
WardenDataResult *wr = new WardenDataResult();
wr->res.SetHexStr(result.c_str());
int len = result.size() / 2;
if (wr->res.GetNumBytes() < len)
{
uint8 *temp = new uint8[len];
memset(temp, 0, len);
memcpy(temp, wr->res.AsByteArray(), wr->res.GetNumBytes());
std::reverse(temp, temp + len);
wr->res.SetBinary((uint8*)temp, len);
delete [] temp;
}
_result_map[id] = wr;
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
}
示例2: LoadWardenDataResult
void CWardenDataStorage::LoadWardenDataResult()
{
QueryResult result = LoginDatabase.Query("SELECT `check`, `data`, `result`, `address`, `length`, `str` FROM warden_data_result");
uint32 count = 0;
if (!result)
{
sLog->outString();
sLog->outString(">> Loaded %u warden data and results", count);
return;
}
do
{
++count;
Field *fields = result->Fetch();
uint8 type = fields[0].GetUInt8();
uint32 id = GenerateInternalDataID();
WardenData *wd = new WardenData();
wd->Type = type;
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == DRIVER_CHECK)
{
std::string data = fields[1].GetString();
wd->i.SetHexStr(data.c_str());
int len = data.size() / 2;
if (wd->i.GetNumBytes() < len)
{
uint8 temp[24];
memset(temp, 0, len);
memcpy(temp, wd->i.AsByteArray(), wd->i.GetNumBytes());
std::reverse(temp, temp + len);
wd->i.SetBinary((uint8*)temp, len);
}
}
if (type == MEM_CHECK || type == MODULE_CHECK)
MemCheckIds.push_back(id);
if (type == MEM_CHECK || type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == PROC_CHECK)
{
wd->Address = fields[3].GetUInt32();
wd->Length = fields[4].GetUInt8();
}
// PROC_CHECK support missing
if (type == MEM_CHECK || type == MPQ_CHECK || type == LUA_STR_CHECK || type == DRIVER_CHECK || type == MODULE_CHECK)
wd->str = fields[5].GetString();
_data_map[id] = wd;
if (type == MPQ_CHECK || type == MEM_CHECK)
{
std::string result = fields[2].GetString();
WardenDataResult *wr = new WardenDataResult();
wr->res.SetHexStr(result.c_str());
int len = result.size() / 2;
if (wr->res.GetNumBytes() < len)
{
uint8 *temp = new uint8[len];
memset(temp, 0, len);
memcpy(temp, wr->res.AsByteArray(), wr->res.GetNumBytes());
std::reverse(temp, temp + len);
wr->res.SetBinary((uint8*)temp, len);
delete [] temp;
}
_result_map[id] = wr;
}
} while (result->NextRow());
sLog->outString();
sLog->outString(">> Loaded %u warden data and results", count);
}