Directive class. Contains information about each preprocessor directive in the source code. Attributes: str The directive line, with all C or C++ comments removed file Name of (possibly included) file where directive is defined linenr Line number in (poss
| 60 | |
| 61 | |
| 62 | class Directive: |
| 63 | """ |
| 64 | Directive class. Contains information about each preprocessor directive in the source code. |
| 65 | |
| 66 | Attributes: |
| 67 | str The directive line, with all C or C++ comments removed |
| 68 | file Name of (possibly included) file where directive is defined |
| 69 | linenr Line number in (possibly included) file where directive is defined |
| 70 | |
| 71 | To iterate through all directives use such code: |
| 72 | @code |
| 73 | data = cppcheckdata.parsedump(...) |
| 74 | for cfg in data.configurations: |
| 75 | for directive in cfg.directives: |
| 76 | print(directive.str) |
| 77 | @endcode |
| 78 | """ |
| 79 | #preprocessor.cpp/Preprocessor::dump |
| 80 | |
| 81 | str = None |
| 82 | file = None |
| 83 | linenr = None |
| 84 | column = None |
| 85 | |
| 86 | def __init__(self, element): |
| 87 | self.str = element.get('str') |
| 88 | _load_location(self, element) |
| 89 | |
| 90 | def __repr__(self): |
| 91 | attrs = ["str", "file", "linenr"] |
| 92 | return "{}({})".format( |
| 93 | "Directive", |
| 94 | ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) |
| 95 | ) |
| 96 | |
| 97 | class MacroUsage: |
| 98 | """ |