1*7b6bd0c4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*7b6bd0c4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*7b6bd0c4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*7b6bd0c4SAndrew Rist * distributed with this work for additional information 6*7b6bd0c4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*7b6bd0c4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*7b6bd0c4SAndrew Rist * "License"); you may not use this file except in compliance 9*7b6bd0c4SAndrew Rist * with the License. You may obtain a copy of the License at 10*7b6bd0c4SAndrew Rist * 11*7b6bd0c4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*7b6bd0c4SAndrew Rist * 13*7b6bd0c4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*7b6bd0c4SAndrew Rist * software distributed under the License is distributed on an 15*7b6bd0c4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*7b6bd0c4SAndrew Rist * KIND, either express or implied. See the License for the 17*7b6bd0c4SAndrew Rist * specific language governing permissions and limitations 18*7b6bd0c4SAndrew Rist * under the License. 19*7b6bd0c4SAndrew Rist * 20*7b6bd0c4SAndrew Rist *************************************************************/ 21*7b6bd0c4SAndrew Rist 22*7b6bd0c4SAndrew Rist 23cdf0e10cSrcweir #ifndef _XMLSEARCH_QE_QUERY_HXX_ 24cdf0e10cSrcweir #define _XMLSEARCH_QE_QUERY_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <sal/types.h> 27cdf0e10cSrcweir #include <rtl/memory.h> 28cdf0e10cSrcweir #include <rtl/ustring.hxx> 29cdf0e10cSrcweir #include <vector> 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace xmlsearch { 33cdf0e10cSrcweir 34cdf0e10cSrcweir namespace qe { 35cdf0e10cSrcweir 36cdf0e10cSrcweir class Search; 37cdf0e10cSrcweir class RoleFiller; 38cdf0e10cSrcweir 39cdf0e10cSrcweir class QueryHit 40cdf0e10cSrcweir { 41cdf0e10cSrcweir public: 42cdf0e10cSrcweir QueryHit(sal_Int32 nColumns,double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end)43cdf0e10cSrcweir QueryHit( sal_Int32 nColumns,double penalty,sal_Int32 doc,sal_Int32 begin,sal_Int32 end ) 44cdf0e10cSrcweir : doc_( doc ), 45cdf0e10cSrcweir begin_( begin ), 46cdf0e10cSrcweir end_( end ), 47cdf0e10cSrcweir matchesL_( 2*nColumns ), 48cdf0e10cSrcweir matches_( new sal_Int32[ 2*nColumns ] ), 49cdf0e10cSrcweir penalty_( penalty ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir rtl_zeroMemory( matches_,sizeof( sal_Int32 ) * matchesL_ ); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir ~QueryHit()54cdf0e10cSrcweir ~QueryHit() { delete[] matches_; } 55cdf0e10cSrcweir getDocument() const56cdf0e10cSrcweir sal_Int32 getDocument() const { return doc_; } 57cdf0e10cSrcweir countOfMatches() const58cdf0e10cSrcweir sal_Int32 countOfMatches() const { return matchesL_; } 59cdf0e10cSrcweir getBegin() const60cdf0e10cSrcweir sal_Int32 getBegin() const { return begin_; } 61cdf0e10cSrcweir getEnd() const62cdf0e10cSrcweir sal_Int32 getEnd() const { return end_; } 63cdf0e10cSrcweir getPenalty() const64cdf0e10cSrcweir double getPenalty() const { return penalty_; } 65cdf0e10cSrcweir betterThan(const QueryHit * o)66cdf0e10cSrcweir bool betterThan( const QueryHit* o ) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir if( penalty_ != o->penalty_ ) 69cdf0e10cSrcweir return penalty_ < o->penalty_; 70cdf0e10cSrcweir else if( begin_ != o->begin_ ) 71cdf0e10cSrcweir return begin_ < o->begin_; 72cdf0e10cSrcweir else if( end_ != o->end_ ) 73cdf0e10cSrcweir return end_ < o->end_; 74cdf0e10cSrcweir else 75cdf0e10cSrcweir return false; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir worseThan(const QueryHit * o)78cdf0e10cSrcweir bool worseThan( const QueryHit* o ) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir if( penalty_ != o->penalty_ ) 81cdf0e10cSrcweir return penalty_ > o->penalty_; 82cdf0e10cSrcweir else if( begin_ != o->begin_ ) 83cdf0e10cSrcweir return begin_ > o->begin_; 84cdf0e10cSrcweir else if( end_ != o->end_ ) 85cdf0e10cSrcweir return end_ > o->end_; 86cdf0e10cSrcweir else 87cdf0e10cSrcweir return false; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir worseThan(double penalty,sal_Int32 begin,sal_Int32 end)90cdf0e10cSrcweir bool worseThan( double penalty,sal_Int32 begin,sal_Int32 end ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir if( penalty_ != penalty ) 93cdf0e10cSrcweir return penalty_ > penalty; 94cdf0e10cSrcweir else if( begin_ != begin ) 95cdf0e10cSrcweir return begin_ > begin; 96cdf0e10cSrcweir else if( end_ != end ) 97cdf0e10cSrcweir return end_ > end; 98cdf0e10cSrcweir else 99cdf0e10cSrcweir return false; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir compareTo(const QueryHit * o) const102cdf0e10cSrcweir bool compareTo( const QueryHit* o ) const 103cdf0e10cSrcweir { 104cdf0e10cSrcweir if( penalty_ != o->penalty_ ) 105cdf0e10cSrcweir return penalty_ < o->penalty_; 106cdf0e10cSrcweir else if( begin_ != o->begin_ ) 107cdf0e10cSrcweir return begin_ < o->begin_; 108cdf0e10cSrcweir else if( end_ != o->end_ ) 109cdf0e10cSrcweir return end_ < o->end_; 110cdf0e10cSrcweir else 111cdf0e10cSrcweir return false; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir private: 116cdf0e10cSrcweir 117cdf0e10cSrcweir sal_Int32 doc_,begin_,end_; 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_Int32 matchesL_; 120cdf0e10cSrcweir sal_Int32 *matches_; // ...concept, word number, ... 121cdf0e10cSrcweir 122cdf0e10cSrcweir double penalty_; 123cdf0e10cSrcweir 124cdf0e10cSrcweir }; // end class QueryHit 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir 128cdf0e10cSrcweir class QueryHitData 129cdf0e10cSrcweir { 130cdf0e10cSrcweir public: 131cdf0e10cSrcweir QueryHitData(double penalty,const rtl::OUString & document,sal_Int32 termsL,rtl::OUString * terms)132cdf0e10cSrcweir QueryHitData( double penalty,const rtl::OUString& document,sal_Int32 termsL, rtl::OUString* terms ) 133cdf0e10cSrcweir : penalty_( penalty ), 134cdf0e10cSrcweir document_( document ), 135cdf0e10cSrcweir termsL_( termsL ), 136cdf0e10cSrcweir terms_( terms ) { } 137cdf0e10cSrcweir ~QueryHitData()138cdf0e10cSrcweir ~QueryHitData() { delete[] terms_; } 139cdf0e10cSrcweir getDocument() const140cdf0e10cSrcweir rtl::OUString getDocument() const { return document_; } 141cdf0e10cSrcweir getPenalty() const142cdf0e10cSrcweir double getPenalty() const { return penalty_; } 143cdf0e10cSrcweir 144cdf0e10cSrcweir 145cdf0e10cSrcweir private: 146cdf0e10cSrcweir 147cdf0e10cSrcweir double penalty_; 148cdf0e10cSrcweir 149cdf0e10cSrcweir const rtl::OUString document_; 150cdf0e10cSrcweir 151cdf0e10cSrcweir sal_Int32 termsL_; 152cdf0e10cSrcweir rtl::OUString* terms_; 153cdf0e10cSrcweir 154cdf0e10cSrcweir }; // end class QueryHitData 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir class PrefixTranslator 158cdf0e10cSrcweir { 159cdf0e10cSrcweir public: 160cdf0e10cSrcweir makePrefixTranslator(const rtl::OUString *,sal_Int32)161cdf0e10cSrcweir static PrefixTranslator* makePrefixTranslator( const rtl::OUString*,sal_Int32 ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir return 0; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir }; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir 171cdf0e10cSrcweir #endif 172