2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-01 16:51:56 +00:00

Add blocks to header parsing state that manipulate which sequences are valid

This commit is contained in:
Jan
2021-02-14 10:27:47 +01:00
parent 3f08be0564
commit e685348abd
18 changed files with 79 additions and 33 deletions

View File

@ -11,3 +11,21 @@ IHeaderBlock* HeaderParserState::GetBlock() const
{
return m_blocks.top().get();
}
void HeaderParserState::PushBlock(std::unique_ptr<IHeaderBlock> block)
{
m_blocks.emplace(std::move(block));
m_blocks.top()->OnOpen(this);
}
void HeaderParserState::PopBlock()
{
// Leave at least one block on the stack which should be the only "none" block
if (m_blocks.size() > 1)
{
std::unique_ptr<IHeaderBlock> poppedBlock = std::move(m_blocks.top());
m_blocks.pop();
poppedBlock->OnClose(this);
m_blocks.top()->OnChildBlockClose(this, poppedBlock.get());
}
}

View File

@ -4,6 +4,7 @@
#include <stack>
#include "Utils/ClassUtils.h"
#include "Utils/NamespaceBuilder.h"
#include "Parsing/Header/Block/IHeaderBlock.h"
class IHeaderBlock;
@ -12,7 +13,11 @@ class HeaderParserState
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
public:
NamespaceBuilder m_namespace;
HeaderParserState();
_NODISCARD IHeaderBlock* GetBlock() const;
void PushBlock(std::unique_ptr<IHeaderBlock> block);
void PopBlock();
};