notepad-plus-plus/boostregex/AnsiDocumentIterator.h
Christian Grasser a61b03ea88 Update Scintilla from v4.4.6 to v5.2.1 and add Lexilla v5.1.5
Update with https://www.scintilla.org/scintilla521.zip
            https://www.scintilla.org/lexilla515.zip

- fix setting to bring Scintilla::PositionCR from ScintillaStructures.h inline with Sci_Position.h Sci_PositionCR
- add workaround to enable lexer for searchResult
commented out SCI_SETILEXER call on searchResult to get one result which is correctly handled by the lexer,
added comment about the current problem with property @MarkingsStruct which seems to disappear after call to SCI_SETILEXER or CreateLexer
- corrected usage of ObjC lexer
- removed unnecessary filter stuff
- use own sections for scintilla and lexilla build targets and allow parallel builds
- as libscilex is no longer existing, changed to libscintilla
- adapt makefiles and cmake
- use VS2019
- started simple changes for createlexer adaptations, nullpointercheck missing on return of lexer name from deprecated LexerNameFromID -> undefined behaviour
- movement from id -> lexer name, mostly done via LexerNameFromID + switching off corresponding compiler warning
- changed to SCI_SETILEXER from SCI_SETLEXER, SCI_SETLEXERLANGUAGE needs to be corrected, see Scintilla5Migration.html
- just commented out: SCI_LOADLEXERLIBRARY

Fix #10504, close #11419
2022-03-27 17:12:53 +02:00

117 lines
2.5 KiB
C++

// This file is part of Notepad++ project
// Copyright (C) 2021 Notepad++ authors.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ANSIDOCUMENTITERATOR_H_12481491281240
#define ANSIDOCUMENTITERATOR_H_12481491281240
#include "Position.h"
namespace Scintilla::Internal {
class AnsiDocumentIterator
{
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = char;
using difference_type = ptrdiff_t;
using pointer = char*;
using reference = char&;
AnsiDocumentIterator() {};
AnsiDocumentIterator(Document* doc, Sci::Position pos, Sci::Position end) :
m_pos(pos),
m_end(end),
m_doc(doc)
{
// Check for debug builds
PLATFORM_ASSERT(m_pos <= m_end);
// Ensure for release.
if (m_pos > m_end)
{
m_pos = m_end;
}
}
AnsiDocumentIterator(const AnsiDocumentIterator& copy) :
m_pos(copy.m_pos),
m_end(copy.m_end),
m_doc(copy.m_doc)
{
// Check for debug builds
PLATFORM_ASSERT(m_pos <= m_end);
// Ensure for release.
if (m_pos > m_end)
{
m_pos = m_end;
}
}
bool operator == (const AnsiDocumentIterator& other) const
{
return (ended() == other.ended()) && (m_doc == other.m_doc) && (m_pos == other.m_pos);
}
bool operator != (const AnsiDocumentIterator& other) const
{
return !(*this == other);
}
char operator * () const
{
return charAt(m_pos);
}
AnsiDocumentIterator& operator ++ ()
{
PLATFORM_ASSERT(m_pos < m_end);
m_pos++;
return *this;
}
AnsiDocumentIterator& operator -- ()
{
m_pos--;
return *this;
}
Sci::Position pos() const
{
return m_pos;
}
private:
char charAt(Sci::Position position) const
{
return m_doc->CharAt(position);
}
bool ended() const
{
return m_pos == m_end;
}
Sci::Position m_pos = 0;
Sci::Position m_end = 0;
Document* m_doc = nullptr;
};
}
#endif