class sfileinst_children_iterator¶
Iterator over the include-tree children ( sfileinst ) of a source file instance.
Initialize with sfileinst.children().
Use as you would any other Python iterator. For example:
# set up sfileinst sfi, then...
for e in sfi.children():
print('sfileinst: ', e)
sfileinst_children_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
sfileinst_children_iterator Details¶
-
class
cs.sfileinst_children_iterator¶ Iterator over the include-tree children (
sfileinst) of a source file instance.-
__eq__(other)¶ Iterator equality.
Parameters: other ( sfileinst_children_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> ch_iterA = sfi.children() >>> ch_iterB = sfi.children() >>> ch_iterA == ch_iterB True >>> for s in ch_iterA: ... if s.name().endswith('apitest.h'): ... break ... >>> ch_iterA == ch_iterB False
-
__iter__()¶ Get the iterator object.
Return type: sfileinst_children_iteratorReturns: self.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> for s in sfi.children(): # iteration managed by sfileinst_children_iterator.__iter__() ... # and sfileinst_children_iterator.__next__() ... if 'apitest' in s.name(): ... print(s) ... C:\alex\test\apitest.h
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( sfileinst_children_iterator) – The iterator to compare against.Return type: bool Returns: Falseif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> ch_iterA = sfi.children() >>> ch_iterB = sfi.children() >>> ch_iterA != ch_iterB False >>> for s in ch_iterA: ... if s.name().endswith('apitest.h'): ... break ... >>> ch_iterA != ch_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: sfileinstReturns: The element at the current iterator position. Raises: StopIteration- Side effects: Modifies
self.
The typical use is implicit:
>>> for item in myiter: ... (do something to item)
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> for s in sfi.children(): # iteration managed by sfileinst_children_iterator.__iter__() ... # and sfileinst_children_iterator.__next__() ... if 'apitest' in s.name(): ... print(s) ... C:\alex\test\apitest.h
- Side effects: Modifies
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> childit = sfi.children() >>> repr(childit) '<cs.sfileinst_children_iterator begin>'
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> childit = sfi.children() >>> str(childit) '<cs.sfileinst_children_iterator begin>'
-
at_end()¶ Check: is the iterator at the end of the structure?
Return type: bool Returns: Trueif the iterator is at the end of the structure (there are no more elements to iterate over),Falseotherwise.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> sfi = cu.get_sfileinst() >>> childit = sfi.children() >>> childit.at_end() False
-