本文整理汇总了C++中Error::HasErrors方法的典型用法代码示例。如果您正苦于以下问题:C++ Error::HasErrors方法的具体用法?C++ Error::HasErrors怎么用?C++ Error::HasErrors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::HasErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
string temp;
string fin_file_name, fout_file_name;
if (!(argc == 2 || argc == 3))
{
cout << "Need command line arguments: <input file> [<output file>]." << endl;
return 1;
}
//открытие файлов
if (argc > 1)
{
fin_file_name = Tooem(argv[1]);
}
ifstream fin(fin_file_name, ios::in);
if (!fin)
{
cout << "Error opening file: " << fin_file_name << "!" << endl;
return 1;
}
if (argc > 2)
{
fout_file_name = Tooem(argv[2]);
}
if (fin_file_name == fout_file_name)
{
cout << "Command line arguments is same: <input file> <output file>." << endl;
return 1;
}
ofstream f;
if (!fout_file_name.empty())
{
f.open(fout_file_name, ios::out);
if (!f)
{
cout << "Error opening file: " << fout_file_name << "!" << endl;
return 1;
}
}
Error e;
sPtr(Scaner) scaner(new Scaner);// динамич. указатель на сканер
e.Accept(dynamic_pointer_cast<Scaner>(scaner));
while (!fin.eof())
{
getline(fin, temp);
scaner->SetString(temp);
}
if (e.HasErrors())
{
f << e;
}
else
{
sPtr(Token) t;
size_t max_value_len = scaner->GetMaxTokenLength(); // для выравнивания
f << "<Token List: >" << endl;;
while (true)
{
t = scaner->PopToken();
if (t->type != T_EOF)
{
f << t->ToString(max_value_len) << endl;
}
else
{
break;
}
}
scaner->ResetTokenPos();
f << endl << "<ID List: >" << endl;
set<string> IdList = scaner->GetIdList();
for (set<string>::const_iterator it = IdList.cbegin(); it != IdList.cend(); ++it)
{
f << *it << endl;
}
}
return 0;
}