class sfileinst_range

A range of (contiguous) locations in a single source file instance.

sfileinst_range Details

class cs.sfileinst_range

A range of (contiguous) locations in a single source file instance.

__init__(_file, _start, _end)

Constructor.

Parameters:
  • _file (sfileinst) – The file instance ( sfileinst ) in which the range occurs.
  • _start ((int, int)) – The line and column of the first character in the range.
  • _end ((int, int)) – The line and column of the last character in the range.
Raises:

OverflowError

>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> sfi = cu.get_sfileinst()
>>> sfileinst_range(sfi, (3, 4), (7, 10))
<cs.sfileinst_range <cs.sfileinst C:\alex\test\apitest.cpp>:3.4-7.10>
__repr__()

Get a representation of a sfileinst_range object 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()
>>> sfir = sfileinst_range(sfi, (3, 4), (7, 10))
>>> repr(sfir)
'<cs.sfileinst_range <cs.sfileinst C:\\alex\\test\\apitest.cpp>:3.4-7.10>'
__str__()

Get a simple string representation of a sfileinst_range object.

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()
>>> sfir = sfileinst_range(sfi, (3, 4), (7, 10))
>>> str(sfir)
'<cs.sfileinst C:\\alex\\test\\apitest.cpp>:3.4-7.10'
get_end()

Get the end line and column number from a sfileinst_range .

Return type:(int, int)
Returns:The end line and column number.
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> sfi = cu.get_sfileinst()
>>> sfir = sfileinst_range(sfi, (3, 4), (7, 10))
>>> sfir.get_end()
(7, 10)
get_file()

Get the source file instance from a sfileinst_range .

Return type:sfileinst
Returns:The source file instance ( sfileinst ).
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> sfi = cu.get_sfileinst()
>>> sfir = sfileinst_range(sfi, (3, 4), (7, 10))
>>> sfir.get_file()
<cs.sfileinst C:\alex\test\apitest.cpp>
get_start()

Get the start line and column number from a sfileinst_range .

Return type:(int, int)
Returns:The start line and column number.
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp'))
>>> sfi = cu.get_sfileinst()
>>> sfir = sfileinst_range(sfi, (3, 4), (7, 10))
>>> sfir.get_start()
(3,4)