Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

include/xapian/document.h

Go to the documentation of this file.
00001 
00024 #ifndef XAPIAN_INCLUDED_DOCUMENT_H
00025 #define XAPIAN_INCLUDED_DOCUMENT_H
00026 
00027 #include <xapian/types.h>
00028 #include <iterator>
00029 
00030 namespace Xapian {
00031 
00032 class TermIterator;
00033 class ValueIterator;
00034 
00036 class Document {
00037   public:
00038     class Internal;
00040     Internal *internal;
00041 
00046     explicit Document(Document::Internal *internal_);
00047 
00051     Document(const Document &other);
00052 
00056     void operator=(const Document &other);
00057 
00059     Document();
00060 
00062     ~Document();
00063 
00065     std::string get_value(valueno value) const;
00066 
00068     //  same number.
00069     void add_value(valueno valueno, const std::string &value);
00070 
00072     void remove_value(valueno valueno);
00073 
00075     void clear_values();
00076 
00082     std::string get_data() const;
00083 
00085     void set_data(const std::string &data);
00086 
00101     void add_posting(const termname & tname, termpos tpos,
00102                      termcount wdfinc = 1);
00103 
00114     void add_term_nopos(const termname & tname, termcount wdfinc = 1);
00115 
00135     void remove_posting(const termname & tname, termpos tpos,
00136                         termcount wdfdec = 1);
00137 
00145     void remove_term(const termname & tname);
00146 
00148     void clear_terms();
00149 
00151     termcount termlist_count();
00152 
00154     TermIterator termlist_begin() const;
00155 
00157     TermIterator termlist_end() const;
00158 
00160     termcount values_count();
00161 
00163     ValueIterator values_begin() const;
00164 
00166     ValueIterator values_end() const;
00167 
00172     std::string get_description() const;
00173 };
00174 
00175 class Database;
00176 class PositionListIterator;
00177 
00180 class TermIterator {
00181   private:
00182     // friend classes which need to be able to construct us
00183     friend class Database;
00184     friend class Document;
00185 
00186   public:
00187     class Internal;
00189     Internal *internal;
00190 
00191     friend bool operator==(const TermIterator &a, const TermIterator &b);
00192 
00193     // FIXME: better if this was private...
00194     TermIterator(Internal *internal_);
00195 
00197     TermIterator();
00198 
00200     ~TermIterator();
00201 
00205     TermIterator(const TermIterator &other);
00206 
00210     void operator=(const TermIterator &other);
00211 
00212     termname operator *() const;
00213 
00214     TermIterator & operator++();
00215 
00216     void operator++(int);
00217 
00218     // extra method, not required for an input_iterator
00219     void skip_to(const termname & tname);
00220 
00221     termcount get_wdf() const;
00222     doccount get_termfreq() const;
00223 
00224     // allow iteration of positionlist for current document
00225     PositionListIterator positionlist_begin();
00226     PositionListIterator positionlist_end();
00227 
00231     std::string get_description() const;
00232 
00234 
00235     typedef std::input_iterator_tag iterator_category;
00236     typedef termname value_type;
00237     typedef termcount_diff difference_type;
00238     typedef termname * pointer;
00239     typedef termname & reference;
00241 };
00242 
00243 inline bool
00244 operator!=(const TermIterator &a, const TermIterator &b)
00245 {
00246     return !(a == b);
00247 }
00248 
00249 class PostListIterator;
00250 
00251 class PositionListIterator {
00252   private:
00253     // friend classes which need to be able to construct us
00254     friend class PostListIterator;
00255     friend class TermIterator;
00256     friend class Database;
00257 
00258   public:
00259     class Internal;
00261     Internal *internal;
00262 
00263     friend bool operator==(const PositionListIterator &a,
00264                            const PositionListIterator &b);
00265 
00266     // FIXME: ought to be private
00267     PositionListIterator(Internal *internal_);
00268 
00270     PositionListIterator();
00271 
00273     ~PositionListIterator();
00274 
00275     void operator=(PositionListIterator &o);
00276     PositionListIterator (const PositionListIterator &o);
00277 
00278     termpos operator *() const;
00279 
00280     PositionListIterator & operator++();
00281 
00282     void operator++(int);
00283 
00284     // extra method, not required for an input_iterator
00285     void skip_to(termpos pos);
00286 
00290     std::string get_description() const;
00291 
00292     // Allow use as an STL iterator
00293     typedef std::input_iterator_tag iterator_category;
00294     typedef termpos value_type;
00295     typedef termpos_diff difference_type;
00296     typedef termpos * pointer;
00297     typedef termpos & reference;
00298 };
00299 
00300 inline bool operator!=(const PositionListIterator &a,
00301                        const PositionListIterator &b)
00302 {
00303     return !(a == b);
00304 }
00305 
00308 class ValueIterator {
00309   private:
00310     friend class Document; // So Document can construct us
00311 
00312     friend bool operator==(const ValueIterator &a, const ValueIterator &b);
00313 
00314     ValueIterator(Internal *internal_);
00315 
00316   public:
00317     class Internal;
00319     Internal *internal;
00320 
00322     ValueIterator();
00323 
00325     ~ValueIterator();
00326 
00328     ValueIterator(const ValueIterator &other);
00329 
00331     void operator=(const ValueIterator &other);
00332 
00333     ValueIterator & operator++();
00334 
00335     void operator++(int);
00336 
00338     const std::string & operator *() const;
00339 
00341     const std::string * operator ->() const;
00342 
00344     valueno get_valueno() const;
00345 
00349     std::string get_description() const;
00350 
00352 
00353     typedef std::input_iterator_tag iterator_category;
00354     typedef std::string value_type;
00355     typedef valueno_diff difference_type;
00356     typedef std::string * pointer;
00357     typedef std::string & reference;
00359 };
00360 
00361 inline bool operator!=(const ValueIterator &a, const ValueIterator &b)
00362 {
00363     return !(a == b);
00364 }
00365 
00366 };
00367 
00368 #endif

Documentation for Xapian (version 0.6.3).
Generated on 24 Dec 2002 by Doxygen 1.2.15.