Class that makes cppcheck dump data available Contains a list of Configuration instances Attributes: filename Path to Cppcheck dump file rawTokens List of rawToken elements suppressions List of Suppressions files Source
| 1181 | |
| 1182 | |
| 1183 | class CppcheckData: |
| 1184 | """ |
| 1185 | Class that makes cppcheck dump data available |
| 1186 | Contains a list of Configuration instances |
| 1187 | |
| 1188 | Attributes: |
| 1189 | filename Path to Cppcheck dump file |
| 1190 | rawTokens List of rawToken elements |
| 1191 | suppressions List of Suppressions |
| 1192 | files Source files for elements occurred in this configuration |
| 1193 | |
| 1194 | To iterate through all configurations use such code: |
| 1195 | @code |
| 1196 | data = cppcheckdata.parsedump(...) |
| 1197 | for cfg in data.configurations: |
| 1198 | print('cfg: ' + cfg.name) |
| 1199 | @endcode |
| 1200 | |
| 1201 | To iterate through all tokens in each configuration use such code: |
| 1202 | @code |
| 1203 | data = cppcheckdata.parsedump(...) |
| 1204 | for cfg in data.configurations: |
| 1205 | print('cfg: ' + cfg.name) |
| 1206 | code = '' |
| 1207 | for token in cfg.tokenlist: |
| 1208 | code = code + token.str + ' ' |
| 1209 | print(' ' + code) |
| 1210 | @endcode |
| 1211 | |
| 1212 | To iterate through all scopes (functions, types, etc) use such code: |
| 1213 | @code |
| 1214 | data = cppcheckdata.parsedump(...) |
| 1215 | for cfg in data.configurations: |
| 1216 | print('cfg: ' + cfg.name) |
| 1217 | for scope in cfg.scopes: |
| 1218 | print(' type:' + scope.type + ' name:' + scope.className) |
| 1219 | @endcode |
| 1220 | """ |
| 1221 | |
| 1222 | def __init__(self, filename): |
| 1223 | """ |
| 1224 | :param filename: Path to Cppcheck dump file |
| 1225 | """ |
| 1226 | self.language = None |
| 1227 | self.filename = filename |
| 1228 | self.rawTokens = [] |
| 1229 | self.platform = None |
| 1230 | self.suppressions = [] |
| 1231 | self.files = [] # source files for elements occurred in this configuration |
| 1232 | |
| 1233 | platform_done = False |
| 1234 | rawtokens_done = False |
| 1235 | suppressions_done = False |
| 1236 | |
| 1237 | # Parse general configuration options from <dumps> node |
| 1238 | # We intentionally don't clean node resources here because we |
| 1239 | # want to serialize in memory only small part of the XML tree. |
| 1240 | for event, node in ElementTree.iterparse(self.filename, events=('start', 'end')): |