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