vector<string> getMatchedDevice(string strDesc)
{
int pos = strDesc.find("?");
int pos1 = strDesc.find("*");
if (pos != string::npos)//find ?
{
strDesc.replace(pos,1,".");
}
if (pos1 != string::npos)// find *
{
strDesc.replace(pos1,2,".*");
}
vector<string> devDescVec;
Array<DeviceTreeNode>* pAllDev = DeviceCtrl::getInstalledDevices();
if (pAllDev == NULL)
{
return devDescVec;
}
int nCount = pAllDev->getCount();
for (int i = 0;i < nCount;++i)
{
DeviceTreeNode &devTreeNode = pAllDev->getItem(i);
wchar_t *pDevDes = devTreeNode.Description;
char buffer[256] = {0};
//sprintf(buffer,"%ws",pDevDes);
sprintf(buffer,"%S",pDevDes);
bool b = std::regex_match(buffer, std::regex(strDesc,ECMAScript | icase));//不区分大小写,需包含头文件#include <regex>,using namespace regex_constants;//ECMAScript | icase //Case insensitive
if (b)
{
devDescVec.push_back(buffer);
}
}
return devDescVec;
}