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 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:True if and only if self and other are at the same position. Behavior is undefined if self and other are 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_iterator
Returns: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:False if and only if self and other are at the same position. Behavior is undefined if self and other are 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:sfileinst
Returns: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
__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:True if the iterator is at the end of the structure (there are no more elements to iterate over), False otherwise.
>>> 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