ZIMlib is the library which implements the access to ZIM files. Use libzim in your own software - like reader applications - to make them ZIM-capable without the need having to dig too much into the ZIM file format .
== Programming ==
=== Introduction ===zimlib is written in C++. To use the library, you need the include files of zimlib have to link against
libzim. Both are installed when zimlib is built with the normal "./configure; make; make install ".
Errors are handled with exceptions. When something goes wrong, zimlib throws an error, which is always derived from std::exception.
int main(int argc, char* argv)
You may save that file under the name "zimlist.cpp" and compile using the command:
'''g++ -o zimlist -lzim zimlist.cpp'''. You get a program, which lists the urls and titles of the file named ''wikipedia.zim''. Of course it is better to pass that name as a parameter in argc/argv. But this should be an easy task for you, so I do not show that.
In subsequent examples I show only the code needed to use the library. The main-function with the error catcher should always be in place.
Articles are addressed either by index or by namespace and url or title. The index is normally not that useful. So let us look how to find a specific article.
''zim::File'' has methods ''find'' and ''findByTitle''. Both take 2 parameters. A char for the namespace (which is normally 'A' for articles) and a string, which specifies the url (in find) or the title (in findByTitle). It returns a const_iterator pointing to the lexicographically next article. Be aware, that the returned iterator may point to end(), so you should check that, before dereferencing the iterator.
;Sample: find a article by title and print the content:
= == Methods
======= Article File:: getArticle(char ns, const QUnicodeString& title , bool collate = false) ====returns an object of an article
std::string Article::getPage(bool layout = true, unsigned maxRecurse = 10) ==== returns the content of an article