Go to the documentation of this file.00001
00002 #ifndef __CConcHolder_H_
00003 #define __CConcHolder_H_
00004
00005
00006 #include "ConcIndexator.h"
00007
00008
00009
00011 typedef bool (*SaveTriggerType) (const string&,DWORD LParam);
00012
00013 class CQueryParser;
00014
00015
00022 struct CQueryResult
00023 {
00025 vector<CHit> m_Hits;
00027 vector<CTokenNo> m_HighlightOccurs;
00029 size_t m_AllHitsCount;
00031 size_t m_RelevantDocumentCount;
00032
00033 mutable vector<BYTE> m_DebugInfo;
00034 void ClearQueryResults();
00035
00036 };
00037
00038
00039
00040
00041
00045 class CConcHolder : public CConcIndexatorInvoker,
00046 public CQueryResult
00047 {
00048 public:
00057 enum FormatTypeEnum{DDC_ResultHTML, DDC_ResultText, DDC_ResultTable, DDC_ResultDocIds, DDC_ResultJson};
00058
00059 private:
00061 map<string, CQueryResult> m_QueryCache;
00063 deque<string> m_Queries;
00065 CQueryParser* m_pQueryEvaluator;
00067 time_t m_QueryEndTime;
00069 const vector<CTokenNo>* m_pBreaks;
00071 FormatTypeEnum m_ResultFormat;
00072
00073
00074
00075
00076
00078 void AddFileReference(const long FileNo);
00080 void ShowBibliographyForTextOrHtml(const CHit& Hit, DWORD PageNumber);
00082 bool ShowBibliographyForTable(DWORD PageNumber, const CHit& Hit, const vector<COutputToken>& Tokens);
00084 bool GenerateOneHitString(DWORD PageNumber, const CHit& Hit, const vector<COutputToken>& Tokens);
00086 bool GenerateOneHitStringJson(DWORD PageNumber, const CHit& Hit, const vector<COutputToken>& Tokens);
00088 bool GetContext(int StartBreakNo, int EndBreakNo, const DWORD CurrFileNo, const bool bConvertASCIIToHtmlSymbols, string& Result) const;
00090 bool GetContextJson(int StartBreakNo, int EndBreakNo, const DWORD CurrFileNo, string& js) const;
00092 DDCErrorEnum GetAllHits(string Query, size_t Limit);
00094 bool TryToGetFromCache(string Query, DWORD& EndHitNo);
00096 void SaveToCache(string& Query, vector<size_t>::const_iterator start, vector<size_t>::const_iterator end);
00098 void SetHitType();
00100 bool GetFileSnippets(const int HitNo, vector<COutputToken>& Tokens) const;
00102 bool SaveOccurrences(const vector<size_t>& ChunkLengths, int ContextSize, const vector<CTokenNo>& Occurrences, const vector<CHit>& Hits, SaveTriggerType SaveTrigger,DWORD LParam);
00104 bool GetTokensFromStorageByBreak(size_t IndexNo, size_t BreakNo, vector<COutputToken>& Tokens) const;
00106 void InitFileReferences(vector<CHit>& Hits) const;
00108 void InitOrderIDForHits(const CDDCFilterWithBounds& Filter) const;
00109 void InitLessByRank() const;
00110 void InitGreaterByRank() const;
00111 void InitLessBySize() const;
00112 void InitGreaterBySize() const;
00113 void InitLessByBigrams() const;
00114
00115 public:
00116
00118 mutable CShortOccurCacheMap m_ShortOccurCaches;
00119
00121 string m_QueryResultStr;
00122
00126 CConcIndexator* m_pIndexator;
00127
00129 size_t m_ResultLimit;
00130
00131
00133 size_t m_CurrentSearchPeriodNo;
00135 string m_AdditionalHitDelimeter;
00136
00137
00138 CConcHolder();
00139 ~CConcHolder();
00140
00142 const vector<CTokenNo>& GetBreaks () const;
00143
00145 FormatTypeEnum GetResultFormat() const { return m_ResultFormat; };;
00147 string GetResultFormatStr() const;
00149 void SetResultFormat(string ResultTypeStr);
00150
00155 DDCErrorEnum GetOccurrences(string Query, int ContextSize, SaveTriggerType SaveTrigger,DWORD LParam);
00156
00157
00159
00166 DDCErrorEnum SimpleQuery(string Query, DWORD& EndHitNo, DWORD& HitsCount);
00168 DDCErrorEnum GetHits(string Query, DWORD& EndHitNo);
00170 DDCErrorEnum GenerateHitStrings(const int StartHitNo);
00172 string GetHitIds() const;
00174 bool HitsShouldBeSorted() const;
00176 void SetTimeOut(int TimeOut);
00178 void ClearQueryCache();
00180 int GetTextArea() const;
00181
00183 static FormatTypeEnum GetResultFormatByString(const string& ResultTypeStr );
00184
00186 static void DecorateQueryResults(const string& ResultTypeStr, string& QueryResultString);
00187
00190 bool HasRankOrderOperator() const;
00192 int GetBreakStarterLength() const;
00193
00195 BigramDirectionEnum GetBigramsToOrder() const;
00196
00198 string BuildJsonContextString (const vector<COutputToken>& Tokens, bool doHighlight=true) const;
00199 };
00200
00201
00205 class CConcordance : public CConcHolder
00206 {
00207 public:
00209 bool m_bOptionsWereModified;
00210
00211 CConcordance();
00212 virtual ~CConcordance();
00213
00215 bool LoadProject(const char* FileName);
00216
00218 bool SaveProject(string FileName);
00219 };
00220
00221
00222
00223 #endif