当前位置: 首页>>代码示例>>C++>>正文


C++ regex::what方法代码示例

本文整理汇总了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;
}
开发者ID:ProjectHax,项目名称:OpcodeFinder,代码行数:61,代码来源:opcodefinder.cpp


注:本文中的boost::regex::what方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。