mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
fix reference bug in readCSV()
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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&);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user