Go to the documentation of this file.00001 #ifndef HitBorder_h
00002 #define HitBorder_h
00003
00022 struct CPageNumber {
00024 CTokenNo m_StartTokenNo;
00026 DWORD m_PageNumber;
00027 };
00028
00029
00030
00031
00036 class CHitBorders
00037 {
00040 struct CBreakCollection
00041 {
00043 string m_ShortName;
00045 string m_LongName;
00046
00048 mutable FILE* m_FileForIndexing;
00050 vector<CTokenNo> m_BreakOffsets;
00051
00052 CBreakCollection (const string& ShortName, const string& LongName);
00054 string GetBreakFileName(string Path) const;
00055 void ReadFromDisk(string Path);
00056 bool ClearAll(string Path);
00057 void CloseFileForIndexing();
00058 };
00059
00061 vector<CBreakCollection> m_Breaks;
00063 map<string,int> m_ShortName2BreakCollection;
00065 int m_FileBreakCollectionNo;
00067 string m_DefaultBreakName;
00069 vector<CPageNumber> m_PageBreaks;
00070
00072 string GetPageBreaksFileName(string Path) const;
00074 string GetShortNameByName(const string& BreakName) const;
00075
00076
00078 vector<DWORD> m_LastTextAreaBreaks;
00079
00080 protected:
00082 bool StartIndexing(string Path);
00084 bool RemoveHitBordersFileAndClear(string Path);
00086 void AddPageBreak(const CPageNumber& P);
00088 bool UniteBorders(const CHitBorders& H1, const CHitBorders& H2, const DWORD EndTokenNo1, const string& Path);
00089 bool RegisterBreak(string ShortName, string LongName);
00090 string GetBreakCollectionShortName(size_t i) const;
00091 int GetBreakCollectionIndexByName(string ShortName ) const;
00092 bool AddBreakByIndex(DWORD BreakCollectionNo, const CTokenNo& B);
00093 public:
00094
00095 CHitBorders();
00097 string GetBorderIndicesString() const;
00099 vector<string> GetBorderIndicesStringVector() const;
00101 string ProcessHitTypeStrInQueryStr(string& Query) const;
00103 const vector<CTokenNo>* GetBreaksByName(const string& ShortName) const;
00105 CTokenNo GetCorpusEndTokenNo() const;
00107 const vector<CTokenNo>& GetFileBreaks() const;
00109 CTokenNo GetFileStartTokenNo(size_t FileNo) const;
00111 DWORD GetPageNumber(size_t No) const;
00113 bool IsRegisteredBreak(const string& ShortName) const;
00115 bool RegisterBorderIndices(const char* IndicesStr);
00117 bool LoadHitBorders(string Path);
00119 void ConvertHitsToPageBreaks (vector<CHit>::const_iterator hits_begin, vector<CHit>::const_iterator hits_end, const vector<CTokenNo>& Breaks, DwordVector& PageBreaks) const;
00121 bool AddBreakByName(const string& ShortName, const CTokenNo& B);
00123 bool BordersEndIndexing(string Path);
00125 void StartTextAreaBorders();
00127 bool EndTextAreaBorders(DWORD TextAreaEndTokenNo);
00128
00129 };
00130
00131
00132 #endif