class symbol_universe_iterator

Iterator over all the symbols ( symbol ) in a project .

Initialize with project.symbols().

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

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

symbol_universe_iterator Details

class cs.symbol_universe_iterator

Iterator over all the symbols ( symbol ) in a project .

__eq__(other)

Iterator equality.

Parameters:other (symbol_universe_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.
>>> symu_iterA = project.current().symbols()
>>> symu_iterB = project.current().symbols()
>>> symu_iterA == symu_iterB
True
>>> for sym in symu_iterA:
...     if 'j' in sym.name().lower():
...         break
...
>>> symu_iterA == symu_iterB
False
__iter__()

Get the iterator object.

Return type:symbol_universe_iterator
Returns:self.
>>> for sym in project.current().symbols(): # iteration managed by symbol_universe_iterator.__iter__()
...                                         # and symbol_universe_iterator.__next__()
...     if sym.is_string() and sym.get_compunit().is_user():
...         print(sym, sym.represented_string())
...
#string1 bar
#string0 foo
__ne__(other)

Iterator inequality.

Parameters:other (symbol_universe_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.
>>> symu_iterA = project.current().symbols()
>>> symu_iterB = project.current().symbols()
>>> symu_iterA != symu_iterB
False
>>> for sym in symu_iterA:
...     if 'j' in sym.name().lower():
...         break
...
>>> symu_iterA != symu_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)
>>> for sym in project.current().symbols(): # iteration managed by symbol_universe_iterator.__iter__()
...                                         # and symbol_universe_iterator.__next__()
...     if sym.is_string() and sym.get_compunit().is_user():
...         print(sym, sym.represented_string())
...
#string1 bar
#string0 foo
__repr__()

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

Return type:str
Returns:The string representation.
>>> syms = project.current().symbols()
>>> repr(syms)
'<cs.symbol_universe_iterator begin>'
__str__()

Get a simple string representation of the iterator.

Return type:str
Returns:The string representation.
>>> syms = project.current().symbols()
>>> str(syms)
'<cs.symbol_universe_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.
>>> syms = project.current().symbols()
>>> syms.at_end()
False