本文整理汇总了C++中boost::regex::what方法的典型用法代码示例。如果您正苦于以下问题:C++ regex::what方法的具体用法?C++ regex::what怎么用?C++ regex::what使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::regex
的用法示例。
在下文中一共展示了regex::what方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExtractOpcodes
//Extracts opcodes out of the client
QStringList OpcodeFinder::ExtractOpcodes(QString path)
{
QStringList opcodes;
QFile file(path);
//Open the file
if(file.open(QIODevice::ReadOnly))
{
//Read the file data and convert it to hex
std::string data = QString(file.readAll().toHex()).toUpper().toAscii().data();
file.close();
if(data.empty())
{
//No data read
QMessageBox::critical(this, "Error", "No data was read from the client.");
}
else
{
//Regex string for locating opcodes
const static boost::regex e("C744240C(?<opcode>....)0000C7442410........E8........8D|8D..24108D..2418....8BCEC7442418(?<opcode>....)0000C744241C........E8|8B4E10C7442410(?<opcode>....)000041C74424..........518BCEE8");
boost::match_results<std::string::const_iterator> what;
boost::match_flag_type flags = boost::match_default;
std::string::const_iterator start = data.begin();
std::string::const_iterator end = data.end();
try
{
//Search
while(boost::regex_search(start, end, what, e, flags))
{
//Get the opcode
std::string temp = what["opcode"];
//Add it to the list
opcodes.append((temp.substr(2, 2) + temp.substr(0, 2)).c_str());
//Next
start = what[0].second;
flags |= boost::match_prev_avail;
flags |= boost::match_not_bob;
}
}
catch(std::exception & e)
{
//Display error message (regular expression is probably outdated for this client)
QMessageBox::critical(this, "Error", e.what());
}
}
}
else
{
//File open error
QMessageBox::critical(this, "Error", QString("Unable to open %0 for reading. Could not extract opcodes.").arg(path));
}
return opcodes;
}