class project_compunits_iterator

Iterator over all the compilation units ( compunit ) in a project .

Initialize with project.compunits().

Use as you would any other Python iterator. For example:

# set up project proj, then...
for e in proj.compunits():
    print('compunit: ', e)

project_compunits_iterator Details

class cs.project_compunits_iterator

Iterator over all the compilation units ( compunit ) in a project .

__eq__(other)

Iterator equality.

Parameters:other (project_compunits_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_iterA = project.current().compunits()
>>> cu_iterB = project.current().compunits()
>>> cu_iterA == cu_iterB
True
>>> for cu  in cu_iterA:
...     if cu.name().endswith('apitest.cpp'):
...         break
...
>>> cu_iterA == cu_iterB
False
__iter__()

Get the iterator object.

Return type:project_compunits_iterator
Returns:self.
>>> for cu in project.current().compunits(): # iteration managed by project_compunits_iterator.__iter__()
...                                          # and project_compunits_iterator.__next__()
...     if cu.is_user():
...         print(cu)
...
C:\cygwin\home\alex\testmicros\API\apitest.cpp
__ne__(other)

Iterator inequality.

Parameters:other (project_compunits_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_iterA = project.current().compunits()
>>> cu_iterB = project.current().compunits()
>>> cu_iterA != cu_iterB
False
>>> for cu  in cu_iterA:
...     if cu.name().endswith('apitest.cpp'):
...         break
...
>>> cu_iterA != cu_iterB
True
__next__()

Iterator dereference operator.

Return type:compunit
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)
>>> for cu in project.current().compunits(): # iteration managed by project_compunits_iterator.__iter__()
...                                          # and project_compunits_iterator.__next__()
...     if cu.is_user():
...         print(cu)
...
C:\cygwin\home\alex\testmicros\API\apitest.cpp
__repr__()

Get a representation of the iterator that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> v0 = project.current()
>>> v1 = v0.compunits()
>>> repr(v1)
'<cs.project_compunits_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> v0 = project.current()
>>> v1 = v0.compunits()
>>> str(v1)
'<cs.project_compunits_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.
>>> v0 = project.current()
>>> v1 = v0.compunits()
>>> v1.at_end()
False