Read assetlists for ignoring assets

This commit is contained in:
Jan
2021-03-11 14:04:53 +01:00
parent 88b5eefe24
commit 792509d11d
7 changed files with 269 additions and 16 deletions

View File

@ -0,0 +1,10 @@
#include "AssetList.h"
AssetListEntry::AssetListEntry()
= default;
AssetListEntry::AssetListEntry(std::string type, std::string name)
: m_type(std::move(type)),
m_name(std::move(name))
{
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <string>
class AssetListEntry
{
public:
std::string m_type;
std::string m_name;
AssetListEntry();
AssetListEntry(std::string type, std::string name);
};

View File

@ -0,0 +1,37 @@
#include "AssetListStream.h"
AssetListInputStream::AssetListInputStream(std::istream& stream)
: m_stream(stream)
{
}
bool AssetListInputStream::NextEntry(AssetListEntry& entry) const
{
std::vector<std::string> row;
while(true)
{
if (!m_stream.NextRow(row))
return false;
if (row.empty())
continue;
entry.m_type = row[0];
if (row.size() >= 2)
entry.m_name = row[1];
return true;
}
}
AssetListOutputStream::AssetListOutputStream(std::ostream& stream)
: m_stream(stream)
{
}
void AssetListOutputStream::WriteEntry(const AssetListEntry& entry)
{
m_stream.WriteColumn(entry.m_type);
m_stream.WriteColumn(entry.m_name);
m_stream.NextRow();
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <iostream>
#include "AssetList.h"
#include "Csv/CsvStream.h"
class AssetListInputStream
{
CsvInputStream m_stream;
public:
explicit AssetListInputStream(std::istream& stream);
bool NextEntry(AssetListEntry& entry) const;
};
class AssetListOutputStream
{
CsvOutputStream m_stream;
public:
explicit AssetListOutputStream(std::ostream& stream);
void WriteEntry(const AssetListEntry& entry);
};

View File

@ -11,3 +11,24 @@ ZoneDefinitionEntry::ZoneDefinitionEntry(std::string type, std::string name, boo
m_is_reference(isReference)
{
}
void ZoneDefinition::Include(ZoneDefinition& definitionToInclude)
{
for(const auto& [key, value] : definitionToInclude.m_metadata)
{
if(m_metadata.find(key) == m_metadata.end())
{
m_metadata.emplace(std::make_pair(key, value));
}
}
for(const auto& ignore : definitionToInclude.m_ignores)
{
m_ignores.emplace_back(ignore);
}
for(const auto& asset : definitionToInclude.m_assets)
{
m_assets.emplace_back(asset);
}
}

View File

@ -21,4 +21,6 @@ public:
std::vector<std::string> m_includes;
std::vector<std::string> m_ignores;
std::vector<ZoneDefinitionEntry> m_assets;
void Include(ZoneDefinition& definitionToInclude);
};