|
| 1 | +# Copyright 2014-2017 Insight Software Consortium. |
| 2 | +# Copyright 2004-2009 Roman Yakovenko. |
| 3 | +# Distributed under the Boost Software License, Version 1.0. |
| 4 | +# See http://www.boost.org/LICENSE_1_0.txt |
| 5 | + |
| 6 | +""" |
| 7 | +Describe a C++ comment declaration. |
| 8 | +
|
| 9 | +""" |
| 10 | + |
| 11 | +from . import location as pygccxml_location |
| 12 | + |
| 13 | + |
| 14 | +class comment_t(object): |
| 15 | + |
| 16 | + def __init__(self, name='', declarations=None): |
| 17 | + """ |
| 18 | + Creates an object that describes a C++ comment declaration. |
| 19 | +
|
| 20 | + Args: |
| 21 | +
|
| 22 | + """ |
| 23 | + self._location = {} |
| 24 | + self._begin_line = 0 |
| 25 | + self._begin_column = 0 |
| 26 | + self._begin_offset = 0 |
| 27 | + self._end_line = 0 |
| 28 | + self._end_column = 0 |
| 29 | + self._end_offset = 0 |
| 30 | + self._text = "" |
| 31 | + |
| 32 | + @property |
| 33 | + def location(self): |
| 34 | + """An instance of the location_t class |
| 35 | + which contains the file where the |
| 36 | + comment can be found. |
| 37 | + @type: location_t """ |
| 38 | + return self._location |
| 39 | + |
| 40 | + @location.setter |
| 41 | + def location(self, location): |
| 42 | + if not isinstance(location, pygccxml_location.location_t): |
| 43 | + raise ValueError( |
| 44 | + "'location' must be a location_t (got a %s instead)" % |
| 45 | + type(location).__name__) |
| 46 | + self._location = location |
| 47 | + |
| 48 | + @property |
| 49 | + def begin_line(self): |
| 50 | + """An integer value which corresponds to the |
| 51 | + line of the file where the comment begins |
| 52 | + @type: int """ |
| 53 | + return self._begin_line |
| 54 | + |
| 55 | + @begin_line.setter |
| 56 | + def begin_line(self, begin_line): |
| 57 | + self._begin_line = int(begin_line) |
| 58 | + |
| 59 | + @property |
| 60 | + def begin_offset(self): |
| 61 | + """An integer value representing the |
| 62 | + number of bytes from the beginning of the |
| 63 | + file to the start of the comment |
| 64 | + @type: int """ |
| 65 | + return self._begin_offset |
| 66 | + |
| 67 | + @begin_offset.setter |
| 68 | + def begin_offset(self, begin_offset): |
| 69 | + self._begin_offset = int(begin_offset) |
| 70 | + |
| 71 | + @property |
| 72 | + def begin_column(self): |
| 73 | + """An integer value which corresponds to the |
| 74 | + column of the file where the comment begins |
| 75 | + @type: int """ |
| 76 | + return self._begin_column |
| 77 | + |
| 78 | + @begin_column.setter |
| 79 | + def begin_column(self, begin_column): |
| 80 | + self._begin_column = int(begin_column) |
| 81 | + |
| 82 | + @property |
| 83 | + def end_line(self): |
| 84 | + """An integer value which corresponds to the |
| 85 | + line of the file where the comment ends |
| 86 | + @type: int """ |
| 87 | + return self._end_line |
| 88 | + |
| 89 | + @end_line.setter |
| 90 | + def end_line(self, end_line): |
| 91 | + self._end_line = int(end_line) |
| 92 | + |
| 93 | + @property |
| 94 | + def end_offset(self): |
| 95 | + """An integer value representing the |
| 96 | + number of bytes from the beginning of the |
| 97 | + file to the end of the comment |
| 98 | + @type: int """ |
| 99 | + return self._end_offset |
| 100 | + |
| 101 | + @end_offset.setter |
| 102 | + def end_offset(self, end_offset): |
| 103 | + self._end_offset = int(end_offset) |
| 104 | + |
| 105 | + @property |
| 106 | + def end_column(self): |
| 107 | + """An integer value which corresponds to the |
| 108 | + column of character in a line of the file |
| 109 | + where the comment ends |
| 110 | + @type: int """ |
| 111 | + return self._end_column |
| 112 | + |
| 113 | + @end_column.setter |
| 114 | + def end_column(self, end_column): |
| 115 | + self._end_column = int(end_column) |
| 116 | + |
| 117 | + @property |
| 118 | + def text(self): |
| 119 | + """A list of strings where each entry in the list |
| 120 | + is one line of the comment. These comments will not |
| 121 | + end in a newline |
| 122 | + @type: list """ |
| 123 | + return self._text |
| 124 | + |
| 125 | + @text.setter |
| 126 | + def text(self, text): |
| 127 | + if not isinstance(text, list): |
| 128 | + raise ValueError( |
| 129 | + "'text' must be a list (got a %s instead)" % |
| 130 | + type(text).__name__) |
| 131 | + self._text = text |
0 commit comments