Skip to content
Snippets Groups Projects
Verified Commit 6be3ccd9 authored by Xavier Robin's avatar Xavier Robin
Browse files

fix: exit with error code if nothing was read

parent cf017c86
No related branches found
No related tags found
No related merge requests found
......@@ -116,6 +116,11 @@ int main(int argc, char const *argv[])
compound_lib.reset();
cdp.SetCompoundLib(in_mem_lib);
cdp.Parse();
if (cdp.GetImportedCount() == 0)
{
std::cout << "No compound imported from " << argv[2] << std::endl;
return 1;
}
in_mem_lib->SetChemLibInfo();
conop::CompoundLibPtr copy = in_mem_lib->Copy(argv[3]);
if (! copy) {
......
......@@ -215,6 +215,7 @@ void ChemdictParser::OnEndData()
}
}
lib_->AddCompound(compound_);
++imported_count_;
}
}
}
......
......@@ -44,7 +44,8 @@ public:
bool ignore_reserved=false, bool ignore_obsolete=false):
StarParser(stream), compound_(new conop::Compound("UNK")),
last_(0), loop_type_(DONT_KNOW), dialect_(dialect),
ignore_reserved_(ignore_reserved), ignore_obsolete_(ignore_obsolete)
ignore_reserved_(ignore_reserved), ignore_obsolete_(ignore_obsolete),
imported_count_(0)
{
this->InitTypeMap();
this->InitPDBXTypeMap();
......@@ -65,6 +66,12 @@ public:
{
lib_=lib;
}
/// \brief Get the number of compounds that were successfully parsed
int GetImportedCount()
{
return imported_count_;
}
private:
void InitTypeMap();
void InitPDBXTypeMap();
......@@ -98,6 +105,7 @@ private:
conop::Compound::Dialect dialect_;
bool ignore_reserved_;
bool ignore_obsolete_;
int imported_count_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment