本文整理汇总了C++中ErrorList::add_error方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorList::add_error方法的具体用法?C++ ErrorList::add_error怎么用?C++ ErrorList::add_error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorList
的用法示例。
在下文中一共展示了ErrorList::add_error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verify_column_selections
/* Test for the required minimum number of columns selected and
* the selection is consistent.
* @param An ErrorList object to which all found issues are added.
*/
void GncTxImport::verify_column_selections (ErrorList& error_msg)
{
/* Verify if a date column is selected and it's parsable.
*/
if (!check_for_column_type(GncTransPropType::DATE))
error_msg.add_error( _("Please select a date column."));
/* Verify if an account is selected either in the base account selector
* or via a column in the import data.
*/
if (!check_for_column_type(GncTransPropType::ACCOUNT))
{
if (m_settings.m_multi_split)
error_msg.add_error( _("Please select an account column."));
else if (!m_settings.m_base_account)
error_msg.add_error( _("Please select an account column or set a base account in the Account field."));
}
/* Verify a description column is selected.
*/
if (!check_for_column_type(GncTransPropType::DESCRIPTION))
error_msg.add_error( _("Please select a description column."));
/* Verify at least one amount column (deposit or withdrawal) column is selected.
*/
if (!check_for_column_type(GncTransPropType::DEPOSIT) &&
!check_for_column_type(GncTransPropType::WITHDRAWAL))
error_msg.add_error( _("Please select a deposit or withdrawal column."));
/* Verify a transfer account is selected if any of the other transfer properties
* are selected.
*/
if ((check_for_column_type(GncTransPropType::TACTION) ||
check_for_column_type(GncTransPropType::TMEMO) ||
check_for_column_type(GncTransPropType::TREC_STATE) ||
check_for_column_type(GncTransPropType::TREC_DATE)) &&
!check_for_column_type(GncTransPropType::TACCOUNT))
error_msg.add_error( _("Please select a transfer account column or remove the other transfer related columns."));
}
示例2:
Route::Route(std::string &line, HighwaySystem *sys, ErrorList &el, std::unordered_map<std::string, Region*> ®ion_hash)
{ /* initialize object from a .csv file line,
but do not yet read in waypoint file */
con_route = 0;
mileage = 0;
rootOrder = -1; // order within connected route
if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines
// system
size_t left = line.find(';');
if (left == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 1");
return;
}
system = sys;
if (system->systemname != line.substr(0,left))
{ el.add_error("System mismatch parsing " + system->systemname + ".csv line [" + line + "], expected " + system->systemname);
return;
}
// region
size_t right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 2");
return;
}
try { region = region_hash.at(line.substr(left+1, right-left-1));
}
catch (const std::out_of_range& oor)
{ el.add_error("Unrecognized region in " + system->systemname + ".csv line: [" + line + "], " + line.substr(left+1, right-left-1));
region = 0;
return;
}
// route
left = right;
right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 3");
return;
}
route = line.substr(left+1, right-left-1);
// banner
left = right;
right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 4");
return;
}
banner = line.substr(left+1, right-left-1);
if (banner.size() > 6)
{ el.add_error("Banner >6 characters in " + system->systemname + ".csv line: [" + line + "], " + banner);
return;
}
// abbrev
left = right;
right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 5");
return;
}
abbrev = line.substr(left+1, right-left-1);
if (abbrev.size() > 3)
{ el.add_error("Abbrev >3 characters in " + system->systemname + ".csv line: [" + line + "], " + abbrev);
return;
}
// city
left = right;
right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 6");
return;
}
city = line.substr(left+1, right-left-1);
// root
left = right;
right = line.find(';', left+1);
if (right == std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found 7");
return;
}
root = line.substr(left+1, right-left-1);
// alt_route_names
left = right;
right = line.find(';', left+1);
if (right != std::string::npos)
{ el.add_error("Could not parse " + system->systemname + ".csv line: [" + line + "], expected 8 fields, found more");
return;
}
char *arnstr = new char[line.size()-left];
strcpy(arnstr, line.substr(left+1).data());
for (char *token = strtok(arnstr, ","); token; token = strtok(0, ","))
alt_route_names.push_back(token);
delete[] arnstr;
//yDEBUG*/ std::cout << "returning from Route ctor" << endl;
//.........这里部分代码省略.........