class symbol_set_iterator¶
Iterator over the symbol elements of a symbol_set .
Use a symbol_set_iterator to iterate over a symbol_set . For example:
for e in my_symbol_set:
print('symbol: ', e)
symbol_set_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
symbol_set_iterator Details¶
-
class
cs.symbol_set_iterator¶ Iterator over the
symbolelements of asymbol_set.-
__eq__(other)¶ Iterator equality.
Parameters: other ( symbol_set_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')) >>> proc = next(p for p in cu.procedures() if p.name()=='bar') >>> pt = next(p for p in proc.points() ... if p.get_kind()==point_kind.EXPRESSION ... and p.get_ast()[1].get_class()==ast_class.NC_POINTEREXPR) >>> print(pt) [expression] *p = x >>> pt_used = symbol_set(pt.csonar_enum_used()) >>> symset_iterA = iter(pt_used) >>> symset_iterB = iter(pt_used) >>> symset_iterA == symset_iterB True >>> for sym in symset_iterA: ... if sym.name() =='x': ... break ... >>> symset_iterA == symset_iterB False
-
__iter__()¶ Get the iterator object.
Return type: symbol_set_iteratorReturns: self.>>> cu = next(c for c in project.current().compunits() ... if c.name().endswith('apitest.cpp')) >>> proc = next(p for p in cu.procedures() if p.name()=='bar') >>> pt = next(p for p in proc.points() ... if p.get_kind()==point_kind.EXPRESSION ... and p.get_ast()[1].get_class()==ast_class.NC_POINTEREXPR) >>> print(pt) [expression] *p = x >>> pt_used = symbol_set(pt.csonar_enum_used()) >>> for sym in iter(pt_used): # iteration managed by symbol_set_iterator.__iter__() ... # and symbol_set_iterator.__next__() ... print(sym.file_line(), sym.name()) ... (<cs.sfileinst C:\alex\test\apitest.cpp>, 14) x (<cs.sfileinst C:\alex\test\apitest.cpp>, 15) p
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( symbol_set_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')) >>> proc = next(p for p in cu.procedures() if p.name()=='bar') >>> pt = next(p for p in proc.points() ... if p.get_kind()==point_kind.EXPRESSION ... and p.get_ast()[1].get_class()==ast_class.NC_POINTEREXPR) >>> print(pt) [expression] *p = x >>> pt_used = symbol_set(pt.csonar_enum_used()) >>> symset_iterA = iter(pt_used) >>> symset_iterB = iter(pt_used) >>> symset_iterA != symset_iterB False >>> for sym in symset_iterA: ... if sym.name() =='x': ... break ... >>> symset_iterA != symset_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: symbolReturns: 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')) >>> proc = next(p for p in cu.procedures() if p.name()=='bar') >>> pt = next(p for p in proc.points() ... if p.get_kind()==point_kind.EXPRESSION ... and p.get_ast()[1].get_class()==ast_class.NC_POINTEREXPR) >>> print(pt) [expression] *p = x >>> pt_used = symbol_set(pt.csonar_enum_used()) >>> for sym in iter(pt_used): # iteration managed by symbol_set_iterator.__iter__() ... # and symbol_set_iterator.__next__() ... print(sym.file_line(), sym.name()) ... (<cs.sfileinst C:\alex\test\apitest.cpp>, 14) x (<cs.sfileinst C:\alex\test\apitest.cpp>, 15) p
- Side effects: Modifies
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> v0 = symbol_set() >>> v1 = iter(v0) >>> repr(v1) '<cs.symbol_set_iterator begin>'
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> v0 = symbol_set() >>> v1 = iter(v0) >>> str(v1) '<cs.symbol_set_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.>>> v0 = symbol_set() >>> v1 = iter(v0) >>> v1.at_end() True
-