for oneMethod in cppHeader.classes['SampleClass']['methods']['public']: for kv in oneMethod.items(): print(kv[0], " : ", kv[1]) print('---------------------\n')
for oneMethod in cppHeader.classes['SampleClass']['methods']['public']: print('name: ', oneMethod['name']) print('rtnType: ', oneMethod['rtnType']) print('parameters: ', end='') iflen(oneMethod['parameters']): for oneParam in oneMethod['parameters']: print(oneParam['name'], oneParam['type'], end='; ') print('\n')
获取类里的public变量
1 2 3 4 5
for oneProperty in cppHeader.classes['AlphaClass']['properties']['public']: print('name: ', oneProperty['name']) print('type: ', oneProperty['type']) # for kv in oneProperty.items(): # print(kv[0], " : ", kv[1])
这里只挑了2个比较重要的属性name和type
获取类里的private方法
1 2 3 4 5
for oneMethod in cppHeader.classes['SampleClass']['methods']['private']: for kv in oneMethod.items(): print(kv[0], " : ", kv[1]) print('---------------------\n')
获取类里的private变量
1 2 3 4 5
for oneProperty in cppHeader.classes['SampleClass']['properties']['private']: print('name: ', oneProperty['name']) print('type: ', oneProperty['type']) # for kv in oneProperty.items(): # print(kv[0], " : ", kv[1])
获取头文件里定义的函数(类外定义的函数)
1 2 3 4 5
for func in cppHeader.functions: print('name: {}'.format(func['name'])) print('rtnType: {}'.format(func['rtnType'])) print('parameters: {}'.format(func['parameters'])) print('\n')
获取头文件里定义的宏定义
1 2
for define in cppHeader.defines: print(define) # 类型是str
获取头文件里定义的enum
1 2
for oneEnum in cppHeader.enums: print(oneEnum)
获取类里定义的enum
1 2 3
for oneEnum in cppHeader.classes['SampleClass']['enums']['public']: print(oneEnum) # 注意,这个enum是定义在SampleClass的public区