2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-07-03 01:31:54 +00:00

Load state maps when loading techniques

This commit is contained in:
Jan
2022-08-13 20:50:40 +02:00
parent 6d15ddcd08
commit 595af125b9
14 changed files with 142 additions and 28 deletions

View File

@ -142,8 +142,8 @@ namespace state_map
};
}
StateMapParser::StateMapParser(SimpleLexer* lexer, const StateMapLayout& layout)
: AbstractParser(lexer, std::make_unique<StateMapParserState>(layout))
StateMapParser::StateMapParser(SimpleLexer* lexer, std::string stateMapName, const StateMapLayout& layout)
: AbstractParser(lexer, std::make_unique<StateMapParserState>(std::move(stateMapName), layout))
{
}

View File

@ -15,7 +15,7 @@ namespace state_map
const std::vector<sequence_t*>& GetTestsForState() override;
public:
StateMapParser(SimpleLexer* lexer, const StateMapLayout& layout);
StateMapParser(SimpleLexer* lexer, std::string stateMapName, const StateMapLayout& layout);
_NODISCARD std::unique_ptr<StateMapDefinition> GetStateMapDefinition() const;
_NODISCARD StateMapParserState* GetState() const;
};

View File

@ -2,11 +2,12 @@
using namespace state_map;
StateMapParserState::StateMapParserState(const StateMapLayout& layout)
StateMapParserState::StateMapParserState(std::string stateMapName, const StateMapLayout& layout)
: m_layout(layout),
m_definition(std::make_unique<StateMapDefinition>(layout.m_layout_entries.size())),
m_definition(std::make_unique<StateMapDefinition>(std::move(stateMapName), layout.m_layout_entries.size())),
m_in_entry(false),
m_current_entry_index(0u)
m_current_entry_index(0u),
m_current_rule(nullptr)
{
for (auto i = 0u; i < m_layout.m_layout_entries.size(); i++)
m_valid_state_map_entry_names.emplace(m_layout.m_layout_entries[i].m_name, i);

View File

@ -20,6 +20,6 @@ namespace state_map
size_t m_current_entry_index;
StateMapRule* m_current_rule;
explicit StateMapParserState(const StateMapLayout& layout);
StateMapParserState(std::string stateMapName, const StateMapLayout& layout);
};
}

View File

@ -7,7 +7,8 @@ bool StateMapRule::IsPassthrough() const
return m_values.empty();
}
StateMapDefinition::StateMapDefinition(const size_t entryCount)
: m_state_map_entries(entryCount)
StateMapDefinition::StateMapDefinition(std::string name, const size_t entryCount)
: m_name(std::move(name)),
m_state_map_entries(entryCount)
{
}

View File

@ -1,4 +1,5 @@
#pragma once
#include <memory>
#include <string>
#include <vector>
@ -26,8 +27,9 @@ namespace state_map
class StateMapDefinition
{
public:
explicit StateMapDefinition(size_t entryCount);
StateMapDefinition(std::string name, size_t entryCount);
std::string m_name;
std::vector<StateMapEntry> m_state_map_entries;
};
}

View File

@ -8,8 +8,9 @@
using namespace state_map;
StateMapReader::StateMapReader(std::istream& stream, std::string fileName, const StateMapLayout& layout)
: m_file_name(std::move(fileName)),
StateMapReader::StateMapReader(std::istream& stream, std::string fileName, std::string stateMapName, const StateMapLayout& layout)
: m_state_map_name(std::move(stateMapName)),
m_file_name(std::move(fileName)),
m_state_map_layout(layout)
{
m_base_stream = std::make_unique<ParserSingleInputStream>(stream, m_file_name);
@ -42,7 +43,7 @@ std::unique_ptr<StateMapDefinition> StateMapReader::ReadStateMapDefinition() con
lexerConfig.m_read_floating_point_numbers = false;
const auto lexer = std::make_unique<SimpleLexer>(m_comment_proxy.get(), std::move(lexerConfig));
const auto parser = std::make_unique<StateMapParser>(lexer.get(), m_state_map_layout);
const auto parser = std::make_unique<StateMapParser>(lexer.get(), m_state_map_name, m_state_map_layout);
const auto success = parser->Parse();
if (!success)

View File

@ -13,13 +13,14 @@ namespace state_map
{
class StateMapReader
{
std::string m_state_map_name;
std::string m_file_name;
const StateMapLayout& m_state_map_layout;
std::unique_ptr<IParserLineStream> m_base_stream;
std::unique_ptr<IParserLineStream> m_comment_proxy;
public:
StateMapReader(std::istream& stream, std::string fileName, const StateMapLayout& layout);
StateMapReader(std::istream& stream, std::string fileName, std::string stateMapName, const StateMapLayout& layout);
_NODISCARD bool IsValidEndState(const StateMapParserState* state) const;
_NODISCARD std::unique_ptr<StateMapDefinition> ReadStateMapDefinition() const;