TextLineCursor

class TextLineCursor

Allows cursoring through external text keeping track of the line number.

Operators

Name Description
operator[] Constructor from string_view.

Functions

Name Description
TextLineCursor Construct an empty cursor.
TextLineCursor Constructor from string_view.
TextLineCursor Constructor from string.
data Get the pointer to the underlying data.
get_line_number Get the number of the current line: it is 0-based.
size Get the number of characters in the text.
view Get the text as a string_view.
substr Creates a (separate) sub-text of the current text.
substr Creates a (separate) sub-text of the current text from the given start to the current length of the text.
substr Creates a (separate) sub-text of the current text from a start position (passed as an iterator) and for a given length.
to_string Converst to string.
advance Advance the cursor by length characters; it throws out_of_range if length is higher that size().
clear Clears the current cursor.

Operator Details

operator[]

inline char operator[](std::size_t i) const noexcept

Constructor from string_view.

v
text tu cursor on.

Function Details

TextLineCursor

TextLineCursor()

Construct an empty cursor.

explicit TextLineCursor(const std::string_view &v)

Constructor from string_view.

v
text tu cursor on.

explicit TextLineCursor(const std::string &v)

Constructor from string.

v
text tu cursor on.

advance

void advance(std::size_t length)

Advance the cursor by length characters; it throws out_of_range if length is higher that size().

clear

void clear() noexcept

Clears the current cursor.

data

inline const char* data() const noexcept

Get the pointer to the underlying data.

get_line_number

inline std::size_t get_line_number() const noexcept

Get the number of the current line: it is 0-based.

size

inline std::size_t size() const noexcept

Get the number of characters in the text.

substr

TextLineCursor substr(std::size_t start, std::size_t length) const

Creates a (separate) sub-text of the current text.

start
start offset of the new sub-text
length
length of the new sub-text

TextLineCursor substr(std::size_t start) const

Creates a (separate) sub-text of the current text from the given start to the current length of the text.

start
start offset of the new sub-text

TextLineCursor substr(const_iterator start, std::size_t length) const

Creates a (separate) sub-text of the current text from a start position (passed as an iterator) and for a given length.

start
start position of the new sub-text
length
length of the new sub-text
Return
TextLineCursor

to_string

inline std::string to_string() const noexcept

Converst to string.

view

inline std::string_view view() const noexcept

Get the text as a string_view.