This question already has an answer here:
I want to parse the classes from a string, but for some reason the regex method I'm using is not working. Is there something in my regex expression that I don't understand?
I've tried using regex_search("class[^;]+\{").
My Code:
//Use regex matching to find start locations of classes
regex rClass("class[^;]+\\{");
smatch matchClass;
regex_search(wholeFile, matchClass, rClass);
for(int i=0; i<matchClass.size(); i++){
wholeFile string:
#ifndef SIMPLE_H_
#define SIMPLE_H_
class Simple
{
public:
Simple();
struct thing{
int thingy2;
};
virtual unsigned int* TestMe(int& ptr, int hi) const;
const DepthMap_C& GetDepthMap();
frameset wait_for_frames(unsigned int timeout_ms = 5000) const{
rs2_error* e = nullptr;
frame f(rs2_pipeline_wait_for_frames(_pipeline.get(), timeout_ms, &e));
error::handle(e);
return frameset(f);
}
private:
thingy thing;
};
class SimpleA
{
public:
Simple();
int foo(int x, double z)
const DepthMap_C& GetDepthMap();
private:
};
class SimpleB
{
public:
Simple();
const DepthMap_C& GetDepthMap();
private:
purple person;
peopleeater a;
};
#endif
I expect matchClass.size() to return 3, but I only get 1...
Aucun commentaire:
Enregistrer un commentaire