J'essaye de chercher un char * pour trouver des correspondances et stocker chaque match comme une structure en utilisant boost regex. Je ne sais pas comment utiliser les itérateurs std :: string sur char *. J'ai donc créé std :: string à partir de char * et en les utilisant. Mais maintenant je veux des pointeurs dans le char original * qui ne peut être trouvé qu'en utilisant std :: string que j'ai créé. Voir le code suivant. Les commentaires devraient effacer vos doutes.en utilisant des itérateurs de chaînes sur char * dans boost regex
typedef struct {
void *pFind; // Pointer to begining of match
int lenFind; // Length of match
} IppRegExpFind;
bool regExSearch(int nStrLen /*Length of input string*/,
std::vector<IppRegExpFind>& vectResult /*vector of struct to store matches*/,
int &numMatches /* number of matches*/,
const char *sStrInput /*Input string to be searched*/,
const char *sStrRegex /*Input regex string*/)
{
bool bStatusOk = true;
try{
std::string regexStr(sStrRegex);
std::string inputStr(sStrInput);
static const boost::regex ex(regexStr);
std::string::const_iterator start, end;
start = inputStr.begin();
end = inputStr.end();
boost::match_results<std::string::const_iterator> what;
boost::match_flag_type flags = boost::match_default;
std::vector <std::string> matches;
while(boost::regex_search(start, end, what, ex, flags))
{
matches.push_back(what.str());
start = what[0].second;
}
// convert boost:match_Results to a vector of IppRegExpFind
}
catch(...){
bStatusOk = false;
}
return bStatusOk;
}