mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-23 19:36:26 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#include "TokenList.h"
|
|
|
|
TokenList::TokenList(std::string_view value)
|
|
: head(new TokenListNode())
|
|
, length(1)
|
|
{
|
|
const TokenListPtr newNode = new Text(head, head, value);
|
|
head->next = newNode;
|
|
}
|
|
|
|
TokenList::~TokenList()
|
|
{
|
|
TokenListPtr next = head->next;
|
|
while (head != next)
|
|
{
|
|
TokenListPtr current = next;
|
|
next = next->next;
|
|
delete current;
|
|
}
|
|
|
|
delete head;
|
|
}
|
|
|
|
TokenListPtr TokenList::addAfter(TokenListPtr node, const std::string& type, TokenList&& children, const std::string& alias, size_t textLength)
|
|
{
|
|
const TokenListPtr next = node->next;
|
|
const TokenListPtr newNode = new Syntax(node, next, type, std::move(children), alias, textLength);
|
|
|
|
node->next = newNode;
|
|
next->prev = newNode;
|
|
length++;
|
|
|
|
return newNode;
|
|
}
|
|
|
|
TokenListPtr TokenList::addAfter(TokenListPtr node, std::string_view value)
|
|
{
|
|
const TokenListPtr next = node->next;
|
|
const TokenListPtr newNode = new Text(node, next, value);
|
|
|
|
node->next = newNode;
|
|
next->prev = newNode;
|
|
length++;
|
|
|
|
return newNode;
|
|
}
|
|
|
|
void TokenList::removeRange(TokenListPtr node, size_t count)
|
|
{
|
|
TokenListPtr item = node->next;
|
|
|
|
for (size_t i = 0; i < count && item != nullptr; i++)
|
|
{
|
|
node->next = item->next;
|
|
node->next->prev = node;
|
|
delete item;
|
|
|
|
item = node->next;
|
|
length--;
|
|
}
|
|
}
|
|
|
|
Syntax::Syntax(TokenListPtr prev, TokenListPtr next, const std::string& type, TokenList&& children, const std::string& alias, size_t length)
|
|
: TokenListNode(prev, next)
|
|
, m_type(type)
|
|
, m_children(std::move(children))
|
|
, m_alias(alias)
|
|
, m_length(length)
|
|
{
|
|
|
|
}
|