00001 /*========================================================================== 00002 * Copyright (c) 2003-2004 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 00013 // 00014 // MetadataPair 00015 // 00016 // 12 May 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_METADATAPAIR_HPP 00020 #define INDRI_METADATAPAIR_HPP 00021 00022 #include <string.h> 00023 #include <ctype.h> 00024 00025 struct MetadataPair { 00026 const char* key; 00027 const void* value; 00028 int valueLength; 00029 00030 class key_equal { 00031 const char* k; 00032 00033 public: 00034 key_equal( const char* key ) { 00035 k = key; 00036 } 00037 00038 bool operator() ( const MetadataPair& pair ) { 00039 return strcmp( k, pair.key ) == 0; 00040 } 00041 }; 00042 00043 void stripValue() { 00044 while( isspace( *(char*)value ) ) { 00045 value = (char*)value + 1; 00046 valueLength -= 1; 00047 } 00048 00049 while( isspace( ((char*)value)[valueLength-2] ) ) { 00050 valueLength -= 1; 00051 ((char*)value)[valueLength-1] = 0; 00052 } 00053 } 00054 }; 00055 00056 #endif // INDRI_METADATAPAIR_HPP