//Функция
ifstream file( filename) ;
string str;
smatch result;
regex rx ( "class\s+([^\s:]*)\s*:\s*(?:virtual)?\s+(?:public\s+|private\s+|protected\s+)?([^\s,]*)(?:\s*,\s*(?:virtual)?\s+(?:public\s+|private\s+|protected\s+)?([^\s,]*))*" ) ;
while ( ! file.eof ( ) ) {
getline( file, str) ;
cout << str << endl << endl;
while ( regex_search( str, result, rx) ) {
for ( auto x : result) std:: cout << x << " " ;
std:: cout << std:: endl ;
str = result.suffix ( ) .str ( ) ;
}
}
//.txt
class Parent: { } ;
class Child: virtual public Parent { } ;
class Child2: virtual public Parent { } ;
class Child3: virtual public Child, virtual public Child2 { } ;
class Child4: virtual public Child, virtual public Child6 { } ;
class Child5: virtual public Child { } ;
class Child6: virtual public Parent, virtual public Child3 { } ;
class Child7: virtual public Child3, virtual public Child { } ;
Ly/QpNGD0L3QutGG0LjRjwoJaWZzdHJlYW0gZmlsZShmaWxlbmFtZSk7CgoJc3RyaW5nIHN0cjsKCXNtYXRjaCByZXN1bHQ7CglyZWdleCByeCAoImNsYXNzXHMrKFteXHM6XSopXHMqOlxzKig/OnZpcnR1YWwpP1xzKyg/OnB1YmxpY1xzK3xwcml2YXRlXHMrfHByb3RlY3RlZFxzKyk/KFteXHMsXSopKD86XHMqLFxzKig/OnZpcnR1YWwpP1xzKyg/OnB1YmxpY1xzK3xwcml2YXRlXHMrfHByb3RlY3RlZFxzKyk/KFteXHMsXSopKSoiKTsKCQoJd2hpbGUgKCFmaWxlLmVvZigpKSB7CgkJZ2V0bGluZShmaWxlLCBzdHIpOwoJCWNvdXQgPDwgc3RyIDw8IGVuZGwgPDwgZW5kbDsKCQl3aGlsZSAocmVnZXhfc2VhcmNoKHN0ciwgcmVzdWx0LCByeCkpIHsKCQkJZm9yIChhdXRvIHggOiByZXN1bHQpIHN0ZDo6Y291dCA8PCB4IDw8ICIgIjsKCQkJc3RkOjpjb3V0IDw8IHN0ZDo6ZW5kbDsKCQkJc3RyID0gcmVzdWx0LnN1ZmZpeCgpLnN0cigpOwoJCX0KCX0KCgoKLy8udHh0CmNsYXNzIFBhcmVudDoge307CmNsYXNzIENoaWxkOiB2aXJ0dWFsIHB1YmxpYyBQYXJlbnQge307CmNsYXNzIENoaWxkMjogdmlydHVhbCBwdWJsaWMgUGFyZW50IHt9OwpjbGFzcyBDaGlsZDM6IHZpcnR1YWwgcHVibGljIENoaWxkLCB2aXJ0dWFsIHB1YmxpYyBDaGlsZDIge307CmNsYXNzIENoaWxkNDogdmlydHVhbCBwdWJsaWMgQ2hpbGQsIHZpcnR1YWwgcHVibGljIENoaWxkNiB7fTsKY2xhc3MgQ2hpbGQ1OiB2aXJ0dWFsIHB1YmxpYyBDaGlsZCB7fTsKY2xhc3MgQ2hpbGQ2OiB2aXJ0dWFsIHB1YmxpYyBQYXJlbnQsIHZpcnR1YWwgcHVibGljIENoaWxkMyB7fTsKY2xhc3MgQ2hpbGQ3OiB2aXJ0dWFsIHB1YmxpYyBDaGlsZDMsIHZpcnR1YWwgcHVibGljIENoaWxkIHt9Ow==
compilation info
prog.cpp:2:2: error: 'ifstream' does not name a type
ifstream file(filename);
^
prog.cpp:4:2: error: 'string' does not name a type
string str;
^
prog.cpp:5:2: error: 'smatch' does not name a type
smatch result;
^
prog.cpp:6:2: error: 'regex' does not name a type
regex rx ("class\s+([^\s:]*)\s*:\s*(?:virtual)?\s+(?:public\s+|private\s+|protected\s+)?([^\s,]*)(?:\s*,\s*(?:virtual)?\s+(?:public\s+|private\s+|protected\s+)?([^\s,]*))*");
^
prog.cpp:8:2: error: expected unqualified-id before 'while'
while (!file.eof()) {
^
stdout