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,ruijieguo@gmail.com 00012 // Created : 2005/11/20 00013 // 00014 #ifndef _DOCTYPEDEF_H 00015 #define _DOCTYPEDEF_H 00016 00017 #include "../utility/StdHeader.h" 00018 #include <string> 00019 using namespace std; 00020 00021 namespace firtex 00022 { 00023 namespace document 00024 { 00025 typedef unsigned int doc_type; 00026 typedef struct _tagDOCTYPETONAME 00027 { 00028 doc_type type; 00029 tchar name[10]; 00030 }DOCTYPETONAME; 00031 00032 #define DOCTYPE_DEFINE(t, value,name) namespace doc { const DOCTYPETONAME t = {value,name}; } 00033 00034 00035 DOCTYPE_DEFINE(NONE,0,_T(""))//always keep it on top 00036 00037 DOCTYPE_DEFINE(TXT,1,_T("txt")) 00038 DOCTYPE_DEFINE(HTML,2,_T("html")) 00039 DOCTYPE_DEFINE(HTM,3,_T("htm")) 00040 DOCTYPE_DEFINE(PDF,4,_T("pdf")) 00041 DOCTYPE_DEFINE(DOC,5,_T("doc")) 00042 DOCTYPE_DEFINE(PPT,6,_T("ppt")) 00043 DOCTYPE_DEFINE(XSL,7,_T("xsl")) 00044 DOCTYPE_DEFINE(BMP,8,_T("bmp")) 00045 DOCTYPE_DEFINE(JPG,9,_T("jpg")) 00046 DOCTYPE_DEFINE(JPEG,10,_T("jpeg")) 00047 DOCTYPE_DEFINE(RM,11,_T("rm")) 00048 DOCTYPE_DEFINE(MP3,12,_T("mp3")) 00049 DOCTYPE_DEFINE(AVI,13,_T("avi")) 00050 00051 DOCTYPE_DEFINE(ALL,1000,_T("*"))//always keep it at bottom 00052 00053 static tstring TypeToName(doc_type type) 00054 { 00055 const DOCTYPETONAME* pStart = &doc::NONE; 00056 const DOCTYPETONAME* pEnd = &doc::ALL; 00057 while (pStart <= pEnd) 00058 { 00059 if(pStart->type == type) 00060 return pStart->name; 00061 pStart++; 00062 } 00063 return _T(""); 00064 } 00065 00071 static doc_type NameToType(const tchar* name) 00072 { 00073 const DOCTYPETONAME* pStart = &doc::NONE; 00074 const DOCTYPETONAME* pEnd = &doc::ALL; 00075 while (pStart < pEnd) 00076 { 00077 if(!_tcsicmp(pStart->name,name)) 00078 return pStart->type; 00079 pStart++; 00080 } 00081 return doc::NONE.type; 00082 } 00083 } 00084 } 00085 00086 00087 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex