FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn 00012 // Created : 2005/12/20 00013 // 00014 #ifndef _TERM_H 00015 #define _TERM_H 00016 00017 #include "../utility/StdHeader.h" 00018 #include "../utility/FXString.h" 00019 using namespace firtex::utility; 00020 00021 namespace firtex 00022 { 00023 namespace index 00024 { 00025 class CTerm 00026 { 00027 public: 00028 CTerm(const tchar* field); 00029 CTerm(const tstring& field); 00030 CTerm(const tchar* field,const tchar* value); 00031 CTerm(const tstring& field,const tstring& value); 00032 CTerm(const CTerm& term); 00033 CTerm(); 00034 virtual ~CTerm(void); 00035 public: 00036 bool operator ==(const CTerm& t) 00037 { 00038 return (m_field == t.m_field); 00039 } 00040 const tchar* getField()const{return m_field.c_str();} 00041 void setField(const tchar* field){m_field = field;} 00042 00043 const tchar* stringValue()const{return ( (m_strValue==NULL)?NULL:m_strValue->c_str());} 00044 void stringValue(const tchar* value) 00045 { 00046 if(m_strValue == NULL) 00047 m_strValue = new CFXString(value); 00048 else *m_strValue = value; 00049 } 00050 virtual CTerm* asTermX()const; 00051 virtual int32_t compare(const CTerm* pOther); 00052 virtual CTerm* clone(); 00053 protected: 00054 CFXString m_field; //域名 00055 CFXString* m_strValue; 00056 }; 00057 00058 template<typename TermT> 00059 class CTermX : public CTerm 00060 { 00061 public: 00062 CTermX(){} 00063 CTermX(const tchar* field,const TermT t ) : CTerm(field),m_value(t) 00064 { 00065 } 00066 virtual ~CTermX(){} 00067 CTermX(const CTermX<TermT>& clone) 00068 :CTerm(clone) 00069 ,m_value(clone.m_value) 00070 { 00071 00072 } 00073 public: 00074 TermT getValue()const{return m_value;} 00075 TermT getValue(){return m_value;} 00076 void setValue(const TermT t){m_value = t;} 00077 00078 CTerm* asTermX()const{return (CTerm*)this;} 00079 CTerm* clone(){return new CTermX<TermT>(*this);} 00080 int32_t compare(const CTerm* pOther) 00081 { 00082 int32_t ret = CTerm::compare(pOther); 00083 if(ret != 0) 00084 return ret; 00085 CTermX<TermT>* pX = (CTermX<TermT>*)pOther->asTermX(); 00086 return (int32_t)(m_value - pX->m_value); 00087 } 00088 private: 00089 TermT m_value; 00090 }; 00091 } 00092 } 00093 00094 00095 00096 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex