00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef IXE_Common_DocInfo_H
00026 #define IXE_Common_DocInfo_H
00027
00028
00029 #include "include/ixe.h"
00030
00031
00032 #include <sys/stat.h>
00033 #include <sys/types.h>
00034
00035
00036 #include "include/error.h"
00037 #include "Common/metaclass.h"
00038
00039 namespace IXE {
00040
00041 #ifndef DllExport
00042 # ifdef _WIN32
00043 # ifdef STATIC_LINKED
00044 # define DllExport
00045 # else
00046 # define DllExport __declspec(dllexport)
00047 # endif
00048 # else
00049 # define DllExport
00050 # endif
00051 #endif
00052
00053 #if defined(_WIN32) || defined(__DECCXX) || defined(__GNUC__)
00054
00055 #pragma pack(push, 4)
00056 #endif
00057
00058 class DocReader;
00059
00060
00064
00065 class DocInfo {
00066 friend class DocReader;
00067 friend class Indexer;
00068
00069 public:
00070
00071 typedef int time32_t;
00072
00074
00075 DocInfo(DocID id = 0, IXE::Size size = 0, time_t time = 0) :
00076 id(id), size(size), time(time)
00077 { }
00078
00080
00081 DocID ID() const { return id; }
00083 IXE::Size Size() const { return size; }
00085 time_t Time() const { return time; }
00086
00088
00094 virtual void Dispose() { }
00095
00100 virtual bool operator ==(DocInfo const &other) {
00101 return id == other.id && size == other.size && time == other.time;
00102 }
00103
00112 virtual void mapFields(DocReader* dr, char const* field) { }
00113
00117 friend std::ostream& operator <<(std::ostream& s, const DocInfo& d);
00118
00119
00120
00121
00122
00123 virtual std::ostream& serialize(std::ostream& s) const {
00124 return s << id << '\t' << size << '\t' << time;
00125 }
00126
00127 DocID id;
00128 IXE::Size size;
00129 time32_t time;
00130
00131 META(DocInfo,
00132 (KEY(id, Field::autoincrement),
00133 FIELD(size),
00134 FIELD(time))
00135 );
00136 };
00137
00138 inline std::ostream& operator <<(std::ostream& s, const DocInfo& d)
00139 {
00140 return d.serialize(s);
00141 }
00142
00143 #if defined(_WIN32) || defined(__DECCXX) || defined(__GNUC__)
00144 #pragma pack(pop)
00145 #endif
00146
00147 }
00148
00149 #endif