mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 07:48:16 -05:00
chore: small code cleanups
This commit is contained in:
@ -6,7 +6,7 @@ ParsedCsvRow::ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std
|
||||
{
|
||||
}
|
||||
|
||||
std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const
|
||||
std::string ParsedCsvRow::GetValue(const std::string& header, const bool required) const
|
||||
{
|
||||
if (this->headers.find(header) == this->headers.end())
|
||||
{
|
||||
@ -28,7 +28,7 @@ std::string ParsedCsvRow::GetValue(const std::string& header, bool required) con
|
||||
return value;
|
||||
}
|
||||
|
||||
float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const
|
||||
float ParsedCsvRow::GetValueFloat(const std::string& header, const bool required) const
|
||||
{
|
||||
const auto& value = this->GetValue(header, required);
|
||||
if (!value.empty())
|
||||
@ -42,7 +42,7 @@ float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) cons
|
||||
return {};
|
||||
}
|
||||
|
||||
ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders)
|
||||
ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, const bool hasHeaders)
|
||||
{
|
||||
std::vector<std::vector<std::string>> csvLines;
|
||||
std::vector<std::string> currentLine;
|
||||
@ -55,7 +55,7 @@ ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders)
|
||||
|
||||
if (hasHeaders)
|
||||
{
|
||||
auto& headersRow = csvLines[0];
|
||||
const auto& headersRow = csvLines[0];
|
||||
for (auto i = 0u; i < headersRow.size(); i++)
|
||||
{
|
||||
this->headers[headersRow[i]] = i;
|
||||
@ -74,7 +74,7 @@ size_t ParsedCsv::Size() const
|
||||
return this->rows.size();
|
||||
}
|
||||
|
||||
ParsedCsvRow ParsedCsv::operator[](size_t index) const
|
||||
ParsedCsvRow ParsedCsv::operator[](const size_t index) const
|
||||
{
|
||||
return this->rows.at(index);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Csv/CsvStream.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
@ -11,10 +13,10 @@ class ParsedCsvRow
|
||||
|
||||
public:
|
||||
explicit ParsedCsvRow(std::unordered_map<std::string, size_t>& headers, std::vector<std::string> row);
|
||||
std::string GetValue(const std::string& header, bool required = false) const;
|
||||
float GetValueFloat(const std::string& header, bool required = false) const;
|
||||
_NODISCARD std::string GetValue(const std::string& header, bool required = false) const;
|
||||
_NODISCARD float GetValueFloat(const std::string& header, bool required = false) const;
|
||||
|
||||
template<typename T> T GetValueInt(const std::string& header, bool required = false) const
|
||||
template<typename T> T GetValueInt(const std::string& header, const bool required = false) const
|
||||
{
|
||||
const auto& value = this->GetValue(header, required);
|
||||
if (!value.empty())
|
||||
@ -37,7 +39,7 @@ class ParsedCsv
|
||||
public:
|
||||
explicit ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders = true);
|
||||
|
||||
size_t Size() const;
|
||||
_NODISCARD size_t Size() const;
|
||||
|
||||
ParsedCsvRow operator[](size_t index) const;
|
||||
};
|
||||
|
@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
|
Reference in New Issue
Block a user