class compunit_global_iterator

Iterator over the global symbols ( symbol ) in a compilation unit ( compunit ).

Initialize with compunit.global_symbols().

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

# set up compunit cu, then...
for e in cu.global_symbols():
    print('symbol: ', e)

compunit_global_iterator Details

class cs.compunit_global_iterator

Iterator over the global symbols ( symbol ) in a compilation unit ( compunit ).

__eq__(other)

Iterator equality.

Parameters:other (compunit_global_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'))
>>> global_iterA = cu.global_symbols()
>>> global_iterB = cu.global_symbols()
>>> global_iterA == global_iterB
True
>>> for g in global_iterA:
...     if g.name()=='foo':
...         break
...
>>> global_iterA == global_iterB
False
__iter__()

Get the iterator object.

Return type:compunit_global_iterator
Returns:self.
>>> v0 = project.current()
>>> v1 = v0.compunits_vector()
>>> v2 = v1[1].global_symbols()
>>> iter(v2)
<cs.compunit_global_iterator begin>
__ne__(other)

Iterator inequality.

Parameters:other (compunit_global_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'))
>>> global_iterA = cu.global_symbols()
>>> global_iterB = cu.global_symbols()
>>> global_iterA != global_iterB
False
>>> for g in global_iterA:
...     if g.name()=='foo':
...         break
...
>>> global_iterA != global_iterB
True
__next__()

Iterator dereference operator.

Return type:symbol
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)
>>> v0 = project.current()
>>> v1 = v0.compunits_vector()
>>> v2 = v1[1].global_symbols()
>>> next(v2)
<cs.symbol #File_Initialization>
__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_vector()
>>> v2 = v1[1].global_symbols()
>>> repr(v2)
'<cs.compunit_global_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> v0 = project.current()
>>> v1 = v0.compunits_vector()
>>> v2 = v1[1].global_symbols()
>>> str(v2)
'<cs.compunit_global_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_vector()
>>> v2 = v1[1].global_symbols()
>>> v2.at_end()
False