user391986
user391986

Reputation: 30936

C++/QtTestLib programatically get number of functions in class

Within my C++/QtTestLib Class, how can I get a count of the number of private functions in this class so that I can output it at runtime?

Upvotes: 1

Views: 170

Answers (2)

teukkam
teukkam

Reputation: 4327

Something like this? (Not tested)

QObject obj ();
QMetaObject metaobject = obj.MetaObject();
int num_methods = metaobject.methodCount();
int private_methods = 0;
for (int i=0; i<num_methods; i++) {
  if (metaobject.method(i).access() == QMetaMethod::Private)
     private_methods++;
}

where instead of just QObject you have the class that you need to examine.

Upvotes: 1

noisy
noisy

Reputation: 6823

ASAIK in C++ this is not possible without third-party parser.

Upvotes: 0

Related Questions