I want to count the number of structs/classes declarations (not forward declarations) for documentation purposes. I always did this manually but now I have >70 classes, So I'm thinking about using regex.
Possible declarations are
class Foo
{
//...
}
class Foo : public Bar
{
}
template<typename T>
class Foo<T> : public Bar<T>
{
}
class MACRO Foo : public Bar
{
}
class MACRO Foo final : public Bar
{
}
But these should not match
class Foo;
void Func(class Foo* foo, class Bar* bar)
{
}
So far I have this
(?:class|struct) .+\n{
But it matches for
void Func(class Foo* foo, class Bar* bar)
{
}
I think If I could somehow tell this regex to not match ) in .+ it would work for all my cases.
(?:class|struct) .+\n{
Edit:
This helped with my problem, it does not include or exclude all possible cases but works with my current coding style.
(?:^[^\S\r\n]*struct|class) .+\n\s*{