SoundBankWriter code

This commit is contained in:
Alex
2024-01-26 12:14:47 -05:00
parent acd9fa27fc
commit a020de6f80
15 changed files with 565 additions and 62 deletions

View File

@ -6,7 +6,7 @@ ParsedCsvRow::ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std
{
}
const std::string& ParsedCsvRow::GetValue(const std::string& header, bool required) const
const std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const
{
if (this->headers.find(header) == this->headers.end())
{
@ -14,19 +14,34 @@ const std::string& ParsedCsvRow::GetValue(const std::string& header, bool requir
std::cerr << "ERROR: Required column \"" << header << "\" was not found";
else
std::cerr << "WARNING: Expected column \"" << header << "\" was not found";
return nullptr;
return {};
}
auto& value = this->values.at(this->headers[header]);
if (required && value.empty())
{
std::cerr << "ERROR: Required column \"" << header << "\" does not have a value";
return nullptr;
return {};
}
return value;
}
const float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const
{
const auto& value = this->GetValue(header, required);
if (!value.empty())
{
std::istringstream ss(value);
float out;
ss >> out;
return out;
}
return {};
}
ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders)
{
std::vector<std::vector<std::string>> csvLines;