mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-27 15:02:06 +00:00
chore: parse includes and assetlists while parsing zone definition
This commit is contained in:
@@ -7,28 +7,24 @@
|
||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||
#include "StructuredDataDef/Parsing/StructuredDataDefParser.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace sdd;
|
||||
|
||||
StructuredDataDefReader::StructuredDataDefReader(std::istream& stream, std::string fileName)
|
||||
: StructuredDataDefReader(stream, std::move(fileName), nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
StructuredDataDefReader::StructuredDataDefReader(std::istream& stream, std::string fileName, include_callback_t includeCallback)
|
||||
: m_file_name(std::move(fileName)),
|
||||
StructuredDataDefReader::StructuredDataDefReader(std::istream& stream, std::string fileName, ISearchPath& searchPath)
|
||||
: SearchPathMultiInputStream(searchPath),
|
||||
m_file_name(std::move(fileName)),
|
||||
m_stream(nullptr)
|
||||
{
|
||||
OpenBaseStream(stream, std::move(includeCallback));
|
||||
OpenBaseStream(stream);
|
||||
SetupStreamProxies();
|
||||
m_stream = m_open_streams.back().get();
|
||||
}
|
||||
|
||||
bool StructuredDataDefReader::OpenBaseStream(std::istream& stream, include_callback_t includeCallback)
|
||||
bool StructuredDataDefReader::OpenBaseStream(std::istream& stream)
|
||||
{
|
||||
if (includeCallback)
|
||||
m_open_streams.emplace_back(std::make_unique<ParserMultiInputStream>(stream, m_file_name, std::move(includeCallback)));
|
||||
else
|
||||
m_open_streams.emplace_back(std::make_unique<ParserSingleInputStream>(stream, m_file_name));
|
||||
m_open_streams.emplace_back(std::make_unique<ParserMultiInputStream>(stream, m_file_name, *this));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -58,6 +54,7 @@ std::vector<std::unique_ptr<CommonStructuredDataDef>> StructuredDataDefReader::R
|
||||
if (success)
|
||||
return parser->GetDefs();
|
||||
|
||||
std::cout << "Parsing structured data def file \"" << m_file_name << "\" failed!\n";
|
||||
std::cerr << std::format("Parsing structured data def file \"{}\" failed!\n", m_file_name);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "SearchPath/SearchPathMultiInputStream.h"
|
||||
#include "StructuredDataDef/CommonStructuredDataDef.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class StructuredDataDefReader
|
||||
class StructuredDataDefReader : public SearchPathMultiInputStream
|
||||
{
|
||||
public:
|
||||
using include_callback_t = std::function<std::unique_ptr<std::istream>(const std::string& filename, const std::string& sourceFile)>;
|
||||
StructuredDataDefReader(std::istream& stream, std::string fileName, ISearchPath& searchPath);
|
||||
|
||||
std::vector<std::unique_ptr<CommonStructuredDataDef>> ReadStructureDataDefs(bool& success);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream(std::istream& stream);
|
||||
void SetupStreamProxies();
|
||||
|
||||
std::string m_file_name;
|
||||
IParserLineStream* m_stream;
|
||||
std::vector<std::unique_ptr<IParserLineStream>> m_open_streams;
|
||||
|
||||
bool OpenBaseStream(std::istream& stream, include_callback_t includeCallback);
|
||||
void SetupStreamProxies();
|
||||
|
||||
public:
|
||||
StructuredDataDefReader(std::istream& stream, std::string fileName);
|
||||
StructuredDataDefReader(std::istream& stream, std::string fileName, include_callback_t includeCallback);
|
||||
|
||||
std::vector<std::unique_ptr<CommonStructuredDataDef>> ReadStructureDataDefs(bool& success);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user