00001 #ifndef LUX_DOCUMENT_H
00002 #define LUX_DOCUMENT_H
00003
00004 #include "lux/lux.h"
00005 #include "field.h"
00006 #include <vector>
00007 #include <string>
00008
00009 #ifdef HAVE_TR1_MEMORY
00010 #include <tr1/memory>
00011 #elif HAVE_BOOST_SHARED_PTR_HPP
00012 #include <boost/shared_ptr.hpp>
00013 #endif
00014
00015 #define ERR_DOC_ID "__ERRDOC__"
00016
00017 namespace Lux {
00018
00019 #ifdef HAVE_TR1_MEMORY
00020 typedef std::tr1::shared_ptr<const Lux::Field> SPF;
00021 #elif HAVE_BOOST_SHARED_PTR_HPP
00022 typedef boost::shared_ptr<const Lux::Field> SPF;
00023 #endif
00024 typedef std::vector<SPF> FieldContainer;
00025 typedef FieldContainer::const_iterator FCIterator;
00026
00030 class Document {
00031 public:
00036 Document(char *id);
00041 Document(std::string &id);
00045 Document(const Document &doc);
00049 Document &operator=(const Document &rhs);
00053 ~Document(void);
00058 void add(const Field *field);
00062 bool has_next(void);
00066 bool has_next(void) const;
00070 const Field *get_next(void);
00074 const Field *get_next(void) const;
00078 void init_iter(void);
00082 void init_iter(void) const;
00086 const std::string get_eid(void);
00090 const std::string get_eid(void) const;
00094 void set_id(doc_id_t internal_id);
00098 const doc_id_t get_id(void);
00102 const doc_id_t get_id(void) const;
00106 const std::string get_by_name(std::string field_name);
00107
00108 private:
00109 doc_id_t internal_id_;
00110 std::string external_id_;
00111 FieldContainer fields_;
00112 mutable FCIterator fields_iterator_;
00113 };
00114 }
00115
00116 #endif