bump product version to 5.0.4.1
[LibreOffice.git] / xmlhelp / source / cxxhelp / test / searchdemo.cxx
blobe2ee86611c09b9d6faa1819275825f913d04934d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <rtl/string.hxx>
21 #include <osl/file.hxx>
22 #include <db/Block.hxx>
23 #include <db/BtreeDictParameters.hxx>
24 #include <db/BtreeDict.hxx>
25 #include <util/RandomAccessStream.hxx>
26 #include <db/DBEnv.hxx>
27 #include <qe/QueryProcessor.hxx>
29 #ifdef ABIDEBUG
30 #include <abidebug.hxx>
31 #endif
34 using namespace xmlsearch::util;
35 using namespace xmlsearch::db;
36 using namespace xmlsearch::qe;
40 extern RandomAccessStream* theFile();
44 void print_rtl_OUString( const OUString bla )
46 OString bluber = OString( bla.getStr(),bla.getLength(),RTL_TEXTENCODING_UTF8 );
47 char* bluberChr = new char[ 1+bluber.getLength() ];
48 const sal_Char* jux = bluber.getStr();
50 for( int i = 0; i < bluber.getLength(); ++i )
51 bluberChr[i] = jux[i];
53 bluberChr[ bluber.getLength() ] = 0;
54 printf( "%s\n",bluberChr );
55 delete[] bluberChr;
59 extern void bla();
60 extern void blu();
63 int main( int argc,char* argv[] )
66 QueryResults* queryResults = 0;
68 try
70 OUString installDir("//./e|/index/");
71 QueryProcessor queryProcessor( installDir );
73 std::vector<OUString> Query(2);
74 Query[0] = "text*";
75 Query[1] = "abbildung";
76 OUString Scope = "headingheading";
77 int HitCount = 40;
79 QueryStatement queryStatement( HitCount,Query,Scope );
80 queryResults = queryProcessor.processQuery( queryStatement );
82 OUString translations[2];
83 translations[0] = "#HLP#";
84 translations[1] = "vnd.sun.star.help://";
86 PrefixTranslator* translator = PrefixTranslator::makePrefixTranslator( translations,2 );
88 QueryHitIterator* it = queryResults->makeQueryHitIterator();
89 sal_Int32 j = 0;
90 while( j < 10 && it->next() )
92 printf( "Ergebnis %2d ",j );
93 QueryHitData* qhd = it->getHit( translator );
94 printf( "Penalty = %10.4f ",qhd->getPenalty() );
95 print_rtl_OUString( qhd->getDocument() );
96 ++j;
99 delete it;
101 catch( ... )
103 printf( "catched exception" );
104 throw;
106 return 0;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */