mirror of
https://github.com/RGBCube/serenity
synced 2025-06-12 04:32:07 +00:00
LibCore: Remove deprecated LineRange and LineIterator
This commit is contained in:
parent
f93ee3142d
commit
7e70ca1040
2 changed files with 0 additions and 68 deletions
|
@ -297,27 +297,4 @@ bool IODevice::write(StringView v)
|
||||||
return write((u8 const*)v.characters_without_null_termination(), v.length());
|
return write((u8 const*)v.characters_without_null_termination(), v.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
LineIterator::LineIterator(IODevice& device, bool is_end)
|
|
||||||
: m_device(device)
|
|
||||||
, m_is_end(is_end)
|
|
||||||
{
|
|
||||||
if (!m_is_end) {
|
|
||||||
++*this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LineIterator::at_end() const
|
|
||||||
{
|
|
||||||
return m_device->eof();
|
|
||||||
}
|
|
||||||
|
|
||||||
LineIterator& LineIterator::operator++()
|
|
||||||
{
|
|
||||||
m_buffer = m_device->read_line();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
LineIterator LineRange::begin() { return m_device.line_begin(); }
|
|
||||||
LineIterator LineRange::end() { return m_device.line_end(); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,44 +14,6 @@
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class IODevice;
|
|
||||||
|
|
||||||
// This is not necessarily a valid iterator in all contexts,
|
|
||||||
// if we had concepts, this would be InputIterator, not Copyable, Movable.
|
|
||||||
class LineIterator {
|
|
||||||
AK_MAKE_NONCOPYABLE(LineIterator);
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit LineIterator(IODevice&, bool is_end = false);
|
|
||||||
|
|
||||||
bool operator==(LineIterator const& other) const { return &other == this || (at_end() && other.is_end()) || (other.at_end() && is_end()); }
|
|
||||||
bool is_end() const { return m_is_end; }
|
|
||||||
bool at_end() const;
|
|
||||||
|
|
||||||
LineIterator& operator++();
|
|
||||||
|
|
||||||
StringView operator*() const { return m_buffer; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
NonnullRefPtr<IODevice> m_device;
|
|
||||||
bool m_is_end { false };
|
|
||||||
DeprecatedString m_buffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LineRange {
|
|
||||||
public:
|
|
||||||
LineRange() = delete;
|
|
||||||
explicit LineRange(IODevice& device)
|
|
||||||
: m_device(device)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
LineIterator begin();
|
|
||||||
LineIterator end();
|
|
||||||
|
|
||||||
private:
|
|
||||||
IODevice& m_device;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class OpenMode : unsigned {
|
enum class OpenMode : unsigned {
|
||||||
NotOpen = 0,
|
NotOpen = 0,
|
||||||
ReadOnly = 1,
|
ReadOnly = 1,
|
||||||
|
@ -101,13 +63,6 @@ public:
|
||||||
virtual bool open(OpenMode) = 0;
|
virtual bool open(OpenMode) = 0;
|
||||||
virtual bool close();
|
virtual bool close();
|
||||||
|
|
||||||
LineIterator line_begin() & { return LineIterator(*this); }
|
|
||||||
LineIterator line_end() { return LineIterator(*this, true); }
|
|
||||||
LineRange lines()
|
|
||||||
{
|
|
||||||
return LineRange(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit IODevice(Object* parent = nullptr);
|
explicit IODevice(Object* parent = nullptr);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue