Programa para el testeo de las funciones.Para compilar o código example_ra_match.cpp:
g++ -static -o example_ra_match example_ra_match.cpp -lpdsramm
Para executar o programa:
Retornando por consola:
Found "a*f" in : "abcdef"
Not found "a*f" in : "abcdee"
Found "[a-z]xx" in : "qxx"
Not found "[a-z]xx" in : "dqxx"
Found "a??" in : "abc"
Not found "a??" in : "abcd"
Código example_ra_match.cpp:
#include <Pds/Ra>
int main(void)
{
int id;
std::string str;
std::string pat;
std::cout<<std::endl;
str="abcdef";
pat="a*f";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
std::cout<<std::endl;
str="abcdee";
pat="a*f";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
std::cout<<std::endl;
str="qxx";
pat="[a-z]xx";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
std::cout<<std::endl;
str="dqxx";
pat="[a-z]xx";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
std::cout<<std::endl;
str="abc";
pat="a??";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
std::cout<<std::endl;
str= "abcd";
pat="a??";
if(id==0) std::cout<<" Found \""<<pat<<"\" in : \""<<str<<"\"\n";
else std::cout<<"Not found \""<<pat<<"\" in : \""<<str<<"\"\n";
return 0;
}
int FnMatch(const std::string &pattern, const std::string &string, int flags)
función similar a fnmatch(), creada para tener compatibilidad en MinGw (code From FreeBSD fnmatch....
const unsigned int FNM_CASEFOLD