109
edits
Line 50: | Line 50: | ||
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. | 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. | ''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. I should add, that both - the url and title - are case sensitive. | ||
;Sample: find a article by title and print the content: | ;Sample: find a article by title and print the content: |