2020-04-05 05:11:33 +03:00
|
|
|
/*
|
2021-04-28 23:46:44 +03:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2020-04-05 05:11:33 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-05 05:11:33 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-05-28 21:40:53 +03:00
|
|
|
|
2021-01-21 22:55:37 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2020-04-05 05:11:33 +03:00
|
|
|
namespace Line {
|
2020-05-28 23:35:39 +03:00
|
|
|
|
2020-04-05 05:11:33 +03:00
|
|
|
class Span {
|
|
|
|
public:
|
2020-05-18 20:05:01 +03:00
|
|
|
enum Mode {
|
|
|
|
ByteOriented,
|
|
|
|
CodepointOriented,
|
|
|
|
};
|
|
|
|
|
|
|
|
Span(size_t start, size_t end, Mode mode = ByteOriented)
|
2020-04-05 05:11:33 +03:00
|
|
|
: m_beginning(start)
|
|
|
|
, m_end(end)
|
2020-05-18 20:05:01 +03:00
|
|
|
, m_mode(mode)
|
2020-04-05 05:11:33 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t beginning() const { return m_beginning; }
|
|
|
|
size_t end() const { return m_end; }
|
2020-05-18 20:05:01 +03:00
|
|
|
Mode mode() const { return m_mode; }
|
2020-04-05 05:11:33 +03:00
|
|
|
|
2022-07-17 02:37:03 +03:00
|
|
|
bool is_empty() const
|
|
|
|
{
|
|
|
|
return m_beginning < m_end;
|
|
|
|
}
|
|
|
|
|
2020-04-05 05:11:33 +03:00
|
|
|
private:
|
|
|
|
size_t m_beginning { 0 };
|
|
|
|
size_t m_end { 0 };
|
2020-05-18 20:05:01 +03:00
|
|
|
Mode m_mode { CodepointOriented };
|
2020-04-05 05:11:33 +03:00
|
|
|
};
|
2020-05-28 23:35:39 +03:00
|
|
|
|
2020-04-05 05:11:33 +03:00
|
|
|
}
|