fix reference bug in readCSV()

This commit is contained in:
GenevensiS
2025-06-25 22:50:58 +02:00
parent e2d546743b
commit d95e9cb2b4
4 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -115,7 +115,7 @@ std::vector<std::string> AddCSVWindow::readCSVRow(const std::string& row) {
return fields; return fields;
} }
bool AddCSVWindow::readCSV(std::ifstream& in, std::vector<String> headers_out, std::vector<std::vector<ScriptValueP>>& table_out) { bool AddCSVWindow::readCSV(std::ifstream& in, std::vector<String>& headers_out, std::vector<std::vector<ScriptValueP>>& table_out) {
// Get the rows // Get the rows
vector<std::string> raw_rows; vector<std::string> raw_rows;
std::string raw_row; std::string raw_row;
@@ -140,7 +140,7 @@ bool AddCSVWindow::readCSV(std::ifstream& in, std::vector<String> headers_out, s
row = row + "\n"; row = row + "\n";
} }
} }
if (rows.size() == 0) { if (rows.empty()) {
queue_message(MESSAGE_ERROR, _ERROR_1_("import empty file", _("CSV / TSV"))); queue_message(MESSAGE_ERROR, _ERROR_1_("import empty file", _("CSV / TSV")));
return false; return false;
} }
@@ -183,7 +183,7 @@ void AddCSVWindow::onOk(wxCommandEvent&) {
// Check for missing fields // Check for missing fields
String missing_fields; String missing_fields;
check_table_headers(set->game, headers, _("CSV / TSV"), missing_fields); check_table_headers(set->game, headers, _("CSV / TSV"), missing_fields);
if (missing_fields.size() > 0) { if (!missing_fields.empty()) {
queue_message(MESSAGE_WARNING, _ERROR_2_("import missing fields", _("CSV / TSV"), missing_fields)); queue_message(MESSAGE_WARNING, _ERROR_2_("import missing fields", _("CSV / TSV"), missing_fields));
} }
// Produce cards from the table // Produce cards from the table
+1 -1
View File
@@ -28,7 +28,7 @@ protected:
SetP set; SetP set;
char separator; char separator;
bool readCSV(std::ifstream& in, std::vector<String> headers_out, std::vector<std::vector<ScriptValueP>>& table_out); bool readCSV(std::ifstream& in, std::vector<String>& headers_out, std::vector<std::vector<ScriptValueP>>& table_out);
std::vector<std::string> readCSVRow(const std::string& row); std::vector<std::string> readCSVRow(const std::string& row);
void onSeparatorTypeChange(wxCommandEvent&); void onSeparatorTypeChange(wxCommandEvent&);
+2 -2
View File
@@ -63,7 +63,7 @@ AddJSONWindow::AddJSONWindow(Window* parent, const SetP& set, bool sizer)
} }
} }
static ScriptValueP json_to_script(boost::json::value jv) { static ScriptValueP json_to_script(boost::json::value& jv) {
if (jv == nullptr) return script_nil; if (jv == nullptr) return script_nil;
else if (jv.is_null()) return script_nil; else if (jv.is_null()) return script_nil;
else if (jv.is_bool()) return to_script(jv.get_bool()); else if (jv.is_bool()) return to_script(jv.get_bool());
@@ -237,7 +237,7 @@ void AddJSONWindow::onOk(wxCommandEvent&) {
// Check for missing fields // Check for missing fields
String missing_fields; String missing_fields;
check_table_headers(set->game, headers, _("JSON"), missing_fields); check_table_headers(set->game, headers, _("JSON"), missing_fields);
if (missing_fields.size() > 0) { if (!missing_fields.empty()) {
queue_message(MESSAGE_WARNING, _ERROR_2_("import missing fields", _("JSON"), missing_fields)); queue_message(MESSAGE_WARNING, _ERROR_2_("import missing fields", _("JSON"), missing_fields));
} }
// Produce cards from the table // Produce cards from the table
+1 -1
View File
@@ -83,7 +83,7 @@ static bool set_builtin_container(GameP& game, CardP& card, ScriptValueP& value,
} }
static bool check_table_headers(GameP& game, std::vector<String>& headers, const String& file_extension, String& missing_fields_out) { static bool check_table_headers(GameP& game, std::vector<String>& headers, const String& file_extension, String& missing_fields_out) {
if (headers.size() == 0) { if (headers.empty()) {
queue_message(MESSAGE_ERROR, _("Empty headers given")); queue_message(MESSAGE_ERROR, _("Empty headers given"));
return false; return false;
} }