http://bugs.openzim.org/show_bug.cgi?id=13
Summary: zim::File::find always returns an article Product: openZIM Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P5 Component: zimlib AssignedTo: tommi@tntnet.org ReportedBy: emmanuel@engelhart.org CC: dev-l@openzim.org Estimated Hours: 0.0
If I call find() with a title corresponding to nothing ("ahsdfkijhasfnsadf" for example) in the ZIM file, find() returns an other article.
To my opinion, I should have a way to indentify if the article was found or not (currently i compare the title I have given and article.getTitle() but this can not be the good way)
My code looks like following: zim::File::const_iterator iterator = zimFileHandler->find(ns[0], zim::QUnicodeString(title)); zim::Article article = zimFileHandler->getArticle(iterator.getIndex());
http://bugs.openzim.org/show_bug.cgi?id=13
Tommi Mäkitalo tommi@tntnet.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME
--- Comment #1 from Tommi Mäkitalo tommi@tntnet.org 2009-11-08 17:14:44 CET --- zim::File::find returns always the next article when no excact match was found.
There is another method "zim::File::findx(char ns, const QUnicodeString& title, bool collate = false)". This returns a "std::pair<bool, const_iterator>". The first element is true, if a excact match was found and false otherwise. The second element returns the const_iterator. zim::File::find is actually a wrapper around findx, which throws the bool-flag away and returns just the const_iterator.
You may as well use zim::File::getArticle. This uses findx as well but returns a null article (article.good() returns false) if no exact match was found.